use of io.restassured.module.mockmvc.specification.MockMvcRequestSpecBuilder in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method form_params_are_merged.
@Test
public void form_params_are_merged() {
// Given
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().addFormParam("param1", "value1").build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().formParam("param2", "value2").spec(specToMerge);
// Then
Assertions.assertThat(implOf(spec).getFormParams()).containsOnly(entry("param1", "value1"), entry("param2", "value2"));
}
use of io.restassured.module.mockmvc.specification.MockMvcRequestSpecBuilder in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method configurations_are_merged.
@Test
public void configurations_are_merged() {
// Given
RestAssuredMockMvcConfig cfg1 = new RestAssuredMockMvcConfig().with().jsonConfig(jsonConfig().with().numberReturnType(JsonPathConfig.NumberReturnType.FLOAT_AND_DOUBLE));
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().setConfig(cfg1).build();
// When
RestAssuredMockMvcConfig cfg2 = new RestAssuredMockMvcConfig().sessionConfig(sessionConfig().sessionIdName("php"));
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().config(cfg2).spec(specToMerge);
// Then
RestAssuredConfig mergedConfig = implOf(spec).getRestAssuredConfig();
assertThat(mergedConfig.getSessionConfig().sessionIdName()).isEqualTo("php");
assertThat(mergedConfig.getJsonConfig().numberReturnType()).isEqualTo(JsonPathConfig.NumberReturnType.FLOAT_AND_DOUBLE);
}
use of io.restassured.module.mockmvc.specification.MockMvcRequestSpecBuilder in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method attributes_are_merged.
@Test
public void attributes_are_merged() {
// Given
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().addAttribute("param1", "value1").build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().attribute("param2", "value2").spec(specToMerge);
// Then
Assertions.assertThat(implOf(spec).getAttributes()).containsOnly(entry("param1", "value1"), entry("param2", "value2"));
}
use of io.restassured.module.mockmvc.specification.MockMvcRequestSpecBuilder in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method query_params_are_merged.
// @formatter:off
@Test
public void query_params_are_merged() {
// Given
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().addQueryParam("param1", "value1").build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().queryParam("param2", "value2").spec(specToMerge);
// Then
Assertions.assertThat(implOf(spec).getQueryParams()).containsOnly(entry("param1", "value1"), entry("param2", "value2"));
}
use of io.restassured.module.mockmvc.specification.MockMvcRequestSpecBuilder in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method request_body_is_not_overwritten_when_not_defined_in_specification.
@Test
public void request_body_is_not_overwritten_when_not_defined_in_specification() {
// Given
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().addQueryParam("param1", "value1").build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().body("body1").spec(specToMerge);
// Then
Assertions.assertThat(implOf(spec).getRequestBody()).isEqualTo("body1");
Assertions.assertThat(implOf(spec).getQueryParams()).containsOnly(entry("param1", "value1"));
}
Aggregations