|
|
@ -105,7 +105,7 @@ public class ProjectServiceTest { |
|
|
|
|
|
|
|
|
|
|
|
User loginUser = getLoginUser(); |
|
|
|
User loginUser = getLoginUser(); |
|
|
|
loginUser.setId(1); |
|
|
|
loginUser.setId(1); |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, null, 1, |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, 1, |
|
|
|
PROJECT_CREATE, baseServiceLogger)).thenReturn(true); |
|
|
|
PROJECT_CREATE, baseServiceLogger)).thenReturn(true); |
|
|
|
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, null, 1, |
|
|
|
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, null, 1, |
|
|
|
baseServiceLogger)).thenReturn(true); |
|
|
|
baseServiceLogger)).thenReturn(true); |
|
|
@ -149,7 +149,6 @@ public class ProjectServiceTest { |
|
|
|
project.setUserId(1); |
|
|
|
project.setUserId(1); |
|
|
|
loginUser.setUserType(UserType.ADMIN_USER); |
|
|
|
loginUser.setUserType(UserType.ADMIN_USER); |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
new Object[]{project.getId()}, |
|
|
|
|
|
|
|
project.getUserId(), PROJECT, baseServiceLogger)).thenReturn(true); |
|
|
|
project.getUserId(), PROJECT, baseServiceLogger)).thenReturn(true); |
|
|
|
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
new Object[]{project.getId()}, |
|
|
|
new Object[]{project.getId()}, |
|
|
@ -168,7 +167,6 @@ public class ProjectServiceTest { |
|
|
|
project1.setUserId(2); |
|
|
|
project1.setUserId(2); |
|
|
|
loginUser.setUserType(UserType.GENERAL_USER); |
|
|
|
loginUser.setUserType(UserType.GENERAL_USER); |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
new Object[]{project.getId()}, |
|
|
|
|
|
|
|
loginUser.getId(), PROJECT, baseServiceLogger)).thenReturn(true); |
|
|
|
loginUser.getId(), PROJECT, baseServiceLogger)).thenReturn(true); |
|
|
|
result2 = projectService.checkProjectAndAuth(loginUser, project1, projectCode, PROJECT); |
|
|
|
result2 = projectService.checkProjectAndAuth(loginUser, project1, projectCode, PROJECT); |
|
|
|
Assertions.assertEquals(Status.USER_NO_OPERATION_PROJECT_PERM, result2.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.USER_NO_OPERATION_PROJECT_PERM, result2.get(Constants.STATUS)); |
|
|
@ -191,7 +189,6 @@ public class ProjectServiceTest { |
|
|
|
tempUser.setId(Integer.MAX_VALUE); |
|
|
|
tempUser.setId(Integer.MAX_VALUE); |
|
|
|
tempUser.setUserType(UserType.GENERAL_USER); |
|
|
|
tempUser.setUserType(UserType.GENERAL_USER); |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
new Object[]{project.getId()}, |
|
|
|
|
|
|
|
tempUser.getId(), null, baseServiceLogger)).thenReturn(true); |
|
|
|
tempUser.getId(), null, baseServiceLogger)).thenReturn(true); |
|
|
|
boolean checkResult = projectService.hasProjectAndPerm(tempUser, project, result, null); |
|
|
|
boolean checkResult = projectService.hasProjectAndPerm(tempUser, project, result, null); |
|
|
|
logger.info(result.toString()); |
|
|
|
logger.info(result.toString()); |
|
|
@ -202,7 +199,6 @@ public class ProjectServiceTest { |
|
|
|
project.setUserId(1); |
|
|
|
project.setUserId(1); |
|
|
|
loginUser.setUserType(UserType.ADMIN_USER); |
|
|
|
loginUser.setUserType(UserType.ADMIN_USER); |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
new Object[]{project.getId()}, |
|
|
|
|
|
|
|
loginUser.getId(), null, baseServiceLogger)).thenReturn(true); |
|
|
|
loginUser.getId(), null, baseServiceLogger)).thenReturn(true); |
|
|
|
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
new Object[]{project.getId()}, |
|
|
|
new Object[]{project.getId()}, |
|
|
@ -251,7 +247,6 @@ public class ProjectServiceTest { |
|
|
|
tempUser.setId(Integer.MAX_VALUE); |
|
|
|
tempUser.setId(Integer.MAX_VALUE); |
|
|
|
tempUser.setUserType(UserType.GENERAL_USER); |
|
|
|
tempUser.setUserType(UserType.GENERAL_USER); |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
new Object[]{project.getId()}, |
|
|
|
|
|
|
|
tempUser.getId(), null, baseServiceLogger)).thenReturn(true); |
|
|
|
tempUser.getId(), null, baseServiceLogger)).thenReturn(true); |
|
|
|
boolean checkResult = projectService.hasProjectAndWritePerm(tempUser, project, result); |
|
|
|
boolean checkResult = projectService.hasProjectAndWritePerm(tempUser, project, result); |
|
|
|
logger.info(result.toString()); |
|
|
|
logger.info(result.toString()); |
|
|
@ -262,7 +257,6 @@ public class ProjectServiceTest { |
|
|
|
project.setUserId(1); |
|
|
|
project.setUserId(1); |
|
|
|
loginUser.setUserType(UserType.ADMIN_USER); |
|
|
|
loginUser.setUserType(UserType.ADMIN_USER); |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
new Object[]{project.getId()}, |
|
|
|
|
|
|
|
loginUser.getId(), null, baseServiceLogger)).thenReturn(true); |
|
|
|
loginUser.getId(), null, baseServiceLogger)).thenReturn(true); |
|
|
|
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
new Object[]{project.getId()}, |
|
|
|
new Object[]{project.getId()}, |
|
|
@ -276,9 +270,10 @@ public class ProjectServiceTest { |
|
|
|
public void testDeleteProject() { |
|
|
|
public void testDeleteProject() { |
|
|
|
User loginUser = getLoginUser(); |
|
|
|
User loginUser = getLoginUser(); |
|
|
|
Mockito.when(projectMapper.queryByCode(1L)).thenReturn(getProject()); |
|
|
|
Mockito.when(projectMapper.queryByCode(1L)).thenReturn(getProject()); |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
Mockito.when( |
|
|
|
new Object[]{1}, loginUser.getId(), |
|
|
|
resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, loginUser.getId(), |
|
|
|
PROJECT_DELETE, baseServiceLogger)).thenReturn(true); |
|
|
|
PROJECT_DELETE, baseServiceLogger)) |
|
|
|
|
|
|
|
.thenReturn(true); |
|
|
|
// PROJECT_NOT_FOUND
|
|
|
|
// PROJECT_NOT_FOUND
|
|
|
|
Result result = projectService.deleteProject(loginUser, 11L); |
|
|
|
Result result = projectService.deleteProject(loginUser, 11L); |
|
|
|
logger.info(result.toString()); |
|
|
|
logger.info(result.toString()); |
|
|
@ -319,9 +314,10 @@ public class ProjectServiceTest { |
|
|
|
loginUser.setId(1); |
|
|
|
loginUser.setId(1); |
|
|
|
Project project = getProject(); |
|
|
|
Project project = getProject(); |
|
|
|
project.setCode(2L); |
|
|
|
project.setCode(2L); |
|
|
|
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
Mockito.when( |
|
|
|
new Object[]{1}, loginUser.getId(), |
|
|
|
resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, loginUser.getId(), |
|
|
|
PROJECT_UPDATE, baseServiceLogger)).thenReturn(true); |
|
|
|
PROJECT_UPDATE, baseServiceLogger)) |
|
|
|
|
|
|
|
.thenReturn(true); |
|
|
|
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, new Object[]{1}, |
|
|
|
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, new Object[]{1}, |
|
|
|
loginUser.getId(), |
|
|
|
loginUser.getId(), |
|
|
|
baseServiceLogger)).thenReturn(true); |
|
|
|
baseServiceLogger)).thenReturn(true); |
|
|
@ -391,7 +387,7 @@ public class ProjectServiceTest { |
|
|
|
// SUCCESS
|
|
|
|
// SUCCESS
|
|
|
|
loginUser.setUserType(UserType.ADMIN_USER); |
|
|
|
loginUser.setUserType(UserType.ADMIN_USER); |
|
|
|
Mockito.when( |
|
|
|
Mockito.when( |
|
|
|
resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, new Object[]{1}, |
|
|
|
resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
loginUser.getId(), PROJECT, baseServiceLogger)) |
|
|
|
loginUser.getId(), PROJECT, baseServiceLogger)) |
|
|
|
.thenReturn(true); |
|
|
|
.thenReturn(true); |
|
|
|
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, new Object[]{1}, |
|
|
|
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, new Object[]{1}, |
|
|
@ -405,7 +401,7 @@ public class ProjectServiceTest { |
|
|
|
loginUser.setId(1); |
|
|
|
loginUser.setId(1); |
|
|
|
loginUser.setUserType(UserType.GENERAL_USER); |
|
|
|
loginUser.setUserType(UserType.GENERAL_USER); |
|
|
|
Mockito.when( |
|
|
|
Mockito.when( |
|
|
|
resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, new Object[]{1}, |
|
|
|
resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, |
|
|
|
loginUser.getId(), PROJECT, baseServiceLogger)) |
|
|
|
loginUser.getId(), PROJECT, baseServiceLogger)) |
|
|
|
.thenReturn(true); |
|
|
|
.thenReturn(true); |
|
|
|
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, new Object[]{1}, |
|
|
|
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, new Object[]{1}, |
|
|
|