use of org.springframework.test.web.Person in project spring-framework by spring-projects.
the class SampleTests method performGetWithResponseBodyFromFile.
@Test
public void performGetWithResponseBodyFromFile() {
Resource responseBody = new ClassPathResource("ludwig.json", this.getClass());
this.mockServer.expect(requestTo("/composers/42")).andExpect(method(HttpMethod.GET)).andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON));
@SuppressWarnings("unused") Person ludwig = this.restTemplate.getForObject("/composers/{id}", Person.class, 42);
// hotel.getId() == 42
// hotel.getName().equals("Holiday Inn")
this.mockServer.verify();
}
use of org.springframework.test.web.Person in project spring-framework by spring-projects.
the class XmlContentRequestMatchersIntegrationTests method setup.
@BeforeEach
public void setup() {
List<Person> composers = Arrays.asList(new Person("Johann Sebastian Bach").setSomeDouble(21), new Person("Johannes Brahms").setSomeDouble(.0025), new Person("Edvard Grieg").setSomeDouble(1.6035), new Person("Robert Schumann").setSomeDouble(Double.NaN));
this.people = new PeopleWrapper(composers);
List<HttpMessageConverter<?>> converters = new ArrayList<>();
converters.add(new Jaxb2RootElementHttpMessageConverter());
this.restTemplate = new RestTemplate();
this.restTemplate.setMessageConverters(converters);
this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
}
use of org.springframework.test.web.Person in project spring-framework by spring-projects.
the class AsyncTests method deferredResultWithImmediateValue.
@Test
public void deferredResultWithImmediateValue() throws Exception {
MvcResult mvcResult = this.mockMvc.perform(get("/1").param("deferredResultWithImmediateValue", "true")).andExpect(request().asyncStarted()).andExpect(request().asyncResult(new Person("Joe"))).andReturn();
this.mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
}
use of org.springframework.test.web.Person in project spring-framework by spring-projects.
the class JavaConfigTests method setup.
@BeforeEach
void setup() {
this.testClient = MockMvcWebTestClient.bindToApplicationContext(this.wac).build();
given(this.personDao.getPerson(5L)).willReturn(new Person("Joe"));
}
use of org.springframework.test.web.Person in project spring-framework by spring-projects.
the class XmlConfigTests method setup.
@BeforeEach
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
given(this.personDao.getPerson(5L)).willReturn(new Person("Joe"));
}
Aggregations