aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2018-05-23 16:17:45 +0300
committerTal Gitelman <tg851x@intl.att.com>2018-05-23 16:22:40 +0300
commit44c763981f2e368184d6461dd18529545c3b29aa (patch)
tree5dfa28ad05212706c594f3fb9c763cd8cdda6d36 /catalog-be
parent1742d73bf62fd80c6e88059c7226eb91c011a99d (diff)
new unit tests for sdc-be
Change-Id: I5a7cf20a9157432fd2bf72d24fa48bc5789ad3b4 Issue-ID: SDC-1333 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java26
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/TestSuite.java11
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/TestSuite.java11
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/dto/TestSuite.java11
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/TestSuite.java11
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceDefinitionTest.java52
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceNodeTypeTest.java101
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinitionTest.java100
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminValidatorTest.java51
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/user/UserBusinessLogicTest.java1006
10 files changed, 1322 insertions, 58 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java
index 794de4ab38..e28375d578 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java
@@ -147,15 +147,8 @@ public class UserBusinessLogic implements IUserBusinessLogic {
Either<User, StorageOperationStatus> addOrUpdateUserReq;
- if (ActionStatus.USER_INACTIVE.equals(eitherUserInDB.right().value())) { // user
- // exist
- // with
- // inactive
- // state
- // -
- // update
- // user
- // data
+ if (eitherUserInDB.isRight() && ActionStatus.USER_INACTIVE.equals(eitherUserInDB.right().value())) {
+ // user exist with inactive state - update user data
newUser.setLastLoginTime(0L);
addOrUpdateUserReq = userAdminOperation.updateUserData(newUser);
@@ -172,7 +165,7 @@ public class UserBusinessLogic implements IUserBusinessLogic {
if (addOrUpdateUserReq.isRight() || addOrUpdateUserReq.left().value() == null) {
log.debug("createUser method - failed to create user");
- Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addOrUpdateUserReq.right().value())));
+ return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addOrUpdateUserReq.right().value())));
}
log.debug("createUser method - user created");
User createdUser = addOrUpdateUserReq.left().value();
@@ -321,6 +314,9 @@ public class UserBusinessLogic implements IUserBusinessLogic {
} else {
rolesStr = "All";
getResponse = getUsersPerRole(null, user, rolesStr);
+ if(getResponse.isRight()) {
+ return getResponse;
+ }
resultList.addAll(getResponse.left().value());
}
responseFormat = componentsUtils.getResponseFormat(ActionStatus.OK);
@@ -487,9 +483,10 @@ public class UserBusinessLogic implements IUserBusinessLogic {
Either<User, StorageOperationStatus> updateUserReq = userAdminOperation.updateUserData(user);
if (updateUserReq.isRight()) {
- responseFormat = componentsUtils.getResponseFormatByUser(eitherCreator.right().value(), user);
+ ActionStatus convertFromStorageResponse = componentsUtils.convertFromStorageResponse(updateUserReq.right().value());
+ responseFormat = componentsUtils.getResponseFormatByUser(convertFromStorageResponse, user);
handleUserAccessAuditing(user, responseFormat, AuditingActionEnum.USER_ACCESS);
- return Either.right(componentsUtils.getResponseFormatByUser(eitherCreator.right().value(), user));
+ return Either.right(responseFormat);
}
User updatedUser = updateUserReq.left().value();
@@ -569,9 +566,10 @@ public class UserBusinessLogic implements IUserBusinessLogic {
Either<User, StorageOperationStatus> updateUserReq = userAdminOperation.updateUserData(user);
if (updateUserReq.isRight()) {
- responseFormat = componentsUtils.getResponseFormatByUser(eitherCreator.right().value(), user);
+ ActionStatus convertFromStorageResponse = componentsUtils.convertFromStorageResponse(updateUserReq.right().value());
+ responseFormat = componentsUtils.getResponseFormatByUser(convertFromStorageResponse, user);
handleUserAccessAuditing(user, responseFormat, AuditingActionEnum.USER_ACCESS);
- return Either.right(componentsUtils.getResponseFormatByUser(eitherCreator.right().value(), user));
+ return Either.right(responseFormat);
}
User updatedUser = updateUserReq.left().value();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/TestSuite.java b/catalog-be/src/test/java/org/openecomp/sdc/TestSuite.java
deleted file mode 100644
index 278e965837..0000000000
--- a/catalog-be/src/test/java/org/openecomp/sdc/TestSuite.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.openecomp.sdc;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses(
-
-{ ErrorConfigurationTest.class, org.openecomp.sdc.be.TestSuite.class })
-public class TestSuite { // nothing
-}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/TestSuite.java b/catalog-be/src/test/java/org/openecomp/sdc/be/TestSuite.java
deleted file mode 100644
index d4cc2fb5dd..0000000000
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/TestSuite.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.openecomp.sdc.be;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses(
-
-{ org.openecomp.sdc.be.ecomp.TestSuite.class })
-public class TestSuite { // nothing
-}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/dto/TestSuite.java b/catalog-be/src/test/java/org/openecomp/sdc/be/dto/TestSuite.java
deleted file mode 100644
index 6178d3855f..0000000000
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/dto/TestSuite.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.openecomp.sdc.be.dto;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses(
-
-{ ExternalRefDTOTest.class })
-public class TestSuite { // nothing
-}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/TestSuite.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/TestSuite.java
deleted file mode 100644
index c255aa353d..0000000000
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/TestSuite.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.openecomp.sdc.be.ecomp;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses(
-
-{ EcompIntImplTest.class, GenerateEcompErrorFileTest.class })
-public class TestSuite { // nothing
-}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceDefinitionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceDefinitionTest.java
new file mode 100644
index 0000000000..f3159dde83
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceDefinitionTest.java
@@ -0,0 +1,52 @@
+package org.openecomp.sdc.be.tosca.model;
+
+import java.util.Map;
+
+import org.junit.Test;
+
+public class ToscaInterfaceDefinitionTest {
+
+ private ToscaInterfaceDefinition createTestSubject() {
+ return new ToscaInterfaceDefinition();
+ }
+
+ @Test
+ public void testGetType() throws Exception {
+ ToscaInterfaceDefinition testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getType();
+ }
+
+ @Test
+ public void testSetType() throws Exception {
+ ToscaInterfaceDefinition testSubject;
+ String type = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setType(type);
+ }
+
+ @Test
+ public void testGetOperations() throws Exception {
+ ToscaInterfaceDefinition testSubject;
+ Map<String, Object> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getOperations();
+ }
+
+ @Test
+ public void testSetOperations() throws Exception {
+ ToscaInterfaceDefinition testSubject;
+ Map<String, Object> toscaOperations = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setOperations(toscaOperations);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceNodeTypeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceNodeTypeTest.java
new file mode 100644
index 0000000000..e6f1f96e89
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceNodeTypeTest.java
@@ -0,0 +1,101 @@
+package org.openecomp.sdc.be.tosca.model;
+
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ToscaInterfaceNodeTypeTest {
+
+ private ToscaInterfaceNodeType createTestSubject() {
+ return new ToscaInterfaceNodeType();
+ }
+
+ @Test
+ public void testGetDerived_from() throws Exception {
+ ToscaInterfaceNodeType testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getDerived_from();
+ }
+
+ @Test
+ public void testSetDerived_from() throws Exception {
+ ToscaInterfaceNodeType testSubject;
+ String derived_from = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setDerived_from(derived_from);
+ }
+
+ @Test
+ public void testGetDescription() throws Exception {
+ ToscaInterfaceNodeType testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getDescription();
+ }
+
+ @Test
+ public void testSetDescription() throws Exception {
+ ToscaInterfaceNodeType testSubject;
+ String description = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setDescription(description);
+ }
+
+ @Test
+ public void testEquals() throws Exception {
+ ToscaInterfaceNodeType testSubject;
+ Object o = null;
+ boolean result;
+
+ // test 1
+ testSubject = createTestSubject();
+ o = null;
+ result = testSubject.equals(o);
+ Assert.assertEquals(false, result);
+ result = testSubject.equals(testSubject);
+ Assert.assertEquals(true, result);
+ result = testSubject.equals(createTestSubject());
+ Assert.assertEquals(true, result);
+
+ }
+
+ @Test
+ public void testHashCode() throws Exception {
+ ToscaInterfaceNodeType testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.hashCode();
+ }
+
+ @Test
+ public void testGetOperations() throws Exception {
+ ToscaInterfaceNodeType testSubject;
+ Map<String, Object> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getOperations();
+ }
+
+ @Test
+ public void testSetOperations() throws Exception {
+ ToscaInterfaceNodeType testSubject;
+ Map<String, Object> operations = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setOperations(operations);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinitionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinitionTest.java
new file mode 100644
index 0000000000..3aadeafd96
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinitionTest.java
@@ -0,0 +1,100 @@
+package org.openecomp.sdc.be.tosca.model;
+
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ToscaLifecycleOperationDefinitionTest {
+
+ private ToscaLifecycleOperationDefinition createTestSubject() {
+ return new ToscaLifecycleOperationDefinition();
+ }
+
+ @Test
+ public void testGetImplementation() throws Exception {
+ ToscaLifecycleOperationDefinition testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getImplementation();
+ }
+
+ @Test
+ public void testSetImplementation() throws Exception {
+ ToscaLifecycleOperationDefinition testSubject;
+ String implementation = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setImplementation(implementation);
+ }
+
+ @Test
+ public void testGetInputs() throws Exception {
+ ToscaLifecycleOperationDefinition testSubject;
+ Map<String, ToscaProperty> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getInputs();
+ }
+
+ @Test
+ public void testSetInputs() throws Exception {
+ ToscaLifecycleOperationDefinition testSubject;
+ Map<String, ToscaProperty> inputs = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setInputs(inputs);
+ }
+
+ @Test
+ public void testEquals() throws Exception {
+ ToscaLifecycleOperationDefinition testSubject;
+ Object o = null;
+ boolean result;
+
+ // test 1
+ testSubject = createTestSubject();
+ o = null;
+ result = testSubject.equals(o);
+ Assert.assertEquals(false, result);
+ result = testSubject.equals(testSubject);
+ Assert.assertEquals(true, result);
+ result = testSubject.equals(createTestSubject());
+ Assert.assertEquals(true, result);
+ }
+
+ @Test
+ public void testHashCode() throws Exception {
+ ToscaLifecycleOperationDefinition testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.hashCode();
+ }
+
+ @Test
+ public void testGetDescription() throws Exception {
+ ToscaLifecycleOperationDefinition testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getDescription();
+ }
+
+ @Test
+ public void testSetDescription() throws Exception {
+ ToscaLifecycleOperationDefinition testSubject;
+ String description = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setDescription(description);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminValidatorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminValidatorTest.java
new file mode 100644
index 0000000000..23e619d764
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminValidatorTest.java
@@ -0,0 +1,51 @@
+package org.openecomp.sdc.be.user;
+
+import org.junit.Test;
+
+public class UserAdminValidatorTest {
+
+ private UserAdminValidator createTestSubject() {
+ return UserAdminValidator.getInstance();
+ }
+
+ @Test
+ public void testGetInstance() throws Exception {
+ UserAdminValidator result;
+
+ // default test
+ result = UserAdminValidator.getInstance();
+ }
+
+ @Test
+ public void testValidateEmail() throws Exception {
+ UserAdminValidator testSubject;
+ String hex = "";
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.validateEmail(hex);
+ }
+
+ @Test
+ public void testValidateUserId() throws Exception {
+ UserAdminValidator testSubject;
+ String userId = "";
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.validateUserId(userId);
+ }
+
+ @Test
+ public void testValidateRole() throws Exception {
+ UserAdminValidator testSubject;
+ String role = "";
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.validateRole(role);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserBusinessLogicTest.java
new file mode 100644
index 0000000000..def184c9a7
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserBusinessLogicTest.java
@@ -0,0 +1,1006 @@
+package org.openecomp.sdc.be.user;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.servlet.ServletContext;
+
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
+import org.javatuples.Pair;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
+import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.operations.api.IUserAdminOperation;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
+import org.openecomp.sdc.common.api.UserRoleEnum;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+import fj.data.Either;
+import mockit.Deencapsulation;
+
+public class UserBusinessLogicTest {
+
+ @InjectMocks
+ UserBusinessLogic testSubject;
+ @Mock
+ private IUserAdminOperation userAdminOperation;
+ @Mock
+ private ComponentsUtils componentsUtils;
+ @Mock
+ private TitanGenericDao titanDao;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testGetUser() throws Exception {
+ String userId = "";
+ boolean inTransaction = false;
+ Either<User, ActionStatus> result;
+
+ // default test
+ result = testSubject.getUser(userId, inTransaction);
+ }
+
+ @Test
+ public void testCreateUser() throws Exception {
+ User modifier = new User();
+ User newUser = new User();
+ Either<User, ResponseFormat> result;
+
+ // default test
+ result = testSubject.createUser(modifier, newUser);
+ }
+
+ @Test
+ public void testCreateUserErrorGetUser() throws Exception {
+ User modifier = new User();
+ User newUser = new User();
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.right(ActionStatus.USER_NOT_FOUND);
+ Mockito.when(userAdminOperation.getUserData(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(value);
+
+ // default test
+ modifier.setUserId("mock");
+ result = testSubject.createUser(modifier, newUser);
+ }
+
+ @Test
+ public void testCreateUserErrorUserNotAdmin() throws Exception {
+ User modifier = new User();
+ User newUser = new User();
+ Either<User, ResponseFormat> result;
+
+ User userFromDb = new User();
+ userFromDb.setRole(UserRoleEnum.DESIGNER.getName());
+ Either<User, ActionStatus> value = Either.left(userFromDb);
+ Mockito.when(userAdminOperation.getUserData(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(value);
+
+ // default test
+ modifier.setUserId("mock");
+ result = testSubject.createUser(modifier, newUser);
+ }
+
+ @Test
+ public void testCreateErrorCheckingNewUser() throws Exception {
+ User modifier = new User();
+ User newUser = new User();
+ Either<User, ResponseFormat> result;
+
+ User userFromDb = new User();
+ userFromDb.setRole(UserRoleEnum.ADMIN.getName());
+ Either<User, ActionStatus> value = Either.left(userFromDb);
+ Either<User, ActionStatus> value2 = Either.right(ActionStatus.AUTH_REQUIRED);
+ Mockito.when(userAdminOperation.getUserData("mockModif", false)).thenReturn(value);
+ Mockito.when(userAdminOperation.getUserData("mockNewUs", false)).thenReturn(value2);
+
+ // default test
+ modifier.setUserId("mockModif");
+ newUser.setUserId("mockNewUs");
+ result = testSubject.createUser(modifier, newUser);
+ }
+
+ @Test
+ public void testCreateErrorCheckingNewUser2() throws Exception {
+ User modifier = new User();
+ User newUser = new User();
+ Either<User, ResponseFormat> result;
+
+ User userFromDb = new User();
+ userFromDb.setRole(UserRoleEnum.ADMIN.getName());
+ Either<User, ActionStatus> value = Either.left(userFromDb);
+ Either<User, ActionStatus> value2 = Either.right(ActionStatus.USER_ALREADY_EXIST);
+ Mockito.when(userAdminOperation.getUserData("mockModif", false)).thenReturn(value);
+ Mockito.when(userAdminOperation.getUserData("mockNewUs", false)).thenReturn(value2);
+
+ // default test
+ modifier.setUserId("mockModif");
+ newUser.setUserId("mockNewUs");
+ result = testSubject.createUser(modifier, newUser);
+ }
+
+ @Test
+ public void testCreate2() throws Exception {
+ User modifier = new User();
+ User newUser = new User();
+ Either<User, ResponseFormat> result;
+
+ modifier.setUserId("mockModif");
+ newUser.setUserId("mockNewUs");
+
+ User userFromDb = new User();
+ userFromDb.setRole(UserRoleEnum.ADMIN.getName());
+ Either<User, ActionStatus> value = Either.left(userFromDb);
+
+ User userFromDb2 = new User();
+ Either<User, ActionStatus> value2 = Either.left(userFromDb2);
+ Mockito.when(userAdminOperation.getUserData("mockModif", false)).thenReturn(value);
+ Mockito.when(userAdminOperation.getUserData("mockNewUs", false)).thenReturn(value2);
+
+ // default test
+ result = testSubject.createUser(modifier, newUser);
+ }
+
+ @Test
+ public void testCreateInvalidMail() throws Exception {
+ User modifier = new User();
+ User newUser = new User();
+ Either<User, ResponseFormat> result;
+
+ modifier.setUserId("mockModif");
+ newUser.setUserId("mockNewUs");
+ newUser.setEmail("mock");
+
+ User userFromDbAdmin = new User();
+ userFromDbAdmin.setRole(UserRoleEnum.ADMIN.getName());
+ Either<User, ActionStatus> value = Either.left(userFromDbAdmin);
+
+ User userFromDbNew = new User();
+ userFromDbNew.setStatus(UserStatusEnum.INACTIVE);
+ Either<User, ActionStatus> value2 = Either.left(userFromDbNew);
+ Mockito.when(userAdminOperation.getUserData("mockModif", false)).thenReturn(value);
+ Mockito.when(userAdminOperation.getUserData("mockNewUs", false)).thenReturn(value2);
+
+ // default test
+ result = testSubject.createUser(modifier, newUser);
+ }
+
+ @Test
+ public void testCreateInvalidRole() throws Exception {
+ User modifier = new User();
+ User newUser = new User();
+ Either<User, ResponseFormat> result;
+
+ modifier.setUserId("mockModif");
+ newUser.setUserId("mockNewUs");
+ newUser.setEmail("mock@mock.mock");
+ newUser.setRole("mock");
+
+ User userFromDbAdmin = new User();
+ userFromDbAdmin.setRole(UserRoleEnum.ADMIN.getName());
+ Either<User, ActionStatus> value = Either.left(userFromDbAdmin);
+
+ User userFromDbNew = new User();
+ userFromDbNew.setStatus(UserStatusEnum.INACTIVE);
+ Either<User, ActionStatus> value2 = Either.left(userFromDbNew);
+ Mockito.when(userAdminOperation.getUserData("mockModif", false)).thenReturn(value);
+ Mockito.when(userAdminOperation.getUserData("mockNewUs", false)).thenReturn(value2);
+
+ // default test
+ result = testSubject.createUser(modifier, newUser);
+ }
+
+ @Test
+ public void testCreateInvalidId() throws Exception {
+ User modifier = new User();
+ User newUser = new User();
+ Either<User, ResponseFormat> result;
+
+ modifier.setUserId("mockModif");
+ newUser.setUserId("mockNewUs");
+ newUser.setEmail("mock@mock.mock");
+ newUser.setUserId("");
+ User userFromDbAdmin = new User();
+ userFromDbAdmin.setRole(UserRoleEnum.ADMIN.getName());
+ Either<User, ActionStatus> value = Either.left(userFromDbAdmin);
+
+ User userFromDbNew = new User();
+ userFromDbNew.setStatus(UserStatusEnum.INACTIVE);
+ Either<User, ActionStatus> value2 = Either.left(userFromDbNew);
+ Mockito.when(userAdminOperation.getUserData("mockModif", false)).thenReturn(value);
+ Mockito.when(userAdminOperation.getUserData("", false)).thenReturn(value2);
+
+ // default test
+ result = testSubject.createUser(modifier, newUser);
+ }
+
+ @Test
+ public void testCreateUpdateFails() throws Exception {
+ User modifier = new User();
+ User newUser = new User();
+ Either<User, ResponseFormat> result;
+
+ modifier.setUserId("mockModif");
+ newUser.setUserId("mockNewUs");
+ newUser.setEmail("mock@mock.mock");
+
+ User userFromDbAdmin = new User();
+ userFromDbAdmin.setRole(UserRoleEnum.ADMIN.getName());
+ Either<User, ActionStatus> value = Either.left(userFromDbAdmin);
+
+ User userFromDbNew = new User();
+ userFromDbNew.setStatus(UserStatusEnum.INACTIVE);
+ Either<User, ActionStatus> value2 = Either.left(userFromDbNew);
+ Mockito.when(userAdminOperation.getUserData("mockModif", false)).thenReturn(value);
+ Mockito.when(userAdminOperation.getUserData("mockNewUs", false)).thenReturn(value2);
+ Either<User, StorageOperationStatus> addOrUpdateUserReq = Either
+ .right(StorageOperationStatus.GRAPH_IS_NOT_AVAILABLE);
+ Mockito.when(userAdminOperation.saveUserData(Mockito.any(User.class))).thenReturn(addOrUpdateUserReq);
+
+ // default test
+ result = testSubject.createUser(modifier, newUser);
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ User modifier = new User();
+ User newUser = new User();
+ Either<User, ResponseFormat> result;
+
+ modifier.setUserId("mockModif");
+ newUser.setUserId("mockNewUs");
+ newUser.setEmail("mock@mock.mock");
+
+ User userFromDbAdmin = new User();
+ userFromDbAdmin.setRole(UserRoleEnum.ADMIN.getName());
+ Either<User, ActionStatus> value = Either.left(userFromDbAdmin);
+
+ User userFromDbNew = new User();
+ userFromDbNew.setStatus(UserStatusEnum.INACTIVE);
+ Either<User, ActionStatus> value2 = Either.left(userFromDbNew);
+ Mockito.when(userAdminOperation.getUserData("mockModif", false)).thenReturn(value);
+ Mockito.when(userAdminOperation.getUserData("mockNewUs", false)).thenReturn(value2);
+ Either<User, StorageOperationStatus> addOrUpdateUserReq = Either.left(newUser);
+ Mockito.when(userAdminOperation.saveUserData(Mockito.any(User.class))).thenReturn(addOrUpdateUserReq);
+
+ // default test
+ result = testSubject.createUser(modifier, newUser);
+ }
+
+ @Test
+ public void testUpdateUserRoleNoId() throws Exception {
+ User modifier = new User();
+ String userIdToUpdate = "";
+ String userRole = "";
+ Either<User, ResponseFormat> result;
+
+ // default test
+ result = testSubject.updateUserRole(modifier, userIdToUpdate, userRole);
+ }
+
+ @Test
+ public void testUpdateUserRoleNotFound() throws Exception {
+ User modifier = new User();
+ modifier.setUserId("mock");
+ String userIdToUpdate = "";
+ String userRole = "";
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.right(ActionStatus.USER_NOT_FOUND);
+ Mockito.when(userAdminOperation.getUserData(modifier.getUserId(), false)).thenReturn(value);
+
+ // default test
+ result = testSubject.updateUserRole(modifier, userIdToUpdate, userRole);
+ }
+
+ @Test
+ public void testUpdateUserRoleModifWrongRole() throws Exception {
+ User modifier = new User();
+ modifier.setUserId("mock");
+ modifier.setRole(UserRoleEnum.DESIGNER.getName());
+ String userIdToUpdate = "";
+ String userRole = "";
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Mockito.when(userAdminOperation.getUserData(modifier.getUserId(), false)).thenReturn(value);
+
+ // default test
+ result = testSubject.updateUserRole(modifier, userIdToUpdate, userRole);
+ }
+
+ @Test
+ public void testUpdateUserRoleSameId() throws Exception {
+ User modifier = new User();
+ modifier.setUserId("mock");
+ modifier.setRole(UserRoleEnum.ADMIN.getName());
+ String userIdToUpdate = "mock";
+ String userRole = "";
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Mockito.when(userAdminOperation.getUserData(modifier.getUserId(), false)).thenReturn(value);
+
+ // default test
+ result = testSubject.updateUserRole(modifier, userIdToUpdate, userRole);
+ }
+
+ @Test
+ public void testUpdateUserRoleUpdatedNotFound() throws Exception {
+ User modifier = new User();
+ modifier.setUserId("mock");
+ modifier.setRole(UserRoleEnum.ADMIN.getName());
+ String userIdToUpdate = "mock1";
+ String userRole = "";
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Either<User, ActionStatus> value2 = Either.right(ActionStatus.ECOMP_USER_NOT_FOUND);
+ Mockito.when(userAdminOperation.getUserData(modifier.getUserId(), false)).thenReturn(value);
+ Mockito.when(userAdminOperation.getUserData(userIdToUpdate, false)).thenReturn(value2);
+
+ // default test
+ result = testSubject.updateUserRole(modifier, userIdToUpdate, userRole);
+ }
+
+ @Test
+ public void testUpdateUserRoleUpdatedToInvalidRole() throws Exception {
+ User modifier = new User();
+ modifier.setUserId("mock");
+ modifier.setRole(UserRoleEnum.ADMIN.getName());
+ String userIdToUpdate = "mock1";
+ String userRole = "";
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Mockito.when(userAdminOperation.getUserData(modifier.getUserId(), false)).thenReturn(value);
+ Mockito.when(userAdminOperation.getUserData(userIdToUpdate, false)).thenReturn(value);
+
+ // default test
+ result = testSubject.updateUserRole(modifier, userIdToUpdate, userRole);
+ }
+
+ @Test
+ public void testUpdateUserRolePendingTaskFailed() throws Exception {
+ User modifier = new User();
+ modifier.setUserId("mock");
+ modifier.setRole(UserRoleEnum.ADMIN.getName());
+ String userIdToUpdate = "mock1";
+ String userRole = UserRoleEnum.DESIGNER.getName();
+ Either<User, ResponseFormat> result;
+
+ User updatedUser = new User();
+ updatedUser.setUserId(userIdToUpdate);
+ updatedUser.setRole(UserRoleEnum.TESTER.getName());
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Either<User, ActionStatus> value2 = Either.left(updatedUser);
+ Mockito.when(userAdminOperation.getUserData(modifier.getUserId(), false)).thenReturn(value);
+ Mockito.when(userAdminOperation.getUserData(userIdToUpdate, false)).thenReturn(value2);
+
+ Either<List<Edge>, StorageOperationStatus> value3 = Either.right(StorageOperationStatus.INCONSISTENCY);
+ Mockito.when(userAdminOperation.getUserPendingTasksList(Mockito.any(), Mockito.any())).thenReturn(value3);
+
+ // default test
+ result = testSubject.updateUserRole(modifier, userIdToUpdate, userRole);
+ }
+
+ @Test
+ public void testUpdateUserRoleListOfTasksNotEmpty() throws Exception {
+ User modifier = new User();
+ modifier.setUserId("mock");
+ modifier.setRole(UserRoleEnum.ADMIN.getName());
+ String userIdToUpdate = "mock1";
+ String userRole = UserRoleEnum.DESIGNER.getName();
+ Either<User, ResponseFormat> result;
+
+ User updatedUser = new User();
+ updatedUser.setUserId(userIdToUpdate);
+ updatedUser.setRole(UserRoleEnum.TESTER.getName());
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Either<User, ActionStatus> value2 = Either.left(updatedUser);
+ Mockito.when(userAdminOperation.getUserData(modifier.getUserId(), false)).thenReturn(value);
+ Mockito.when(userAdminOperation.getUserData(userIdToUpdate, false)).thenReturn(value2);
+ List<Edge> list = new LinkedList<>();
+
+ list.add(new DetachedEdge("sdas", "fdfs", new HashMap<>(), Pair.with("sadas", "sadasd"),
+ Pair.with("sadas", "sadasd")));
+ Either<List<Edge>, StorageOperationStatus> value3 = Either.left(list);
+ Mockito.when(userAdminOperation.getUserPendingTasksList(Mockito.any(), Mockito.any())).thenReturn(value3);
+
+ // default test
+ result = testSubject.updateUserRole(modifier, userIdToUpdate, userRole);
+ }
+
+ @Test
+ public void testUpdateUserRoleFailToUpdate() throws Exception {
+ User modifier = new User();
+ modifier.setUserId("mock");
+ modifier.setRole(UserRoleEnum.ADMIN.getName());
+ String userIdToUpdate = "mock1";
+ String userRole = UserRoleEnum.DESIGNER.getName();
+ Either<User, ResponseFormat> result;
+
+ User updatedUser = new User();
+ updatedUser.setUserId(userIdToUpdate);
+ updatedUser.setRole(UserRoleEnum.TESTER.getName());
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Either<User, ActionStatus> value2 = Either.left(updatedUser);
+ Mockito.when(userAdminOperation.getUserData(modifier.getUserId(), false)).thenReturn(value);
+ Mockito.when(userAdminOperation.getUserData(userIdToUpdate, false)).thenReturn(value2);
+ List<Edge> list = new LinkedList<>();
+
+ Either<List<Edge>, StorageOperationStatus> value3 = Either.left(list);
+ Mockito.when(userAdminOperation.getUserPendingTasksList(Mockito.any(), Mockito.any())).thenReturn(value3);
+ Either<User, StorageOperationStatus> value4 = Either.right(StorageOperationStatus.INCONSISTENCY);
+ Mockito.when(userAdminOperation.updateUserData(Mockito.any())).thenReturn(value4);
+ // default test
+ result = testSubject.updateUserRole(modifier, userIdToUpdate, userRole);
+ }
+
+ @Test
+ public void testUpdateUserRole() throws Exception {
+ User modifier = new User();
+ modifier.setUserId("mock");
+ modifier.setRole(UserRoleEnum.ADMIN.getName());
+ String userIdToUpdate = "mock1";
+ String userRole = UserRoleEnum.DESIGNER.getName();
+ Either<User, ResponseFormat> result;
+
+ User updatedUser = new User();
+ updatedUser.setUserId(userIdToUpdate);
+ updatedUser.setRole(UserRoleEnum.TESTER.getName());
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Either<User, ActionStatus> value2 = Either.left(updatedUser);
+ Mockito.when(userAdminOperation.getUserData(modifier.getUserId(), false)).thenReturn(value);
+ Mockito.when(userAdminOperation.getUserData(userIdToUpdate, false)).thenReturn(value2);
+ List<Edge> list = new LinkedList<>();
+
+ Either<List<Edge>, StorageOperationStatus> value3 = Either.left(list);
+ Mockito.when(userAdminOperation.getUserPendingTasksList(Mockito.any(), Mockito.any())).thenReturn(value3);
+ Either<User, StorageOperationStatus> value4 = Either.left(updatedUser);
+ Mockito.when(userAdminOperation.updateUserData(Mockito.any())).thenReturn(value4);
+ // default test
+ result = testSubject.updateUserRole(modifier, userIdToUpdate, userRole);
+ }
+
+ @Test
+ public void testGetAllAdminUsers() throws Exception {
+ ServletContext context = null;
+ Either<List<User>, ResponseFormat> result;
+
+ Either<List<User>, ActionStatus> response = Either.left(new LinkedList<>());
+ Mockito.when(userAdminOperation.getAllUsersWithRole(Mockito.anyString(), Mockito.nullable(String.class)))
+ .thenReturn(response);
+ // default test
+ result = testSubject.getAllAdminUsers(context);
+ }
+
+ @Test
+ public void testGetAllAdminUsersFail() throws Exception {
+ ServletContext context = null;
+ Either<List<User>, ResponseFormat> result;
+
+ Either<List<User>, ActionStatus> response = Either.right(ActionStatus.NOT_ALLOWED);
+ Mockito.when(userAdminOperation.getAllUsersWithRole(Mockito.anyString(), Mockito.nullable(String.class)))
+ .thenReturn(response);
+ // default test
+ result = testSubject.getAllAdminUsers(context);
+ }
+
+ @Test
+ public void testGetUsersList1() throws Exception {
+ String modifierAttId = "";
+ List<String> roles = null;
+ String rolesStr = "";
+ Either<List<User>, ResponseFormat> result;
+
+ // test 1
+ modifierAttId = null;
+ result = testSubject.getUsersList(modifierAttId, roles, rolesStr);
+ }
+
+ @Test
+ public void testGetUsersListFail() throws Exception {
+ String modifierAttId = "mockMod";
+ List<String> roles = null;
+ String rolesStr = "";
+ Either<List<User>, ResponseFormat> result;
+
+ Either<User, ActionStatus> value3 = Either.right(ActionStatus.ILLEGAL_COMPONENT_STATE);
+ Mockito.when(userAdminOperation.getUserData(modifierAttId, false)).thenReturn(value3);
+
+ result = testSubject.getUsersList(modifierAttId, roles, rolesStr);
+ }
+
+ @Test
+ public void testGetUsersListFail2() throws Exception {
+ String modifierAttId = "mockMod";
+ List<String> roles = null;
+ String rolesStr = "";
+ Either<List<User>, ResponseFormat> result;
+
+ Either<User, ActionStatus> value3 = Either.right(ActionStatus.USER_NOT_FOUND);
+ Mockito.when(userAdminOperation.getUserData(modifierAttId, false)).thenReturn(value3);
+
+ result = testSubject.getUsersList(modifierAttId, roles, rolesStr);
+ }
+
+ @Test
+ public void testGetUsersListFail3() throws Exception {
+ String modifierAttId = "mockMod";
+ List<String> roles = new LinkedList<>();
+ String rolesStr = "";
+ Either<List<User>, ResponseFormat> result;
+
+ User a = new User();
+ Either<User, ActionStatus> value3 = Either.left(a);
+ Mockito.when(userAdminOperation.getUserData(modifierAttId, false)).thenReturn(value3);
+ Either<List<User>, ActionStatus> value = Either.right(ActionStatus.USER_NOT_FOUND);
+ Mockito.when(userAdminOperation.getAllUsersWithRole(Mockito.nullable(String.class), Mockito.anyString()))
+ .thenReturn(value);
+
+ result = testSubject.getUsersList(modifierAttId, roles, rolesStr);
+ }
+
+ @Test
+ public void testGetUsersList() throws Exception {
+ String modifierAttId = "mockMod";
+ List<String> roles = new LinkedList<>();
+ String rolesStr = "";
+ Either<List<User>, ResponseFormat> result;
+
+ User a = new User();
+ Either<User, ActionStatus> value3 = Either.left(a);
+ Mockito.when(userAdminOperation.getUserData(modifierAttId, false)).thenReturn(value3);
+ Either<List<User>, ActionStatus> value = Either.left(new LinkedList<>());
+ Mockito.when(userAdminOperation.getAllUsersWithRole(Mockito.nullable(String.class), Mockito.anyString()))
+ .thenReturn(value);
+
+ result = testSubject.getUsersList(modifierAttId, roles, rolesStr);
+ }
+
+ @Test
+ public void testGetUsersListInvalidRole() throws Exception {
+ String modifierAttId = "mockMod";
+ List<String> roles = new LinkedList<>();
+ roles.add("mock");
+ String rolesStr = "";
+ Either<List<User>, ResponseFormat> result;
+
+ User a = new User();
+ Either<User, ActionStatus> value3 = Either.left(a);
+ Mockito.when(userAdminOperation.getUserData(modifierAttId, false)).thenReturn(value3);
+ Either<List<User>, ActionStatus> value = Either.left(new LinkedList<>());
+ Mockito.when(userAdminOperation.getAllUsersWithRole(Mockito.nullable(String.class), Mockito.anyString()))
+ .thenReturn(value);
+
+ result = testSubject.getUsersList(modifierAttId, roles, rolesStr);
+ }
+
+ @Test
+ public void testGetUsersList2() throws Exception {
+ String modifierAttId = "mockMod";
+ List<String> roles = new LinkedList<>();
+ roles.add(UserRoleEnum.DESIGNER.name());
+ String rolesStr = "";
+ Either<List<User>, ResponseFormat> result;
+
+ User a = new User();
+ Either<User, ActionStatus> value3 = Either.left(a);
+ Mockito.when(userAdminOperation.getUserData(modifierAttId, false)).thenReturn(value3);
+ Either<List<User>, ActionStatus> value = Either.left(new LinkedList<>());
+ Mockito.when(userAdminOperation.getAllUsersWithRole(Mockito.nullable(String.class), Mockito.anyString()))
+ .thenReturn(value);
+
+ result = testSubject.getUsersList(modifierAttId, roles, rolesStr);
+ }
+
+ @Test
+ public void testHandleUserAccessAuditing() throws Exception {
+ User user = null;
+ ResponseFormat responseFormat = null;
+ AuditingActionEnum actionName = null;
+
+ // default test
+ Deencapsulation.invoke(testSubject, "handleUserAccessAuditing",
+ new Object[] { User.class, ResponseFormat.class, AuditingActionEnum.class });
+ }
+
+ @Test
+ public void testDeActivateUserMissingID() throws Exception {
+ User modifier = new User();
+ modifier.setUserId(null);
+ String userUniuqeIdToDeactive = "";
+ Either<User, ResponseFormat> result;
+
+ // default test
+ result = testSubject.deActivateUser(modifier, userUniuqeIdToDeactive);
+ }
+
+ @Test
+ public void testDeActivateUserModifierNotFound() throws Exception {
+ User modifier = new User();
+ modifier.setUserId("mockMod");
+ String userUniuqeIdToDeactive = "";
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.right(ActionStatus.USER_NOT_FOUND);
+ Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value);
+
+ // default test
+ result = testSubject.deActivateUser(modifier, userUniuqeIdToDeactive);
+ }
+
+ @Test
+ public void testDeActivateUserModNotAdmin() throws Exception {
+
+ User modifier = new User();
+ modifier.setUserId("mockMod");
+ modifier.setRole(UserRoleEnum.DESIGNER.getName());
+ String userUniuqeIdToDeactive = "";
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value);
+
+ // default test
+ result = testSubject.deActivateUser(modifier, userUniuqeIdToDeactive);
+ }
+
+ @Test
+ public void testDeActivateUserDeacUserNotFound() throws Exception {
+
+ User modifier = new User();
+ modifier.setUserId("mockMod");
+ modifier.setRole(UserRoleEnum.ADMIN.getName());
+ String userUniuqeIdToDeactive = "mockDU";
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value);
+ Either<User, ActionStatus> value2 = Either.right(ActionStatus.USER_NOT_FOUND);
+ Mockito.when(userAdminOperation.getUserData("mockDU", false)).thenReturn(value2);
+
+ // default test
+ result = testSubject.deActivateUser(modifier, userUniuqeIdToDeactive);
+ }
+
+ @Test
+ public void testDeActivateUserDeacAndModSame() throws Exception {
+
+ User modifier = new User();
+ modifier.setUserId("mockMod");
+ modifier.setRole(UserRoleEnum.ADMIN.getName());
+ String userUniuqeIdToDeactive = "mockMod";
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value);
+ Either<User, ActionStatus> value2 = Either.left(modifier);
+ Mockito.when(userAdminOperation.getUserData("mockDU", false)).thenReturn(value2);
+
+ // default test
+ result = testSubject.deActivateUser(modifier, userUniuqeIdToDeactive);
+ }
+
+ @Test
+ public void testDeActivateUserAlreadyInactive() throws Exception {
+
+ User modifier = new User();
+ modifier.setUserId("mockMod");
+ modifier.setRole(UserRoleEnum.ADMIN.getName());
+ String userUniuqeIdToDeactive = "mockDU";
+ User deacUser = new User();
+ deacUser.setStatus(UserStatusEnum.INACTIVE);
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value);
+ Either<User, ActionStatus> value2 = Either.left(deacUser);
+ Mockito.when(userAdminOperation.getUserData("mockDU", false)).thenReturn(value2);
+
+ // default test
+ result = testSubject.deActivateUser(modifier, userUniuqeIdToDeactive);
+ }
+
+ @Test
+ public void testDeActivateUserFailToGetTasks() throws Exception {
+
+ User modifier = new User();
+ modifier.setUserId("mockMod");
+ modifier.setRole(UserRoleEnum.ADMIN.getName());
+ String userUniuqeIdToDeactive = "mockDU";
+ User deacUser = new User();
+ deacUser.setStatus(UserStatusEnum.ACTIVE);
+ deacUser.setRole(UserRoleEnum.DESIGNER.name());
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value);
+ Either<User, ActionStatus> value2 = Either.left(deacUser);
+ Mockito.when(userAdminOperation.getUserData("mockDU", false)).thenReturn(value2);
+ Either<List<Edge>, StorageOperationStatus> value3 = Either.right(StorageOperationStatus.INCONSISTENCY);
+ Mockito.when(userAdminOperation.getUserPendingTasksList(Mockito.any(), Mockito.any())).thenReturn(value3);
+
+ // default test
+ result = testSubject.deActivateUser(modifier, userUniuqeIdToDeactive);
+ }
+
+ @Test
+ public void testDeActivateUserWithPendingTasks() throws Exception {
+
+ User modifier = new User();
+ modifier.setUserId("mockMod");
+ modifier.setRole(UserRoleEnum.ADMIN.getName());
+ String userUniuqeIdToDeactive = "mockDU";
+ User deacUser = new User();
+ deacUser.setStatus(UserStatusEnum.ACTIVE);
+ deacUser.setRole(UserRoleEnum.DESIGNER.name());
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value);
+ Either<User, ActionStatus> value2 = Either.left(deacUser);
+ Mockito.when(userAdminOperation.getUserData("mockDU", false)).thenReturn(value2);
+ LinkedList<Edge> a = new LinkedList<>();
+ a.add(new DetachedEdge(userUniuqeIdToDeactive, userUniuqeIdToDeactive, new HashMap<>(),
+ Pair.with("dsfds", "dsfds"), Pair.with("dsfds", "dsfds")));
+ Either<List<Edge>, StorageOperationStatus> value3 = Either.left(a);
+ Mockito.when(userAdminOperation.getUserPendingTasksList(Mockito.any(), Mockito.any())).thenReturn(value3);
+
+ // default test
+ result = testSubject.deActivateUser(modifier, userUniuqeIdToDeactive);
+ }
+
+ @Test
+ public void testDeActivateUserDeacFail() throws Exception {
+
+ User modifier = new User();
+ modifier.setUserId("mockMod");
+ modifier.setRole(UserRoleEnum.ADMIN.getName());
+ String userUniuqeIdToDeactive = "mockDU";
+ User deacUser = new User();
+ deacUser.setStatus(UserStatusEnum.ACTIVE);
+ deacUser.setRole(UserRoleEnum.DESIGNER.name());
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value);
+ Either<User, ActionStatus> value2 = Either.left(deacUser);
+ Mockito.when(userAdminOperation.getUserData("mockDU", false)).thenReturn(value2);
+ Either<List<Edge>, StorageOperationStatus> value3 = Either.left(new LinkedList<>());
+ Mockito.when(userAdminOperation.getUserPendingTasksList(Mockito.any(), Mockito.any())).thenReturn(value3);
+ Either<User, StorageOperationStatus> value4 = Either.right(StorageOperationStatus.BAD_REQUEST);
+ Mockito.when(userAdminOperation.deActivateUser(deacUser)).thenReturn(value4);
+ // default test
+ result = testSubject.deActivateUser(modifier, userUniuqeIdToDeactive);
+ }
+
+ @Test
+ public void testDeActivateUser() throws Exception {
+
+ User modifier = new User();
+ modifier.setUserId("mockMod");
+ modifier.setRole(UserRoleEnum.ADMIN.getName());
+ String userUniuqeIdToDeactive = "mockDU";
+ User deacUser = new User();
+ deacUser.setStatus(UserStatusEnum.ACTIVE);
+ deacUser.setRole(UserRoleEnum.DESIGNER.name());
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(modifier);
+ Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value);
+ Either<User, ActionStatus> value2 = Either.left(deacUser);
+ Mockito.when(userAdminOperation.getUserData("mockDU", false)).thenReturn(value2);
+ Either<List<Edge>, StorageOperationStatus> value3 = Either.left(new LinkedList<>());
+ Mockito.when(userAdminOperation.getUserPendingTasksList(Mockito.any(), Mockito.any())).thenReturn(value3);
+ Either<User, StorageOperationStatus> value4 = Either.left(deacUser);
+ Mockito.when(userAdminOperation.deActivateUser(deacUser)).thenReturn(value4);
+ // default test
+ result = testSubject.deActivateUser(modifier, userUniuqeIdToDeactive);
+ }
+
+ @Test
+ public void testAuthorizeMissingId() throws Exception {
+ User authUser = new User();
+ Either<User, ResponseFormat> result;
+
+ // default test
+ result = testSubject.authorize(authUser);
+ }
+
+ @Test
+ public void testAuthorizeFail1() throws Exception {
+ User authUser = new User();
+ authUser.setUserId("mockAU");
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.right(ActionStatus.USER_NOT_FOUND);
+ Mockito.when(userAdminOperation.getUserData("mockAU", false)).thenReturn(value);
+ // default test
+ result = testSubject.authorize(authUser);
+ }
+
+ @Test
+ public void testAuthorizeFail2() throws Exception {
+ User authUser = new User();
+ authUser.setUserId("mockAU");
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.right(ActionStatus.AAI_ARTIFACT_GENERATION_FAILED);
+ Mockito.when(userAdminOperation.getUserData("mockAU", false)).thenReturn(value);
+ // default test
+ result = testSubject.authorize(authUser);
+ }
+
+ @Test
+ public void testAuthorizeFail3() throws Exception {
+ User authUser = new User();
+ authUser.setUserId("mockAU");
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(null);
+ Mockito.when(userAdminOperation.getUserData("mockAU", false)).thenReturn(value);
+ // default test
+ result = testSubject.authorize(authUser);
+ }
+
+ @Test
+ public void testAuthorize4() throws Exception {
+ User authUser = new User();
+ authUser.setUserId("mockAU");
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(authUser);
+ Mockito.when(userAdminOperation.getUserData("mockAU", false)).thenReturn(value);
+ Either<User, StorageOperationStatus> value2 = Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND);
+ Mockito.when(userAdminOperation.updateUserData(Mockito.any(User.class))).thenReturn(value2);
+ // default test
+ User authUser1 = new User();
+ authUser1.setUserId("mockAU");
+ authUser1.setFirstName("mock");
+ authUser1.setLastName("mock");
+ authUser1.setEmail("mock");
+ result = testSubject.authorize(authUser1);
+ }
+
+ @Test
+ public void testAuthorize5() throws Exception {
+ User authUser = new User();
+ authUser.setUserId("mockAU");
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(authUser);
+ Mockito.when(userAdminOperation.getUserData("mockAU", false)).thenReturn(value);
+ Either<User, StorageOperationStatus> value2 = Either.left(authUser);
+ Mockito.when(userAdminOperation.updateUserData(Mockito.any(User.class))).thenReturn(value2);
+ // default test
+ result = testSubject.authorize(authUser);
+ }
+
+ @Test
+ public void testUpdateUserCredentialsMissingId() throws Exception {
+ User updatedUserCred = new User();
+ updatedUserCred.setUserId(null);
+ Either<User, ResponseFormat> result;
+
+ // default test
+ result = testSubject.updateUserCredentials(updatedUserCred);
+ }
+
+ @Test
+ public void testUpdateUserCredentialsFailedToGet() throws Exception {
+ User updatedUserCred = new User();
+ updatedUserCred.setUserId("mock");
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.right(ActionStatus.USER_NOT_FOUND);
+ Mockito.when(userAdminOperation.getUserData("mock", false)).thenReturn(value);
+
+ // default test
+ result = testSubject.updateUserCredentials(updatedUserCred);
+ }
+
+ @Test
+ public void testUpdateUserCredentialsFailedToGet2() throws Exception {
+ User updatedUserCred = new User();
+ updatedUserCred.setUserId("mock");
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.right(ActionStatus.ADDITIONAL_INFORMATION_ALREADY_EXISTS);
+ Mockito.when(userAdminOperation.getUserData("mock", false)).thenReturn(value);
+
+ // default test
+ result = testSubject.updateUserCredentials(updatedUserCred);
+ }
+
+ @Test
+ public void testUpdateUserCredentialsFailedToGet3() throws Exception {
+ User updatedUserCred = new User();
+ updatedUserCred.setUserId("mock");
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(null);
+ Mockito.when(userAdminOperation.getUserData("mock", false)).thenReturn(value);
+
+ // default test
+ result = testSubject.updateUserCredentials(updatedUserCred);
+ }
+
+ @Test
+ public void testUpdateUserCredentialsFailToUpdate() throws Exception {
+ User updatedUserCred = new User();
+ updatedUserCred.setUserId("mock");
+ Either<User, ResponseFormat> result;
+
+ User updatedUserCred1 = new User();
+ updatedUserCred.setUserId("mock1");
+ updatedUserCred.setFirstName("mock1");
+ updatedUserCred.setLastName("mock1");
+ updatedUserCred.setEmail("mock1");
+ updatedUserCred.setLastLoginTime(435324L);
+
+ Either<User, ActionStatus> value = Either.left(updatedUserCred1);
+ Mockito.when(userAdminOperation.getUserData("mock1", false)).thenReturn(value);
+
+ Either<User, StorageOperationStatus> value2 = Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND);
+ Mockito.when(userAdminOperation.updateUserData(Mockito.any(User.class))).thenReturn(value2);
+ // default test
+
+ result = testSubject.updateUserCredentials(updatedUserCred);
+ }
+
+ @Test
+ public void testUpdateUserCredentials() throws Exception {
+ User updatedUserCred = new User();
+ updatedUserCred.setUserId("mock");
+ Either<User, ResponseFormat> result;
+
+ Either<User, ActionStatus> value = Either.left(updatedUserCred);
+ Mockito.when(userAdminOperation.getUserData("mock", false)).thenReturn(value);
+
+ Either<User, StorageOperationStatus> value2 = Either.left(updatedUserCred);
+ Mockito.when(userAdminOperation.updateUserData(Mockito.any(User.class))).thenReturn(value2);
+
+ // default test
+ result = testSubject.updateUserCredentials(updatedUserCred);
+ }
+
+ @Test
+ public void testGetPendingUserPendingTasksWithCommit() throws Exception {
+ Either<List<Edge>, StorageOperationStatus> result;
+ User user = new User();
+ for (UserRoleEnum iterable_element : UserRoleEnum.values()) {
+ user.setRole(iterable_element.name());
+ result = Deencapsulation.invoke(testSubject, "getPendingUserPendingTasksWithCommit", user);
+ }
+
+ }
+
+ @Test
+ public void testGetUserPendingTaskStatusByRole() throws Exception {
+ String result;
+ for (UserRoleEnum iterable_element : UserRoleEnum.values()) {
+ result = Deencapsulation.invoke(testSubject, "getUserPendingTaskStatusByRole", iterable_element);
+ }
+ }
+} \ No newline at end of file