Search in sources :

Example 61 with JsonPath

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);
}
Also used : JsonPath(io.restassured.path.json.JsonPath)

Example 62 with JsonPath

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();
}
Also used : Response(io.restassured.response.Response) JsonPath(io.restassured.path.json.JsonPath) ResponseBuilder(io.restassured.builder.ResponseBuilder)

Example 63 with JsonPath

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"));
}
Also used : JsonPath(io.restassured.path.json.JsonPath) Test(org.junit.Test)

Example 64 with JsonPath

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);
    }
}
Also used : JsonPath(io.restassured.path.json.JsonPath) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest) Test(org.junit.Test)

Example 65 with JsonPath

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);
    }
}
Also used : JsonPath(io.restassured.path.json.JsonPath) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

JsonPath (io.restassured.path.json.JsonPath)117 Test (org.junit.Test)101 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)82 Response (io.restassured.response.Response)9 Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)8 Date (java.util.Date)6 Property (com.b2international.snowowl.fhir.core.model.codesystem.Property)4 Coding (com.b2international.snowowl.fhir.core.model.dt.Coding)4 SubProperty (com.b2international.snowowl.fhir.core.model.dt.SubProperty)4 CodeSystem (com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem)3 Uri (com.b2international.snowowl.fhir.core.model.dt.Uri)3 HashMap (java.util.HashMap)3 TranslateResult (com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult)2 BigDecimal (java.math.BigDecimal)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)2 MappingJackson2HttpMessageConverter (org.springframework.http.converter.json.MappingJackson2HttpMessageConverter)2 MockMvc (org.springframework.test.web.servlet.MockMvc)2 OperationOutcomeCode (com.b2international.snowowl.fhir.core.codesystems.OperationOutcomeCode)1