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);
});
}
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")));
}
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")));
}
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);
}
});
}
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")));
}
Aggregations