Guest User

Untitled

a guest
Dec 15th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import static org.assertj.core.api.Assertions.assertThat;
  2.  
  3. import com.arun.cucumberrecipes.config.IntegrationTest;
  4. import cucumber.api.java.en.Given;
  5. import cucumber.api.java8.En;
  6. import io.cucumber.datatable.DataTable;
  7. import java.util.ArrayList;
  8. import java.util.List;
  9.  
  10. public class AdditionSteps extends IntegrationTest implements En {
  11.  
  12. public AdditionSteps() {
  13.  
  14. Given("first number is {int} and second number is {int}", (Integer firstNumber, Integer secondNumber) -> {
  15. List<Integer> numbers = new ArrayList<>();
  16. numbers.add(firstNumber);
  17. numbers.add(secondNumber);
  18.  
  19. getTestContext().setPayload(numbers);
  20. });
  21.  
  22. When("user executes sum function", () -> {
  23. List<Integer> numbers = getTestContext().getPayload(List.class);
  24. final String sumUrl = "/calculator/sum";
  25. executePost(sumUrl);
  26. });
  27.  
  28. Then("the sum is {int}", (Integer expectedSum) -> {
  29. Integer actualSum = getTestContext().getResponse()
  30. .as(Integer.class);
  31.  
  32. assertThat(actualSum).isEqualTo(expectedSum);
  33. });
  34. }
  35. }
Add Comment
Please, Sign In to add comment