Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. package cucumber;
  2.  
  3.  
  4. import io.cucumber.java.en.Given;
  5. import io.cucumber.java.en.Then;
  6. import io.cucumber.java.en.When;
  7. import domain.FootballClubBuilder;
  8. import domain.FootballClubDates;
  9. import service.FootballClubManager;
  10. import service.FootballClubManagerImpl;
  11.  
  12. import java.util.List;
  13.  
  14. import static org.junit.Assert.assertEquals;
  15.  
  16. public class FootballClubAddGuide {
  17. private FootballClubManager footballClubManager;
  18. private FootballClubBuilder footballClubBuilder;
  19. private List<FootballClubDates>footballClubDatesList;
  20. private FootballClubDates addedFootballClub;
  21.  
  22. public FootballClubAddGuide(){
  23. footballClubBuilder = new FootballClubBuilder();
  24. footballClubManager = new FootballClubManagerImpl();
  25. }
  26.  
  27.  
  28. @Given("Football Club ID {int} FootballClub Name {string}")
  29. public void footballClubWithNameAdded (Integer id, String name) {
  30. footballClubBuilder = new FootballClubBuilder();
  31. footballClubBuilder.byId(id).byName(name);
  32. }
  33. @Given("Football Club Stadium Capacity {int}")
  34. public void footballClubStadiumCapacity (Integer stadiumCapacity){
  35. footballClubBuilder.byStadiumCapacity(stadiumCapacity);
  36. }
  37. @Given("Football Club Location {string}")
  38. public void footballClubLocation(String location) {
  39. footballClubBuilder.byLocation(location);
  40. }
  41.  
  42. @Given("Football Club Ground {string}")
  43. public void footballClubGround(String ground) {
  44. footballClubBuilder.byGround(ground);
  45. }
  46. @Given("Football Club League {string}")
  47. public void footballClubLeague(String league) {
  48. footballClubBuilder.byLeague(league);
  49. }
  50.  
  51. @When("Football Club is added")
  52. public void footballClubAdded() {
  53. addedFootballClub = footballClubBuilder.build();
  54. footballClubManager.create(addedFootballClub);
  55. }
  56.  
  57. @Then("it will exist with a given id {int} in the database")
  58. public void footballClubAddedCorrectly(Integer id){
  59. FootballClubDates footballClubCreated = footballClubManager.read(id);
  60. assertEquals(addedFootballClub.getId(), footballClubCreated.getId());
  61. }
  62. @Given("Football Clubs in base")
  63. public void addFootballClubToBase() {
  64. footballClubManager.create(new FootballClubBuilder().byId(1).byName("FC Barcelona").byStadiumCapacity(95000).byLocation("Barcelona").byGround("Camp Nou").byLeague("La Liga").build());
  65. footballClubManager.create(new FootballClubBuilder().byId(2).byName("Real Madrid").byStadiumCapacity(80000).byLocation("Madrid").byGround("Estadio Bernabeu").byLeague("La Liga").build());
  66. footballClubManager.create(new FootballClubBuilder().byId(3).byName("Sevilla FC").byStadiumCapacity(50000).byLocation("Sevilla").byGround("Estadio Ramón Sánchez Pizjuán").byLeague("La Liga").build());
  67. footballClubManager.create(new FootballClubBuilder().byId(4).byName("Atletico Madrid").byStadiumCapacity(75000).byLocation("Madrid").byGround("Wanda Metropolitano").byLeague("La Liga").build());
  68. footballClubManager.create(new FootballClubBuilder().byId(5).byName("Valencia CF").byStadiumCapacity(60000).byLocation("Valencia").byGround("Estadio Mestalla").byLeague("La Liga").build());
  69. }
  70.  
  71. @When("finding out how many leagues start with the word La{string}")
  72. public void checkTvShowTitleForWords(String regex) {
  73. footballClubDatesList = footballClubManager.findInLeague(regex);
  74. }
  75.  
  76. @Then("I am counting it {int} which leagues contains La")
  77. public void countWordAppearances (int number) {
  78. assertEquals(number, footballClubDatesList.size());
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement