use of io.restassured.path.json.JsonPath in project rest-assured by rest-assured.
the class CustomAuthFilter method filter.
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
final String loginResponse = post("/custom-auth/login").asString();
final JsonPath jsonPath = new JsonPath(loginResponse);
final int operandA = jsonPath.getInt("operandA");
final int operandB = jsonPath.getInt("operandB");
final String sessionId = jsonPath.getString("id");
requestSpec.param("sum", operandA + operandB);
requestSpec.param("id", sessionId);
return ctx.next(requestSpec, responseSpec);
}
use of io.restassured.path.json.JsonPath in project rest-assured by rest-assured.
the class SpookyGreetJsonResponseFilter method filter.
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
final Response response = ctx.next(requestSpec, responseSpec);
final String responseAsString = response.asString();
final JsonPath jsonPath = new JsonPath(responseAsString);
final String firstName = jsonPath.getString("greeting.firstName");
final String updatedResponse = responseAsString.replace(firstName, "Spooky");
return new ResponseBuilder().clone(response).setBody(updatedResponse).build();
}
use of io.restassured.path.json.JsonPath in project rest-assured by rest-assured.
the class JSONPostITest method supportsReturningPostBody.
@Test
public void supportsReturningPostBody() throws Exception {
final String body = with().parameters("firstName", "John", "lastName", "Doe").when().post("/greet").asString();
final JsonPath jsonPath = new JsonPath(body);
assertThat(jsonPath.getString("greeting"), equalTo("Greetings John Doe"));
}
use of io.restassured.path.json.JsonPath in project ddf by codice.
the class TestFanout method fanoutQueryReturnsOnlyOneSource.
@Test
public void fanoutQueryReturnsOnlyOneSource() throws Exception {
startCswSource();
try {
String queryUrl = REST_PATH.getUrl() + "sources";
String jsonBody = given().when().get(queryUrl).getBody().asString();
JsonPath json = JsonPath.from(jsonBody);
assertThat(json.getInt("size()"), equalTo(1));
assertThat(json.getList("id", String.class), hasItem(LOCAL_SOURCE_ID));
} finally {
getServiceManager().stopManagedService(CSW_FEDERATED_SOURCE_FACTORY_PID);
}
}
use of io.restassured.path.json.JsonPath in project ddf by codice.
the class TestFanout method nonFanoutQueryReturnsMultipleSources.
@Test
public void nonFanoutQueryReturnsMultipleSources() throws Exception {
startCswSource();
try {
getCatalogBundle().setFanout(false);
getCatalogBundle().waitForCatalogProvider();
String queryUrl = REST_PATH.getUrl() + "sources";
String jsonBody = given().when().get(queryUrl).getBody().asString();
JsonPath json = JsonPath.from(jsonBody);
assertThat(json.getInt("size()"), equalTo(2));
assertThat(json.getList("id", String.class), hasItem(LOCAL_SOURCE_ID));
assertThat(json.getList("id", String.class), hasItem(CSW_SOURCE_ID));
} finally {
getServiceManager().stopManagedService(CSW_FEDERATED_SOURCE_FACTORY_PID);
}
}
Aggregations