You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by bh...@apache.org on 2019/09/27 08:09:21 UTC
[incubator-dlab] branch DLAB-terraform updated: DLAB-000 fixed bug
connected with removing user group
This is an automated email from the ASF dual-hosted git repository.
bhliva pushed a commit to branch DLAB-terraform
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/DLAB-terraform by this push:
new 3d91d18 DLAB-000 fixed bug connected with removing user group
3d91d18 is described below
commit 3d91d18292a973f4c3892102cb85880c1283d6b4
Author: bhliva <bo...@epam.com>
AuthorDate: Fri Sep 27 11:09:12 2019 +0300
DLAB-000 fixed bug connected with removing user group
---
.../backendapi/service/impl/UserGroupServiceImpl.java | 18 ++++++++++++------
.../service/impl/UserGroupServiceImplTest.java | 4 ++--
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/UserGroupServiceImpl.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/UserGroupServiceImpl.java
index 51c45fd..c3867c9 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/UserGroupServiceImpl.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/UserGroupServiceImpl.java
@@ -21,6 +21,7 @@ package com.epam.dlab.backendapi.service.impl;
import com.epam.dlab.backendapi.dao.ProjectDAO;
import com.epam.dlab.backendapi.dao.UserGroupDao;
import com.epam.dlab.backendapi.dao.UserRoleDao;
+import com.epam.dlab.backendapi.domain.ProjectDTO;
import com.epam.dlab.backendapi.resources.dto.UserGroupDto;
import com.epam.dlab.backendapi.service.UserGroupService;
import com.epam.dlab.dto.UserInstanceStatus;
@@ -88,12 +89,17 @@ public class UserGroupServiceImpl implements UserGroupService {
@Override
public void removeGroup(String groupId) {
- projectDAO.getProjectsWithEndpointStatusNotIn(UserInstanceStatus.TERMINATED, UserInstanceStatus.TERMINATING)
- .stream()
- .filter(p -> !p.getGroups().contains(groupId))
- .findAny()
- .orElseThrow(() -> new ResourceConflictException("Group can not be removed because it is used in some " +
- "project"));
+ final List<ProjectDTO> notTerminatedProjects =
+ projectDAO.getProjectsWithEndpointStatusNotIn(UserInstanceStatus.TERMINATED,
+ UserInstanceStatus.TERMINATING);
+ if (!notTerminatedProjects.isEmpty()){
+ notTerminatedProjects
+ .stream()
+ .filter(p -> !p.getGroups().contains(groupId))
+ .findAny()
+ .orElseThrow(() -> new ResourceConflictException("Group can not be removed because it is used in some " +
+ "project"));
+ }
if (userRoleDao.removeGroup(groupId)) {
userGroupDao.removeGroup(groupId);
}
diff --git a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/UserGroupServiceImplTest.java b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/UserGroupServiceImplTest.java
index d79ddf2..52f985c 100644
--- a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/UserGroupServiceImplTest.java
+++ b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/UserGroupServiceImplTest.java
@@ -183,8 +183,8 @@ public class UserGroupServiceImplTest {
assertEquals("Group can not be removed because it is used in some project", e.getMessage());
}
- verify(userRoleDao, never()).removeGroup(GROUP);
- verify(userGroupDao, never()).removeGroup(GROUP);
+ verify(userRoleDao).removeGroup(GROUP);
+ verify(userGroupDao).removeGroup(GROUP);
verifyNoMoreInteractions(userGroupDao, userRoleDao);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org