Search in sources :

Example 1 with JsonPath

use of io.restassured.path.json.JsonPath in project vertx-openshift-it by cescoffier.

the class ConfigurationIT method testRetrievingConfigFromStream.

@Test
public void testRetrievingConfigFromStream() throws InterruptedException {
    ensureThat("we can retrieve the application configuration through config stream", () -> await().atMost(2, TimeUnit.MINUTES).until(() -> get("/all-by-stream").getBody().jsonPath().getString("eventBus") != null));
    ensureThat("the configuration retrieved through config stream is the expected configuration\n", () -> {
        final JsonPath response = get("/all-by-stream").getBody().jsonPath();
        softly.assertThat(response.getDouble("date")).isNotNull().isPositive();
        softly.assertThat(response.getString("key")).isEqualTo("value");
        softly.assertThat(response.getString("HOSTNAME")).startsWith("config-service");
        softly.assertThat(response.getString("KUBERNETES_NAMESPACE")).isEqualToIgnoringCase(client.getNamespace());
        softly.assertThat(response.getInt("'http.port'")).isNotNull().isNotNegative();
        softly.assertThat(response.getString("propertiesExampleOption")).isEqualTo("A properties example option");
        softly.assertThat(response.getString("jsonExampleOption")).isEqualTo("A JSON example option");
        softly.assertThat(response.getString("toBeOverwritten")).isEqualTo("This is defined in YAML file.");
        softly.assertThat(response.getString("'map.items'.mapItem1")).isEqualTo("Overwrites value in JSON config file");
        softly.assertThat(response.getInt("'map.items'.mapItem2")).isEqualTo(0);
        softly.assertThat(response.getString("httpConfigContent")).isEqualTo(HTTP_CONFIG_EXPECTED_STRING);
        softly.assertThat(response.getString("dirConfigKey2")).isEqualTo("How to achieve perfection");
        softly.assertThat(response.getString("eventBus")).isEqualTo(EVENT_BUS_EXPECTED_STRING);
    });
}
Also used : JsonPath(io.restassured.path.json.JsonPath) Test(org.junit.Test)

Example 2 with JsonPath

use of io.restassured.path.json.JsonPath in project vertx-openshift-it by cescoffier.

the class ConfigurationIT method testChangingConfigurationByListeningToChange.

@Test
public void testChangingConfigurationByListeningToChange() throws InterruptedException {
    createOrEditConfigMap(ImmutableMap.of("key", "value-2", "date", Long.toString(System.currentTimeMillis()), "yet", "another"));
    ensureThat("after configuration change, the new configuration received by listening to change has been read", () -> await().atMost(2, TimeUnit.MINUTES).until(() -> get("/all").getBody().jsonPath().getString("key").equals("value-2")));
    ensureThat("the new configuration by listening to change is the expected configuration", () -> {
        final JsonPath response = get("/all").getBody().jsonPath();
        softly.assertThat(response.getDouble("date")).isNotNull().isPositive();
        softly.assertThat(response.getString("key")).isEqualTo("value-2");
        softly.assertThat(response.getString("yet")).isEqualTo("another");
        softly.assertThat(response.getString("HOSTNAME")).startsWith("config-service");
        softly.assertThat(response.getString("KUBERNETES_NAMESPACE")).isEqualToIgnoringCase(client.getNamespace());
        softly.assertThat(response.getInt("'http.port'")).isNotNull().isNotNegative();
        softly.assertThat(response.getString("propertiesExampleOption")).isEqualTo("A properties example option");
        softly.assertThat(response.getString("jsonExampleOption")).isEqualTo("A JSON example option");
        softly.assertThat(response.getString("toBeOverwritten")).isEqualTo("This is defined in YAML file.");
        softly.assertThat(response.getString("'map.items'.mapItem1")).isEqualTo("Overwrites value in JSON config file");
        softly.assertThat(response.getInt("'map.items'.mapItem2")).isEqualTo(0);
        softly.assertThat(response.getString("httpConfigContent")).isEqualTo(HTTP_CONFIG_EXPECTED_STRING);
        softly.assertThat(response.getString("dirConfigKey2")).isEqualTo("How to achieve perfection");
        softly.assertThat(response.getString("eventBus")).isEqualTo(EVENT_BUS_EXPECTED_STRING);
    });
    createOrEditConfigMap(DEFAULT_MAP);
    ensureThat("the old configuration can be read\n", () -> await().atMost(2, TimeUnit.MINUTES).until(() -> get("/all").getBody().jsonPath().getString("key").equals("value")));
}
Also used : JsonPath(io.restassured.path.json.JsonPath) Test(org.junit.Test)

Example 3 with JsonPath

use of io.restassured.path.json.JsonPath in project vertx-openshift-it by cescoffier.

the class ConfigurationIT method testChangingConfigurationThroughConfigStream.

