use of io.restassured.module.mockmvc.specification.MockMvcRequestSpecification in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method request_body_is_overwritten_when_defined_in_specification.
@Test
public void request_body_is_overwritten_when_defined_in_specification() {
// Given
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().setBody("body2").build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().body("body1").spec(specToMerge);
// Then
Assertions.assertThat(implOf(spec).getRequestBody()).isEqualTo("body2");
}
use of io.restassured.module.mockmvc.specification.MockMvcRequestSpecification in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method configs_of_same_type_are_overwritten_when_defined_in_specification.
@Test
public void configs_of_same_type_are_overwritten_when_defined_in_specification() {
// Given
RestAssuredMockMvcConfig otherConfig = new RestAssuredMockMvcConfig().with().jsonConfig(jsonConfig().with().numberReturnType(JsonPathConfig.NumberReturnType.BIG_DECIMAL));
RestAssuredMockMvcConfig thisConfig = new RestAssuredMockMvcConfig().with().jsonConfig(jsonConfig().with().numberReturnType(JsonPathConfig.NumberReturnType.FLOAT_AND_DOUBLE));
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().setConfig(otherConfig).build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().config(thisConfig).spec(specToMerge);
// Then
assertThat(implOf(spec).getRestAssuredMockMvcConfig().getJsonConfig().numberReturnType()).isEqualTo(JsonPathConfig.NumberReturnType.BIG_DECIMAL);
}
use of io.restassured.module.mockmvc.specification.MockMvcRequestSpecification in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method params_are_merged.
@Test
public void params_are_merged() {
// Given
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().addParam("param1", "value1").build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().param("param2", "value2").spec(specToMerge);
// Then
Assertions.assertThat(implOf(spec).getParams()).containsOnly(entry("param1", "value1"), entry("param2", "value2"));
}
use of io.restassured.module.mockmvc.specification.MockMvcRequestSpecification in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method mock_mvc_instance_is_overwritten_when_defined_in_specification.
@Test
public void mock_mvc_instance_is_overwritten_when_defined_in_specification() {
// Given
MockMvc otherMockMvcInstance = MockMvcBuilders.standaloneSetup(new PostController()).build();
MockMvc thisMockMvcInstance = MockMvcBuilders.standaloneSetup(new GreetingController()).build();
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().setMockMvc(otherMockMvcInstance).build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().mockMvc(thisMockMvcInstance).spec(specToMerge);
// Then
assertThat(Whitebox.getInternalState(implOf(spec).getMockMvcFactory(), "mockMvc")).isSameAs(otherMockMvcInstance);
}
use of io.restassured.module.mockmvc.specification.MockMvcRequestSpecification in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method config_is_not_overwritten_when_not_defined_in_specification.
@Test
public void config_is_not_overwritten_when_not_defined_in_specification() {
// Given
RestAssuredMockMvcConfig thisConfig = new RestAssuredMockMvcConfig().with().jsonConfig(jsonConfig().with().numberReturnType(JsonPathConfig.NumberReturnType.FLOAT_AND_DOUBLE));
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().addQueryParam("param1", "value1").build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().config(thisConfig).spec(specToMerge);
// Then
// This assertion is commented out since for some reason it fails during the release process
// assertThat(implOf(spec).getRestAssuredMockMvcConfig()).isSameAs(thisConfig);
Assertions.assertThat(implOf(spec).getQueryParams()).containsOnly(entry("param1", "value1"));
assertThat(implOf(spec).getRestAssuredMockMvcConfig().getJsonConfig().numberReturnType()).isEqualTo(JsonPathConfig.NumberReturnType.FLOAT_AND_DOUBLE);
}
Aggregations