|
@ -15,11 +15,11 @@ import org.ros.chatto.dto.UserRegistrationDTO; |
|
|
import org.ros.chatto.model.ChatUser; |
|
|
import org.ros.chatto.model.ChatUser; |
|
|
import org.ros.chatto.model.Role; |
|
|
import org.ros.chatto.model.Role; |
|
|
import org.ros.chatto.model.UserRole; |
|
|
import org.ros.chatto.model.UserRole; |
|
|
|
|
|
import org.ros.chatto.repository.RoleRepository; |
|
|
import org.ros.chatto.repository.UserRepository; |
|
|
import org.ros.chatto.repository.UserRepository; |
|
|
import org.ros.chatto.repository.UserRepositoryCustom; |
|
|
import org.ros.chatto.repository.UserRepositoryCustom; |
|
|
import org.ros.chatto.repository.UserRoleRepository; |
|
|
import org.ros.chatto.repository.UserRoleRepository; |
|
|
import org.ros.chatto.repository.UserSessionRepository; |
|
|
import org.ros.chatto.repository.UserSessionRepository; |
|
|
import org.ros.chatto.service.RoleService; |
|
|
|
|
|
import org.ros.chatto.service.UserService; |
|
|
import org.ros.chatto.service.UserService; |
|
|
import org.ros.chatto.service.UserServiceImpl; |
|
|
import org.ros.chatto.service.UserServiceImpl; |
|
|
import org.springframework.boot.test.context.SpringBootTest; |
|
|
import org.springframework.boot.test.context.SpringBootTest; |
|
@ -33,9 +33,9 @@ import lombok.extern.slf4j.Slf4j; |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
public class UnitTest { |
|
|
public class UnitTest { |
|
|
@InjectMocks |
|
|
@InjectMocks |
|
|
private UserService userService = new UserServiceImpl(); |
|
|
|
|
|
// private RoleService roleService; |
|
|
|
|
|
// private UserTokenService userTokenService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private RoleService roleService; |
|
|
|
|
|
// private UserTokenService userTokenService; |
|
|
|
|
|
|
|
|
@Mock |
|
|
@Mock |
|
|
private UserRoleRepository userRoleRepository; |
|
|
private UserRoleRepository userRoleRepository; |
|
@ -44,7 +44,7 @@ public class UnitTest { |
|
|
private PasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
|
|
private PasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
|
|
|
|
|
|
|
|
@Mock |
|
|
@Mock |
|
|
private RoleService roleService; |
|
|
|
|
|
|
|
|
private RoleRepository roleRepository; |
|
|
|
|
|
|
|
|
@Mock |
|
|
@Mock |
|
|
private UserRepositoryCustom userRepositoryCustom; |
|
|
private UserRepositoryCustom userRepositoryCustom; |
|
@ -54,6 +54,9 @@ public class UnitTest { |
|
|
|
|
|
|
|
|
@Mock |
|
|
@Mock |
|
|
private UserRepository userRepository; |
|
|
private UserRepository userRepository; |
|
|
|
|
|
|
|
|
|
|
|
private UserService userService = new UserServiceImpl(userRepository, userRoleRepository, passwordEncoder, roleRepository, |
|
|
|
|
|
userSessionRepository); |
|
|
// private ChatUser chatUser; |
|
|
// private ChatUser chatUser; |
|
|
|
|
|
|
|
|
@Before |
|
|
@Before |
|
@ -75,7 +78,7 @@ public class UnitTest { |
|
|
Role role = new Role(); |
|
|
Role role = new Role(); |
|
|
role.setRoleID(2); |
|
|
role.setRoleID(2); |
|
|
role.setName("USER"); |
|
|
role.setName("USER"); |
|
|
when(roleService.getRole("USER")).thenReturn(role); |
|
|
|
|
|
|
|
|
when(roleRepository.findByName("USER")).thenReturn(role); |
|
|
when(userRepository.save(chatUser)).thenReturn(chatUser); |
|
|
when(userRepository.save(chatUser)).thenReturn(chatUser); |
|
|
|
|
|
|
|
|
UserRole userRole = userService.registerUser(userRegistrationDTO); |
|
|
UserRole userRole = userService.registerUser(userRegistrationDTO); |
|
|