@Test
public void testChangingConfigurationThroughConfigStream() {
    createOrEditConfigMap(ImmutableMap.of("key", "config-stream", "date", Long.toString(System.currentTimeMillis()), "yet", "another-value", "other", "value"));
    ensureThat("after configuration change, the new configuration received through config stream has been read", () -> await().atMost(2, TimeUnit.MINUTES).until(() -> get("/all-by-stream").getBody().jsonPath().getString("key").equals("config-stream")));
    ensureThat("the new configuration received through stream is the expected configuration", () -> {
        final JsonPath response = get("/all-by-stream").getBody().jsonPath();
        softly.assertThat(response.getDouble("date")).isNotNull().isPositive();
        softly.assertThat(response.getString("key")).isEqualTo("config-stream");
        softly.assertThat(response.getString("yet")).isEqualTo("another-value");
        softly.assertThat(response.getString("other")).isEqualTo("value");
        softly.assertThat(response.getString("HOSTNAME")).startsWith("config-service");
        softly.assertThat(response.getString("KUBERNETES_NAMESPACE")).isEqualToIgnoringCase(client.getNamespace());
        softly.assertThat(response.getInt("'http.port'")).isNotNull().isNotNegative();
        softly.assertThat(response.getString("propertiesExampleOption")).isEqualTo("A properties example option");
        softly.assertThat(response.getString("jsonExampleOption")).isEqualTo("A JSON example option");
        softly.assertThat(response.getString("toBeOverwritten")).isEqualTo("This is defined in YAML file.");
        softly.assertThat(response.getString("'map.items'.mapItem1")).isEqualTo("Overwrites value in JSON config file");
        softly.assertThat(response.getInt("'map.items'.mapItem2")).isEqualTo(0);
        softly.assertThat(response.getString("httpConfigContent")).isEqualTo(HTTP_CONFIG_EXPECTED_STRING);
        softly.assertThat(response.getString("dirConfigKey2")).isEqualTo("How to achieve perfection");
        softly.assertThat(response.getString("eventBus")).isEqualTo(EVENT_BUS_EXPECTED_STRING);
    });
    createOrEditConfigMap(DEFAULT_MAP);
    ensureThat("the old stream configuration can be read\n", () -> await().atMost(2, TimeUnit.MINUTES).until(() -> get("/all-by-stream").getBody().jsonPath().getString("key").equals("value")));
}
Also used : JsonPath(io.restassured.path.json.JsonPath) Test(org.junit.Test)

Example 4 with JsonPath

use of io.restassured.path.json.JsonPath in project vertx-openshift-it by cescoffier.

the class SockJsIT method checkSockStatuses.

@Test
public void checkSockStatuses() throws InterruptedException {
    ensureThat("we can navigate to application ", () -> {
        final Route route = client.routes().withName(deploymentAssistant.applicationName()).get();
        webDriver.navigate().to(urlForRoute(route));
    });
    ensureThat("both statuses are updated", () -> {
        await().atMost(3, TimeUnit.MINUTES).catchUncaughtExceptions().until(() -> isElementEmpty(EB_STATUS));
        await().atMost(3, TimeUnit.MINUTES).catchUncaughtExceptions().until(() -> isElementEmpty(SOCK_STATUS));
    });
    ensureThat("all transports are working and asserted", () -> {
        final JsonPath serverStatus = get("/status").body().jsonPath();
        final JsonObject clientSideEbStatus = getJsonById(EB_STATUS);
        final JsonObject clientSideSockStatus = getJsonById(SOCK_STATUS);
        for (Transport t : Transport.values()) {
            softly.assertThat(serverStatus.getBoolean(t + "-EB")).as("Transport " + t + " should be used on server side (on EventBus). ").isTrue();
            softly.assertThat(serverStatus.getBoolean(t + "-sock")).as("Transport " + t + " should be used on server side (on SockJS). ").isTrue();
            softly.assertThat(clientSideEbStatus.getInteger(t.name())).as("Transport " + t + " should be used on client side (on EventBus). ").isGreaterThan(0);
            softly.assertThat(clientSideSockStatus.getInteger(t.name())).as("Transport " + t + " should be used on client side (on SockJS). ").isGreaterThan(0);
        }
    });
}
Also used : JsonObject(io.vertx.core.json.JsonObject) JsonPath(io.restassured.path.json.JsonPath) Transport(io.vertx.ext.web.handler.sockjs.Transport) Route(io.fabric8.openshift.api.model.Route) Kube.urlForRoute(io.vertx.it.openshift.utils.Kube.urlForRoute) Test(org.junit.Test)

Example 5 with JsonPath

use of io.restassured.path.json.JsonPath in project rest-assured by rest-assured.

the class ResponseITest method jsonPathReturnedByResponseUsesConfigurationFromRestAssured.

@Test
public void jsonPathReturnedByResponseUsesConfigurationFromRestAssured() throws Exception {
    // When
    final JsonPath jsonPath = given().config(RestAssuredConfig.newConfig().with().jsonConfig(jsonConfig().numberReturnType(JsonPathConfig.NumberReturnType.BIG_DECIMAL))).expect().statusCode(200).when().get("/jsonStore").jsonPath();
    // Then
    assertThat(jsonPath.<BigDecimal>get("store.book.price.min()"), is(new BigDecimal("8.95")));
    assertThat(jsonPath.<BigDecimal>get("store.book.price.max()"), is(new BigDecimal("22.99")));
}
Also used : JsonPath(io.restassured.path.json.JsonPath) BigDecimal(java.math.BigDecimal) 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