java-tutorials/spring-cucumber/src/test/java/com/baeldung/StepDefsIntegrationTest.java

29 lines
1.1 KiB
Java
Raw Normal View History

2016-07-27 13:19:46 +03:00
package com.baeldung;
2016-08-02 12:46:27 +03:00
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import org.springframework.http.HttpStatus;
2016-07-27 13:19:46 +03:00
import cucumber.api.java.en.And;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
2016-10-19 16:45:26 +02:00
public class StepDefsIntegrationTest extends SpringIntegrationTest {
2016-08-02 12:34:08 +03:00
@When("^the client calls /version$")
public void the_client_issues_GET_version() throws Throwable {
executeGet("http://localhost:8082/version");
2016-07-27 13:19:46 +03:00
}
@Then("^the client receives status code of (\\d+)$")
2016-08-02 12:34:08 +03:00
public void the_client_receives_status_code_of(int statusCode) throws Throwable {
2016-07-27 13:19:46 +03:00
final HttpStatus currentStatusCode = latestResponse.getTheResponse().getStatusCode();
2016-08-02 12:34:08 +03:00
assertThat("status code is incorrect : " + latestResponse.getBody(), currentStatusCode.value(), is(statusCode));
2016-07-27 13:19:46 +03:00
}
@And("^the client receives server version (.+)$")
2016-08-02 12:34:08 +03:00
public void the_client_receives_server_version_body(String version) throws Throwable {
assertThat(latestResponse.getBody(), is(version));
2016-07-27 13:19:46 +03:00
}
2016-07-26 09:43:09 -05:00
}