Search in sources :

Example 1 with User

use of sample.test.domain.User in project spring-boot by spring-projects.

the class UserVehicleService method getVehicleDetails.

public VehicleDetails getVehicleDetails(String username) throws UserNameNotFoundException, VehicleIdentificationNumberNotFoundException {
    Assert.notNull(username, "Username must not be null");
    User user = this.userRepository.findByUsername(username);
    if (user == null) {
        throw new UserNameNotFoundException(username);
    }
    return this.vehicleDetailsService.getVehicleDetails(user.getVin());
}
Also used : User(sample.test.domain.User)

Example 2 with User

use of sample.test.domain.User in project spring-boot by spring-projects.

the class UserVehicleServiceTests method getVehicleDetailsShouldReturnMakeAndModel.

@Test
public void getVehicleDetailsShouldReturnMakeAndModel() throws Exception {
    given(this.userRepository.findByUsername(anyString())).willReturn(new User("sboot", VIN));
    VehicleDetails details = new VehicleDetails("Honda", "Civic");
    given(this.vehicleDetailsService.getVehicleDetails(VIN)).willReturn(details);
    VehicleDetails actual = this.service.getVehicleDetails("sboot");
    assertThat(actual).isEqualTo(details);
}
Also used : User(sample.test.domain.User) VehicleDetails(sample.test.service.VehicleDetails) Test(org.junit.Test)

Aggregations

User (sample.test.domain.User)2 Test (org.junit.Test)1 VehicleDetails (sample.test.service.VehicleDetails)1