Testy jednostkowe transformerow oraz task'a inwalidujacego sesje
This commit is contained in:
1 parent
7205f61a43
commit
2bcebb27e1
11 files changed
+516
-13
No files matched your search
@@ -31,12 +31,10 @@
|
||||
<dependency>
|
||||
<groupId>edu.agh.ztb</groupId>
|
||||
<artifactId>AuthorizationModule-model</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>edu.agh.ztb</groupId>
|
||||
<artifactId>AuthorizationModule-dto</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
||||
+8
-6
@@ -13,14 +13,16 @@ import java.util.List;
|
||||
public class ExpiredSessionInvalidationTask {
|
||||
|
||||
@Autowired
|
||||
private SessionDao sessionDao;
|
||||
protected SessionDao sessionDao;
|
||||
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void invalidateSessions() {
|
||||
List<Session> sessions = sessionDao.findExpiredSessions ();
|
||||
for (Session session : sessions) {
|
||||
session.setValid(false);
|
||||
sessionDao.update(session);
|
||||
List<Session> sessions = sessionDao.findExpiredSessions();
|
||||
if (sessions != null) {
|
||||
for (Session session : sessions) {
|
||||
session.setValid(false);
|
||||
sessionDao.update(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -6,12 +6,12 @@ import java.util.List;
|
||||
|
||||
public abstract class AbstractTransformer<F, T> implements Transformer<F, T> {
|
||||
|
||||
public List<T> transformCollection(Collection<F> list) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
public List<T> transformCollection(Collection<F> collection) {
|
||||
if (collection == null) {
|
||||
throw new NullPointerException("Input must not be null.");
|
||||
}
|
||||
List<T> result = new ArrayList<T>();
|
||||
for (F from : list) {
|
||||
for (F from : collection) {
|
||||
result.add(transform(from));
|
||||
}
|
||||
return result;
|
||||
|
||||
+3
@@ -7,6 +7,9 @@ public class Permission2PermissionDtoTransformer extends AbstractTransformer<Per
|
||||
|
||||
@Override
|
||||
public PermissionDto transform(Permission from) {
|
||||
if (from == null) {
|
||||
throw new NullPointerException("Input must not be null.");
|
||||
}
|
||||
return PermissionDto.builder().name(from.getName()).build();
|
||||
}
|
||||
}
|
||||
+3
@@ -15,6 +15,9 @@ public class Role2RoleDtoTransformer extends AbstractTransformer<Role, RoleDto>
|
||||
|
||||
@Override
|
||||
public RoleDto transform(Role from) {
|
||||
if (from == null) {
|
||||
throw new NullPointerException("Input must not be null.");
|
||||
}
|
||||
List<Permission> rolePermissions = new ArrayList<Permission>();
|
||||
if (from.getRolePermissions() != null) {
|
||||
for (RolePermission rolePermission : from.getRolePermissions()) {
|
||||
|
||||
+3
-1
@@ -15,6 +15,9 @@ public class User2UserDtoTransformer extends AbstractTransformer<User, UserDto>
|
||||
|
||||
@Override
|
||||
public UserDto transform(User from) {
|
||||
if (from == null) {
|
||||
throw new NullPointerException("Input must not be null.");
|
||||
}
|
||||
List<Role> userRoles = new ArrayList<Role>();
|
||||
if (from.getUserRoles() != null) {
|
||||
for (UserRole userRole : from.getUserRoles()) {
|
||||
@@ -24,5 +27,4 @@ public class User2UserDtoTransformer extends AbstractTransformer<User, UserDto>
|
||||
return UserDto.builder().email(from.getEmail()).login(from.getLogin()).name(from.getName()).surname(from.getSurname())
|
||||
.userRoles(role2RoleDtoTransformer.transformCollection(userRoles)).build();
|
||||
}
|
||||
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
package edu.agh.ztb.authorization.scheduling;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import edu.agh.ztb.authorization.dao.SessionDao;
|
||||
import edu.agh.ztb.authorization.model.Session;
|
||||
|
||||
public class ExpiredSessionInvalidationTaskTest {
|
||||
|
||||
private final static String TOKEN = "1234-abcd-12-ab";
|
||||
|
||||
private ExpiredSessionInvalidationTask task;
|
||||
private SessionDao sessionDao;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
sessionDao = mock(SessionDao.class);
|
||||
task = new ExpiredSessionInvalidationTask();
|
||||
task.sessionDao = sessionDao;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidateSessions_shouldInvalidateAllSessions() {
|
||||
// given
|
||||
Session session1 = new Session();
|
||||
session1.setToken(TOKEN);
|
||||
session1.setValid(true);
|
||||
|
||||
Session session2 = new Session();
|
||||
session2.setToken(TOKEN);
|
||||
session2.setValid(true);
|
||||
when(sessionDao.findExpiredSessions()).thenReturn(Arrays.asList(session1, session2));
|
||||
|
||||
// when
|
||||
task.invalidateSessions();
|
||||
|
||||
// then
|
||||
assertThat(session1.getValid(), is(equalTo(false)));
|
||||
assertThat(session1.getToken(), is(equalTo(TOKEN)));
|
||||
assertThat(session2.getValid(), is(equalTo(false)));
|
||||
assertThat(session2.getToken(), is(equalTo(TOKEN)));
|
||||
verify(sessionDao, times(1)).findExpiredSessions();
|
||||
verify(sessionDao, times(2)).update((Session) anyObject());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidateSessions_shouldDoNothing() {
|
||||
// given
|
||||
when(sessionDao.findExpiredSessions()).thenReturn(Collections.<Session> emptyList());
|
||||
|
||||
// when
|
||||
task.invalidateSessions();
|
||||
|
||||
// then
|
||||
verify(sessionDao, times(1)).findExpiredSessions();
|
||||
verify(sessionDao, never()).update((Session) anyObject());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidateSessions_shouldDoNothingWhenNullListReturnedFromDao() {
|
||||
// given
|
||||
when(sessionDao.findExpiredSessions()).thenReturn(null);
|
||||
|
||||
// when
|
||||
task.invalidateSessions();
|
||||
|
||||
// then
|
||||
verify(sessionDao, times(1)).findExpiredSessions();
|
||||
verify(sessionDao, never()).update((Session) anyObject());
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
package edu.agh.ztb.authorization.transformer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import edu.agh.ztb.authorization.dto.PermissionDto;
|
||||
import edu.agh.ztb.authorization.model.Permission;
|
||||
|
||||
public class Permission2PermissionDtoTransformerTest {
|
||||
private final static String PERM1_NAME = "perm1_name";
|
||||
private final static String PERM1_DESC = "perm1_desc";
|
||||
private final static String PERM2_NAME = "perm2_name";
|
||||
private final static String PERM2_DESC = "perm2_desc";
|
||||
|
||||
@Rule
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
private Permission2PermissionDtoTransformer transformer;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
transformer = new Permission2PermissionDtoTransformer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transform_shouldThrowNPE() {
|
||||
exception.expect(NullPointerException.class);
|
||||
exception.expectMessage("Input must not be null.");
|
||||
|
||||
transformer.transform(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transformCollection_shouldThrowNPE() {
|
||||
exception.expect(NullPointerException.class);
|
||||
exception.expectMessage("Input must not be null.");
|
||||
|
||||
transformer.transformCollection(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transform_shouldReturnCorrectPermissionDto() {
|
||||
// given
|
||||
Permission permission = new Permission();
|
||||
permission.setName(PERM1_NAME);
|
||||
permission.setDescription(PERM1_DESC);
|
||||
|
||||
// when
|
||||
PermissionDto permissionDto = transformer.transform(permission);
|
||||
|
||||
// then
|
||||
assertThat(permissionDto, is(not(nullValue())));
|
||||
assertThat(permissionDto.getName(), equalTo(PERM1_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transform_shouldReturnPermissionDtoCollection() {
|
||||
// given
|
||||
Permission permission1 = new Permission();
|
||||
permission1.setName(PERM1_NAME);
|
||||
permission1.setDescription(PERM1_DESC);
|
||||
|
||||
Permission permission2 = new Permission();
|
||||
permission2.setName(PERM2_NAME);
|
||||
permission2.setDescription(PERM2_DESC);
|
||||
|
||||
// when
|
||||
List<PermissionDto> permissionDtos = transformer.transformCollection(Arrays.asList(permission1, permission2));
|
||||
|
||||
// then
|
||||
assertThat(permissionDtos, is(not(nullValue())));
|
||||
assertThat(permissionDtos, hasSize(2));
|
||||
assertThat(permissionDtos, containsInAnyOrder(PermissionDto.builder().name(PERM1_NAME).build(), PermissionDto.builder().name(PERM2_NAME).build()));
|
||||
}
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
package edu.agh.ztb.authorization.transformer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.emptyCollectionOf;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import edu.agh.ztb.authorization.dto.PermissionDto;
|
||||
import edu.agh.ztb.authorization.dto.RoleDto;
|
||||
import edu.agh.ztb.authorization.model.Permission;
|
||||
import edu.agh.ztb.authorization.model.Role;
|
||||
import edu.agh.ztb.authorization.model.RolePermission;
|
||||
|
||||
public class Role2RoleDtoTransformerTest {
|
||||
|
||||
private final static String ROLE_NAME = "role_name";
|
||||
private final static String ROLE_DESC = "role_desc";
|
||||
private final static String PERM1_NAME = "perm1_name";
|
||||
private final static String PERM1_DESC = "perm1_desc";
|
||||
private final static String PERM2_NAME = "perm2_name";
|
||||
private final static String PERM2_DESC = "perm2_desc";
|
||||
|
||||
@Rule
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
private Role2RoleDtoTransformer transformer;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
transformer = new Role2RoleDtoTransformer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transform_shouldThrowNPE() {
|
||||
exception.expect(NullPointerException.class);
|
||||
exception.expectMessage("Input must not be null.");
|
||||
|
||||
transformer.transform(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transformCollection_shouldThrowNPE() {
|
||||
exception.expect(NullPointerException.class);
|
||||
exception.expectMessage("Input must not be null.");
|
||||
|
||||
transformer.transformCollection(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transform_shouldReturnCorrectRoleDtoWithoutInnerCollection() {
|
||||
// given
|
||||
Role role = new Role();
|
||||
role.setName(ROLE_NAME);
|
||||
role.setDescription(ROLE_DESC);
|
||||
|
||||
// when
|
||||
RoleDto roleDto = transformer.transform(role);
|
||||
|
||||
// then
|
||||
assertThat(roleDto, is(not(nullValue())));
|
||||
assertThat(roleDto.getName(), is(equalTo(ROLE_NAME)));
|
||||
assertThat(roleDto.getPermissions(), is(not(nullValue())));
|
||||
assertThat(roleDto.getPermissions(), is(emptyCollectionOf(PermissionDto.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transform_shouldReturnCorrectRoleDtoWitInnerCollection() {
|
||||
// given
|
||||
Role role = new Role();
|
||||
role.setName(ROLE_NAME);
|
||||
role.setDescription(ROLE_DESC);
|
||||
|
||||
Permission permission1 = new Permission();
|
||||
permission1.setName(PERM1_NAME);
|
||||
permission1.setDescription(PERM1_DESC);
|
||||
RolePermission rolePermission1 = new RolePermission();
|
||||
rolePermission1.setRole(role);
|
||||
rolePermission1.setPermission(permission1);
|
||||
|
||||
Permission permission2 = new Permission();
|
||||
permission2.setName(PERM2_NAME);
|
||||
permission2.setDescription(PERM2_DESC);
|
||||
RolePermission rolePermission2 = new RolePermission();
|
||||
rolePermission2.setRole(role);
|
||||
rolePermission2.setPermission(permission2);
|
||||
|
||||
role.setRolePermissions(new HashSet<>(Arrays.asList(rolePermission1, rolePermission2)));
|
||||
|
||||
// when
|
||||
RoleDto roleDto = transformer.transform(role);
|
||||
|
||||
// then
|
||||
assertThat(roleDto, is(not(nullValue())));
|
||||
assertThat(roleDto.getName(), is(equalTo(ROLE_NAME)));
|
||||
assertThat(roleDto.getPermissions(), is(not(nullValue())));
|
||||
assertThat(roleDto.getPermissions(), hasSize(2));
|
||||
assertThat(roleDto.getPermissions(),
|
||||
containsInAnyOrder(PermissionDto.builder().name(PERM1_NAME).build(), PermissionDto.builder().name(PERM2_NAME).build()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transform_shouldReturnRoleDtoCollection() {
|
||||
// given
|
||||
Role role1 = new Role();
|
||||
role1.setName(ROLE_NAME);
|
||||
role1.setDescription(ROLE_DESC);
|
||||
|
||||
Role role2 = new Role();
|
||||
role2.setName(ROLE_NAME + "2");
|
||||
role2.setDescription(ROLE_DESC + "2");
|
||||
|
||||
// when
|
||||
List<RoleDto> roleDtos = transformer.transformCollection(Arrays.asList(role1, role2));
|
||||
|
||||
// then
|
||||
assertThat(roleDtos, is(not(nullValue())));
|
||||
assertThat(roleDtos, hasSize(2));
|
||||
assertThat(
|
||||
roleDtos,
|
||||
containsInAnyOrder(RoleDto.builder().name(ROLE_NAME).permissions(Collections.<PermissionDto> emptyList()).build(),
|
||||
RoleDto.builder().name(ROLE_NAME + "2").permissions(Collections.<PermissionDto> emptyList()).build()));
|
||||
}
|
||||
}
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
package edu.agh.ztb.authorization.transformer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.emptyCollectionOf;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import edu.agh.ztb.authorization.dto.PermissionDto;
|
||||
import edu.agh.ztb.authorization.dto.RoleDto;
|
||||
import edu.agh.ztb.authorization.dto.UserDto;
|
||||
import edu.agh.ztb.authorization.model.Role;
|
||||
import edu.agh.ztb.authorization.model.User;
|
||||
import edu.agh.ztb.authorization.model.UserRole;
|
||||
|
||||
public class User2UserDtoTransformerTest {
|
||||
|
||||
private final static String USER_LOGIN = "login";
|
||||
private final static String USER_NAME = "name";
|
||||
private final static String USER_SURNAME = "surname";
|
||||
private final static String USER_EMAIL = "123@321.pl";
|
||||
private final static String USER_PASSWORD = "12345678";
|
||||
private final static String ROLE1_NAME = "role1_name";
|
||||
private final static String ROLE1_DESC = "role1_desc";
|
||||
private final static String ROLE2_NAME = "role2_name";
|
||||
private final static String ROLE2_DESC = "role2_desc";
|
||||
|
||||
@Rule
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
private User2UserDtoTransformer transformer;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
transformer = new User2UserDtoTransformer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transform_shouldThrowNPE() {
|
||||
exception.expect(NullPointerException.class);
|
||||
exception.expectMessage("Input must not be null.");
|
||||
|
||||
transformer.transform(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transformCollection_shouldThrowNPE() {
|
||||
exception.expect(NullPointerException.class);
|
||||
exception.expectMessage("Input must not be null.");
|
||||
|
||||
transformer.transformCollection(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transform_shouldReturnCorrectUserDtoWithoutInnerCollection() {
|
||||
// given
|
||||
User user = new User();
|
||||
user.setLogin(USER_LOGIN);
|
||||
user.setName(USER_NAME);
|
||||
user.setSurname(USER_SURNAME);
|
||||
user.setEmail(USER_EMAIL);
|
||||
user.setPassword(USER_PASSWORD);
|
||||
|
||||
// when
|
||||
UserDto userDto = transformer.transform(user);
|
||||
|
||||
// then
|
||||
assertThat(userDto, is(not(nullValue())));
|
||||
assertThat(userDto.getLogin(), is(equalTo(USER_LOGIN)));
|
||||
assertThat(userDto.getName(), is(equalTo(USER_NAME)));
|
||||
assertThat(userDto.getSurname(), is(equalTo(USER_SURNAME)));
|
||||
assertThat(userDto.getEmail(), is(equalTo(USER_EMAIL)));
|
||||
assertThat(userDto.getCurrentToken(), is(nullValue()));
|
||||
assertThat(userDto.getUserRoles(), is(not(nullValue())));
|
||||
assertThat(userDto.getUserRoles(), is(emptyCollectionOf(RoleDto.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transform_shouldReturnCorrectUserDtoWithInnerCollection() {
|
||||
// given
|
||||
User user = new User();
|
||||
user.setLogin(USER_LOGIN);
|
||||
user.setName(USER_NAME);
|
||||
user.setSurname(USER_SURNAME);
|
||||
user.setEmail(USER_EMAIL);
|
||||
user.setPassword(USER_PASSWORD);
|
||||
user.setUserRoles(prepareUserRolesCollection(user));
|
||||
|
||||
// when
|
||||
UserDto userDto = transformer.transform(user);
|
||||
|
||||
// then
|
||||
assertThat(userDto, is(not(nullValue())));
|
||||
assertThat(userDto.getLogin(), is(equalTo(USER_LOGIN)));
|
||||
assertThat(userDto.getName(), is(equalTo(USER_NAME)));
|
||||
assertThat(userDto.getSurname(), is(equalTo(USER_SURNAME)));
|
||||
assertThat(userDto.getEmail(), is(equalTo(USER_EMAIL)));
|
||||
assertThat(userDto.getCurrentToken(), is(nullValue()));
|
||||
assertThat(userDto.getUserRoles(), is(not(nullValue())));
|
||||
assertThat(userDto.getUserRoles(), hasSize(2));
|
||||
assertThat(
|
||||
userDto.getUserRoles(),
|
||||
containsInAnyOrder(RoleDto.builder().name(ROLE1_NAME).permissions(Collections.<PermissionDto> emptyList()).build(),
|
||||
RoleDto.builder().name(ROLE2_NAME).permissions(Collections.<PermissionDto> emptyList()).build()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transformCollection_shouldReturnCorrectUserDtoList() {
|
||||
// given
|
||||
User user1 = new User();
|
||||
user1.setLogin(USER_LOGIN);
|
||||
user1.setName(USER_NAME);
|
||||
user1.setSurname(USER_SURNAME);
|
||||
user1.setEmail(USER_EMAIL);
|
||||
user1.setPassword(USER_PASSWORD);
|
||||
|
||||
User user2 = new User();
|
||||
user2.setLogin(USER_LOGIN + "2");
|
||||
user2.setName(USER_NAME + "2");
|
||||
user2.setSurname(USER_SURNAME + "2");
|
||||
user2.setEmail(USER_EMAIL + "2");
|
||||
user2.setPassword(USER_PASSWORD + "2");
|
||||
|
||||
// when
|
||||
List<UserDto> userDtos = transformer.transformCollection(Arrays.asList(user1, user2));
|
||||
|
||||
// then
|
||||
assertThat(userDtos, is(not(nullValue())));
|
||||
assertThat(userDtos, hasSize(2));
|
||||
assertThat(
|
||||
userDtos,
|
||||
containsInAnyOrder(
|
||||
UserDto.builder().login(USER_LOGIN).name(USER_NAME).surname(USER_SURNAME).email(USER_EMAIL)
|
||||
.userRoles(Collections.<RoleDto> emptyList()).build(),
|
||||
UserDto.builder().login(USER_LOGIN + "2").name(USER_NAME + "2").surname(USER_SURNAME + "2").email(USER_EMAIL + "2")
|
||||
.userRoles(Collections.<RoleDto> emptyList()).build()));
|
||||
}
|
||||
|
||||
private Set<UserRole> prepareUserRolesCollection(User user) {
|
||||
Set<UserRole> userRoles = new HashSet<>();
|
||||
|
||||
Role role1 = new Role();
|
||||
role1.setName(ROLE1_NAME);
|
||||
role1.setDescription(ROLE1_DESC);
|
||||
|
||||
Role role2 = new Role();
|
||||
role2.setName(ROLE2_NAME);
|
||||
role2.setDescription(ROLE2_DESC);
|
||||
|
||||
UserRole userRole1 = new UserRole();
|
||||
userRole1.setRole(role1);
|
||||
userRole1.setUser(user);
|
||||
|
||||
UserRole userRole2 = new UserRole();
|
||||
userRole2.setRole(role2);
|
||||
userRole2.setUser(user);
|
||||
userRoles.add(userRole1);
|
||||
userRoles.add(userRole2);
|
||||
return userRoles;
|
||||
}
|
||||
}
|
||||
+10
@@ -120,6 +120,16 @@
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>edu.agh.ztb</groupId>
|
||||
<artifactId>AuthorizationModule-model</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>edu.agh.ztb</groupId>
|
||||
<artifactId>AuthorizationModule-dto</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
Reference in new issue
Block a user