Deprecate Privilege entity and dao (#763)
Change-Id: I53429e497b6df263d499f8f78dbea77b7fa60ae0
diff --git a/src/main/java/de/ids_mannheim/korap/constant/PrivilegeType.java b/src/main/java/de/ids_mannheim/korap/constant/PrivilegeType.java
index 0466fa2..10bc511 100644
--- a/src/main/java/de/ids_mannheim/korap/constant/PrivilegeType.java
+++ b/src/main/java/de/ids_mannheim/korap/constant/PrivilegeType.java
@@ -1,14 +1,10 @@
package de.ids_mannheim.korap.constant;
-import de.ids_mannheim.korap.entity.Privilege;
-import de.ids_mannheim.korap.entity.Role;
-
/**
* Defines the privilege or permissions of users or admins
* based on their roles.
*
* @author margaretha
- * @see Privilege
* @see Role
*/
public enum PrivilegeType {
diff --git a/src/main/java/de/ids_mannheim/korap/dao/PrivilegeDao.java b/src/main/java/de/ids_mannheim/korap/dao/PrivilegeDao.java
index ad1e77b..bf4e4dc 100644
--- a/src/main/java/de/ids_mannheim/korap/dao/PrivilegeDao.java
+++ b/src/main/java/de/ids_mannheim/korap/dao/PrivilegeDao.java
@@ -28,6 +28,7 @@
* @author margaretha
*
*/
+@Deprecated
@Transactional
@Repository
public class PrivilegeDao {
diff --git a/src/main/java/de/ids_mannheim/korap/entity/Privilege.java b/src/main/java/de/ids_mannheim/korap/entity/Privilege.java
index 0828595..9a03c59 100644
--- a/src/main/java/de/ids_mannheim/korap/entity/Privilege.java
+++ b/src/main/java/de/ids_mannheim/korap/entity/Privilege.java
@@ -21,6 +21,7 @@
* @author margaretha
*
*/
+@Deprecated
@Getter
@Setter
@Entity
diff --git a/src/test/java/de/ids_mannheim/korap/dao/RolePrivilegeDaoTest.java b/src/test/java/de/ids_mannheim/korap/dao/RolePrivilegeDaoTest.java
deleted file mode 100644
index 13b2c91..0000000
--- a/src/test/java/de/ids_mannheim/korap/dao/RolePrivilegeDaoTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package de.ids_mannheim.korap.dao;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-import de.ids_mannheim.korap.constant.PredefinedRole;
-import de.ids_mannheim.korap.constant.PrivilegeType;
-import de.ids_mannheim.korap.entity.Privilege;
-import de.ids_mannheim.korap.entity.Role;
-
-@ExtendWith(SpringExtension.class)
-@ContextConfiguration("classpath:test-config.xml")
-public class RolePrivilegeDaoTest {
-
- @Autowired
- private RoleDao roleDao;
-
- @Autowired
- private PrivilegeDao privilegeDao;
-
- @Test
- public void retrievePredefinedRole () {
- Role r = roleDao
- .retrieveRoleById(PredefinedRole.USER_GROUP_ADMIN.getId());
- assertEquals(1, r.getId());
- }
-
- @Test
- public void createDeleteRole () {
- String roleName = "vc editor";
- List<PrivilegeType> privileges = new ArrayList<PrivilegeType>();
- privileges.add(PrivilegeType.READ);
- privileges.add(PrivilegeType.WRITE);
- roleDao.createRole(roleName, privileges);
- Role r = roleDao.retrieveRoleByName(roleName);
- assertEquals(roleName, r.getName());
- assertEquals(2, r.getPrivileges().size());
- roleDao.deleteRole(r.getId());
- }
-
- @Test
- public void updateRole () {
- Role role = roleDao.retrieveRoleByName("USER_GROUP_MEMBER");
- roleDao.editRoleName(role.getId(), "USER_GROUP_MEMBER role");
- role = roleDao.retrieveRoleById(role.getId());
- assertEquals(role.getName(), "USER_GROUP_MEMBER role");
- roleDao.editRoleName(role.getId(), "USER_GROUP_MEMBER");
- role = roleDao.retrieveRoleById(role.getId());
- assertEquals(role.getName(), "USER_GROUP_MEMBER");
- }
-
- @Test
- public void addDeletePrivilegeOfExistingRole () {
- Role role = roleDao.retrieveRoleByName("USER_GROUP_MEMBER");
- List<Privilege> privileges = role.getPrivileges();
- assertEquals(1, role.getPrivileges().size());
- assertEquals(privileges.get(0).getName(), PrivilegeType.DELETE);
- // add privilege
- List<PrivilegeType> privilegeTypes = new ArrayList<PrivilegeType>();
- privilegeTypes.add(PrivilegeType.READ);
- privilegeDao.addPrivilegesToRole(role, privilegeTypes);
- role = roleDao.retrieveRoleByName("USER_GROUP_MEMBER");
- assertEquals(2, role.getPrivileges().size());
- // delete privilege
- privilegeDao.deletePrivilegeFromRole(role.getId(), PrivilegeType.READ);
- role = roleDao.retrieveRoleByName("USER_GROUP_MEMBER");
- assertEquals(1, role.getPrivileges().size());
- assertEquals(privileges.get(0).getName(), PrivilegeType.DELETE);
- }
-}