use of io.restassured.module.mockmvc.specification.MockMvcRequestSpecification in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method interception_is_overwritten_when_defined_in_specification.
@Test
public void interception_is_overwritten_when_defined_in_specification() {
// Given
MockHttpServletRequestBuilderInterceptor otherInterceptor = new MockHttpServletRequestBuilderInterceptor() {
public void intercept(MockHttpServletRequestBuilder requestBuilder) {
}
};
MockHttpServletRequestBuilderInterceptor thisInterceptor = new MockHttpServletRequestBuilderInterceptor() {
public void intercept(MockHttpServletRequestBuilder requestBuilder) {
}
};
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().setMockHttpServletRequestBuilderInterceptor(otherInterceptor).build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().interceptor(thisInterceptor).spec(specToMerge);
// Then
Assertions.assertThat(implOf(spec).getInterceptor()).isEqualTo(otherInterceptor);
}
use of io.restassured.module.mockmvc.specification.MockMvcRequestSpecification in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method interception_is_not_overwritten_when_not_defined_in_specification.
@Test
public void interception_is_not_overwritten_when_not_defined_in_specification() {
// Given
MockHttpServletRequestBuilderInterceptor thisInterceptor = new MockHttpServletRequestBuilderInterceptor() {
public void intercept(MockHttpServletRequestBuilder requestBuilder) {
}
};
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().addQueryParam("param1", "value1").build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().interceptor(thisInterceptor).spec(specToMerge);
// Then
Assertions.assertThat(implOf(spec).getInterceptor()).isEqualTo(thisInterceptor);
Assertions.assertThat(implOf(spec).getQueryParams()).containsOnly(entry("param1", "value1"));
}
use of io.restassured.module.mockmvc.specification.MockMvcRequestSpecification in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method base_path_is_overwritten_when_defined_in_specification.
@Test
public void base_path_is_overwritten_when_defined_in_specification() {
// Given
RestAssuredMockMvc.basePath = "/something";
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().setBasePath("basePath").build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().body("body1").spec(specToMerge);
// Then
RestAssuredMockMvc.reset();
Assertions.assertThat(implOf(spec).getBasePath()).isEqualTo("basePath");
}
use of io.restassured.module.mockmvc.specification.MockMvcRequestSpecification in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method cookies_are_not_overwritten_when_not_defined_in_specification.
@Test
public void cookies_are_not_overwritten_when_not_defined_in_specification() {
// Given
Cookie thisCookie = new Cookie.Builder("cookie2", "value2").build();
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().addQueryParam("param1", "value1").build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().cookie(thisCookie).spec(specToMerge);
// Then
Assertions.assertThat(implOf(spec).getCookies()).containsOnly(thisCookie);
Assertions.assertThat(implOf(spec).getQueryParams()).containsOnly(entry("param1", "value1"));
}
use of io.restassured.module.mockmvc.specification.MockMvcRequestSpecification in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method mock_mvc_factory_is_not_overwritten_when_not_defined_in_specification.
@Test
public void mock_mvc_factory_is_not_overwritten_when_not_defined_in_specification() {
// Given
MockMvc mockMvcInstance = MockMvcBuilders.standaloneSetup(new GreetingController()).build();
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().addQueryParam("param1", "value1").build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().mockMvc(mockMvcInstance).spec(specToMerge);
// Then
assertThat(Whitebox.getInternalState(implOf(spec).getMockMvcFactory(), "mockMvc")).isSameAs(mockMvcInstance);
Assertions.assertThat(implOf(spec).getQueryParams()).containsOnly(entry("param1", "value1"));
}
Aggregations