Search in sources :

Example 6 with VehicleDetails

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>")));
}
Also used : VehicleDetails(demo.service.VehicleDetails) Test(org.junit.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Example 7 with VehicleDetails

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);
}
Also used : User(demo.domain.User) VehicleDetails(demo.service.VehicleDetails) Test(org.junit.Test)

Example 8 with VehicleDetails

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>";
}
Also used : VehicleDetails(demo.service.VehicleDetails) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

VehicleDetails (demo.service.VehicleDetails)8 Test (org.junit.Test)7 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)5 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)1 User (demo.domain.User)1 WebElement (org.openqa.selenium.WebElement)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1