use of io.restassured.path.json.JsonPath in project vertx-openshift-it by cescoffier.
the class ConfigurationIT method testRetrievingConfigByListeningToChange.
@Test
public void testRetrievingConfigByListeningToChange() throws InterruptedException {
// So event bus config store has some time to load
ensureThat("we can retrieve the application configuration", () -> await().atMost(2, TimeUnit.MINUTES).until(() -> get("/all").getBody().jsonPath().getString("eventBus") != null));
ensureThat("the configuration is the expected configuration\n", () -> {
final JsonPath response = get("/all").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 rest-assured by rest-assured.
the class GreetingControllerVanillaMockMvcTest method mock_mvc_example_for_post_greeting_controller.
@Test
public void mock_mvc_example_for_post_greeting_controller() throws Exception {
MockMvc mockMvc = standaloneSetup(new PostController()).setMessageConverters(new MappingJackson2HttpMessageConverter()).build();
String contentAsString = mockMvc.perform(post("/greetingPost").param("name", "Johan").contentType(MediaType.APPLICATION_FORM_URLENCODED)).andReturn().getResponse().getContentAsString();
JsonPath jsonPath = new JsonPath(contentAsString);
assertThat(jsonPath.getInt("id"), equalTo(1));
assertThat(jsonPath.getString("content"), equalTo("Hello, Johan!"));
}
use of io.restassured.path.json.JsonPath in project rest-assured by rest-assured.
the class GreetingControllerVanillaMockMvcTest method mock_mvc_example_for_get_greeting_controller.
@Test
public void mock_mvc_example_for_get_greeting_controller() throws Exception {
MockMvc mockMvc = standaloneSetup(new GreetingController()).setMessageConverters(new MappingJackson2HttpMessageConverter()).build();
String contentAsString = mockMvc.perform(get("/greeting?name={name}", "Johan").accept(APPLICATION_JSON)).andReturn().getResponse().getContentAsString();
JsonPath jsonPath = new JsonPath(contentAsString);
assertThat(jsonPath.getInt("id"), equalTo(1));
assertThat(jsonPath.getString("content"), equalTo("Hello, Johan!"));
}
use of io.restassured.path.json.JsonPath in project rest-assured by rest-assured.
the class MultiPartFileUploadITest method object_serialization_works.
@Test
public void object_serialization_works() throws IOException {
File file = folder.newFile("something");
IOUtils.write("Something3210", new FileOutputStream(file));
Greeting greeting = new Greeting();
greeting.setFirstName("John");
greeting.setLastName("Doe");
String content = RestAssuredMockMvc.given().multiPart("controlName1", file, "mime-type1").multiPart("controlName2", greeting, "application/json").when().post("/multiFileUpload").then().root("[%d]").body("size", withArgs(0), is(13)).body("name", withArgs(0), equalTo("controlName1")).body("originalName", withArgs(0), equalTo("something")).body("mimeType", withArgs(0), equalTo("mime-type1")).body("content", withArgs(0), equalTo("Something3210")).body("size", withArgs(1), greaterThan(10)).body("name", withArgs(1), equalTo("controlName2")).body("originalName", withArgs(1), equalTo("file")).body("mimeType", withArgs(1), equalTo("application/json")).body("content", withArgs(1), notNullValue()).extract().path("[1].content");
JsonPath jsonPath = new JsonPath(content);
assertThat(jsonPath.getString("firstName"), equalTo("John"));
assertThat(jsonPath.getString("lastName"), equalTo("Doe"));
}
use of io.restassured.path.json.JsonPath in project rest-assured by rest-assured.
the class SimplePathITest method simpleJsonValidationWithJsonPath.
@Test
public void simpleJsonValidationWithJsonPath() throws Exception {
final String body = get("/greetJSON?firstName=John&lastName=Doe").asString();
final JsonPath json = new JsonPath(body).setRoot("greeting");
final String firstName = json.getString("firstName");
final String lastName = json.getString("lastName");
assertThat(firstName, equalTo("John"));
assertThat(lastName, equalTo("Doe"));
}
Aggregations