@@ -0,0 +1,2685 @@
+package bg.car_wash.areas.user.serviceImpl;%0A%0Aimport bg.car_wash.areas.user.entity.User;%0Aimport bg.car_wash.areas.user.exception.UserNotFoundException;%0Aimport bg.car_wash.areas.user.models.viewModels.UserViewModel;%0Aimport bg.car_wash.areas.user.repository.UserRepository;%0Aimport bg.car_wash.areas.user.service.UserService;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.Mockito;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.boot.test.context.SpringBootTest;%0Aimport org.springframework.boot.test.mock.mockito.MockBean;%0Aimport org.springframework.test.context.ActiveProfiles;%0Aimport org.springframework.test.context.junit4.SpringRunner;%0A%0Aimport static org.junit.Assert.*;%0A%0A@RunWith(SpringRunner.class)%0A@SpringBootTest%0A@ActiveProfiles(%22test%22)%0Apublic class UserServiceTest %7B%0A%0A%09private static final Long VALID_ID = 1L;%0A%09private static final Long INVALID_ID = -1L;%0A%09private static final String VALID_EMAIL = %22ivan@abv.bg%22;%0A%0A%09@MockBean%0A%09private UserRepository userRepository;%0A%0A%09@Autowired%0A%09private UserService userService;%0A%0A%09@Before%0A%09public void setUp() throws Exception %7B%0A%09%09User user = new User();%0A%09%09user.setId(VALID_ID);%0A%09%09user.setEmail(VALID_EMAIL);%0A%09%09user.setEnabled(true);%0A%09%09user.setCredentialsNonExpired(true);%0A%0A%09%09Mockito.when(userRepository.findUserById(VALID_ID)).thenReturn(user);%0A%09%7D%0A%0A%09@Test%0A%09public void findUserByIdGivenValidId_ShouldReturnValidUserId() throws Exception %7B%0A%09%09//Act%0A%09%09User user = this.userService.findUserById(VALID_ID);%0A%0A%09%09//Assert%0A%09%09assertEquals(VALID_ID, user.getId());%0A%09%7D%0A%0A%09@Test%0A%09public void findUserByIdGivenValidId_ShouldReturnValidUserEmail() throws Exception %7B%0A%09%09//Act%0A%09%09User user = this.userService.findUserById(VALID_ID);%0A%0A%09%09//Assert%0A%09%09assertEquals(VALID_EMAIL, user.getEmail());%0A%09%7D%0A%0A%09@Test%0A%09public void findUserByIdGivenValidId_ShouldReturnIsEnabled() throws Exception %7B%0A%09%09//Act%0A%09%09User user = this.userService.findUserById(VALID_ID);%0A%0A%09%09//Assert%0A%09%09assertTrue(user.isEnabled());%0A%09%7D%0A%0A%09@Test%0A%09public void findUserByIdGivenValidId_ShouldReturnIsCredentialsNonExpired() throws Exception %7B%0A%09%09//Act%0A%09%09User user = this.userService.findUserById(VALID_ID);%0A%0A%09%09//Assert%0A%09%09assertTrue(user.isCredentialsNonExpired());%0A%09%7D%0A%0A%09@Test%0A%09public void findUserByIdGivenValidId_ShouldOneCallFindUserById() throws Exception %7B%0A%09%09//Act%0A%09%09User user = this.userService.findUserById(VALID_ID);%0A%0A%09%09//Assert%0A%09%09Mockito.verify(this.userRepository, Mockito.times(1)).findUserById(VALID_ID);%0A%09%7D%0A%0A%09@Test(expected = UserNotFoundException.class)%0A%09public void findUserByIdGivenValidId_ShouldThrowException() throws Exception %7B%0A%09%09//Act%0A%09%09User user = this.userService.findUserById(INVALID_ID);%0A%09%7D%0A%0A%7D

create UserServiceTest