use of sample.test.service.VehicleDetails in project spring-boot by spring-projects.
the class UserVehicleControllerHtmlUnitTests method getVehicleWhenRequestingTextShouldReturnMakeAndModel.
@Test
public void getVehicleWhenRequestingTextShouldReturnMakeAndModel() throws Exception {
given(this.userVehicleService.getVehicleDetails("sboot")).willReturn(new VehicleDetails("Honda", "Civic"));
HtmlPage page = this.webClient.getPage("/sboot/vehicle.html");
assertThat(page.getBody().getTextContent()).isEqualTo("Honda Civic");
}
use of sample.test.service.VehicleDetails in project spring-boot by spring-projects.
the class UserVehicleControllerTests method getVehicleWhenRequestingJsonShouldReturnMakeAndModel.
@Test
public void getVehicleWhenRequestingJsonShouldReturnMakeAndModel() throws Exception {
given(this.userVehicleService.getVehicleDetails("sboot")).willReturn(new VehicleDetails("Honda", "Civic"));
this.mvc.perform(get("/sboot/vehicle").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andExpect(content().json("{'make':'Honda','model':'Civic'}"));
}
use of sample.test.service.VehicleDetails in project spring-boot by spring-projects.
the class UserVehicleController method VehicleDetailsHtml.
@GetMapping(path = "/{username}/vehicle.html", produces = MediaType.TEXT_HTML_VALUE)
public String VehicleDetailsHtml(@PathVariable String username) {
VehicleDetails details = this.userVehicleService.getVehicleDetails(username);
String makeAndModel = details.getMake() + " " + details.getModel();
return "<html><body><h1>" + makeAndModel + "</h1></body></html>";
}
Aggregations