use of demo.service.VehicleDetails in project microservices by pwillhan.
the class UserVehicleControllerTest method getVehicleWhenRequestingHtmlShouldReturnMakeAndModel.
@Test
public void getVehicleWhenRequestingHtmlShouldReturnMakeAndModel() throws Exception {
given(this.userVehicleService.getVehicleDetails("donald")).willReturn(new VehicleDetails("Honda", "Civic"));
this.mvc.perform(get("/donald/vehicle.html").accept(MediaType.TEXT_HTML)).andExpect(status().isOk()).andExpect(content().string(containsString("<h1>Honda Civic</h1>")));
}
use of demo.service.VehicleDetails in project microservices by pwillhan.
the class UserVehicleServiceTest method getVehicleDetailsShouldReturnMakeAndModel.
@Test
public void getVehicleDetailsShouldReturnMakeAndModel() throws Exception {
given(this.userRepository.findByUsername("donald")).willReturn(new User("donald", VIN));
VehicleDetails details = new VehicleDetails("Honda", "Civic");
given(this.vehicleDetailsService.getVehicleDetails(VIN)).willReturn(details);
VehicleDetails actual = this.service.getVehicleDetails("donald");
assertThat(actual).isEqualTo(details);
}
use of demo.service.VehicleDetails in project microservices by pwillhan.
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