From 44c763981f2e368184d6461dd18529545c3b29aa Mon Sep 17 00:00:00 2001 From: Tal Gitelman Date: Wed, 23 May 2018 16:17:45 +0300 Subject: new unit tests for sdc-be Change-Id: I5a7cf20a9157432fd2bf72d24fa48bc5789ad3b4 Issue-ID: SDC-1333 Signed-off-by: Tal Gitelman --- .../openecomp/sdc/be/user/UserBusinessLogic.java | 26 +- .../src/test/java/org/openecomp/sdc/TestSuite.java | 11 - .../test/java/org/openecomp/sdc/be/TestSuite.java | 11 - .../java/org/openecomp/sdc/be/dto/TestSuite.java | 11 - .../java/org/openecomp/sdc/be/ecomp/TestSuite.java | 11 - .../tosca/model/ToscaInterfaceDefinitionTest.java | 52 + .../be/tosca/model/ToscaInterfaceNodeTypeTest.java | 101 ++ .../ToscaLifecycleOperationDefinitionTest.java | 100 ++ .../sdc/be/user/UserAdminValidatorTest.java | 51 + .../sdc/be/user/UserBusinessLogicTest.java | 1006 ++++++++++++++++++++ 10 files changed, 1322 insertions(+), 58 deletions(-) delete mode 100644 catalog-be/src/test/java/org/openecomp/sdc/TestSuite.java delete mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/TestSuite.java delete mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/dto/TestSuite.java delete mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/TestSuite.java create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceDefinitionTest.java create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceNodeTypeTest.java create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinitionTest.java create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminValidatorTest.java create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/user/UserBusinessLogicTest.java 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 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 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 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 result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getOperations(); + } + + @Test + public void testSetOperations() throws Exception { + ToscaInterfaceDefinition testSubject; + Map 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 result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getOperations(); + } + + @Test + public void testSetOperations() throws Exception { + ToscaInterfaceNodeType testSubject; + Map 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 result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getInputs(); + } + + @Test + public void testSetInputs() throws Exception { + ToscaLifecycleOperationDefinition testSubject; + Map 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 result; + + // default test + result = testSubject.getUser(userId, inTransaction); + } + + @Test + public void testCreateUser() throws Exception { + User modifier = new User(); + User newUser = new User(); + Either result; + + // default test + result = testSubject.createUser(modifier, newUser); + } + + @Test + public void testCreateUserErrorGetUser() throws Exception { + User modifier = new User(); + User newUser = new User(); + Either result; + + Either 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 result; + + User userFromDb = new User(); + userFromDb.setRole(UserRoleEnum.DESIGNER.getName()); + Either 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 result; + + User userFromDb = new User(); + userFromDb.setRole(UserRoleEnum.ADMIN.getName()); + Either value = Either.left(userFromDb); + Either 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 result; + + User userFromDb = new User(); + userFromDb.setRole(UserRoleEnum.ADMIN.getName()); + Either value = Either.left(userFromDb); + Either 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 result; + + modifier.setUserId("mockModif"); + newUser.setUserId("mockNewUs"); + + User userFromDb = new User(); + userFromDb.setRole(UserRoleEnum.ADMIN.getName()); + Either value = Either.left(userFromDb); + + User userFromDb2 = new User(); + Either 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 result; + + modifier.setUserId("mockModif"); + newUser.setUserId("mockNewUs"); + newUser.setEmail("mock"); + + User userFromDbAdmin = new User(); + userFromDbAdmin.setRole(UserRoleEnum.ADMIN.getName()); + Either value = Either.left(userFromDbAdmin); + + User userFromDbNew = new User(); + userFromDbNew.setStatus(UserStatusEnum.INACTIVE); + Either 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 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 value = Either.left(userFromDbAdmin); + + User userFromDbNew = new User(); + userFromDbNew.setStatus(UserStatusEnum.INACTIVE); + Either 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 result; + + modifier.setUserId("mockModif"); + newUser.setUserId("mockNewUs"); + newUser.setEmail("mock@mock.mock"); + newUser.setUserId(""); + User userFromDbAdmin = new User(); + userFromDbAdmin.setRole(UserRoleEnum.ADMIN.getName()); + Either value = Either.left(userFromDbAdmin); + + User userFromDbNew = new User(); + userFromDbNew.setStatus(UserStatusEnum.INACTIVE); + Either 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 result; + + modifier.setUserId("mockModif"); + newUser.setUserId("mockNewUs"); + newUser.setEmail("mock@mock.mock"); + + User userFromDbAdmin = new User(); + userFromDbAdmin.setRole(UserRoleEnum.ADMIN.getName()); + Either value = Either.left(userFromDbAdmin); + + User userFromDbNew = new User(); + userFromDbNew.setStatus(UserStatusEnum.INACTIVE); + Either value2 = Either.left(userFromDbNew); + Mockito.when(userAdminOperation.getUserData("mockModif", false)).thenReturn(value); + Mockito.when(userAdminOperation.getUserData("mockNewUs", false)).thenReturn(value2); + Either 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 result; + + modifier.setUserId("mockModif"); + newUser.setUserId("mockNewUs"); + newUser.setEmail("mock@mock.mock"); + + User userFromDbAdmin = new User(); + userFromDbAdmin.setRole(UserRoleEnum.ADMIN.getName()); + Either value = Either.left(userFromDbAdmin); + + User userFromDbNew = new User(); + userFromDbNew.setStatus(UserStatusEnum.INACTIVE); + Either value2 = Either.left(userFromDbNew); + Mockito.when(userAdminOperation.getUserData("mockModif", false)).thenReturn(value); + Mockito.when(userAdminOperation.getUserData("mockNewUs", false)).thenReturn(value2); + Either 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 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 result; + + Either 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 result; + + Either 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 result; + + Either 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 result; + + Either value = Either.left(modifier); + Either 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 result; + + Either 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 result; + + User updatedUser = new User(); + updatedUser.setUserId(userIdToUpdate); + updatedUser.setRole(UserRoleEnum.TESTER.getName()); + + Either value = Either.left(modifier); + Either value2 = Either.left(updatedUser); + Mockito.when(userAdminOperation.getUserData(modifier.getUserId(), false)).thenReturn(value); + Mockito.when(userAdminOperation.getUserData(userIdToUpdate, false)).thenReturn(value2); + + Either, 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 result; + + User updatedUser = new User(); + updatedUser.setUserId(userIdToUpdate); + updatedUser.setRole(UserRoleEnum.TESTER.getName()); + + Either value = Either.left(modifier); + Either value2 = Either.left(updatedUser); + Mockito.when(userAdminOperation.getUserData(modifier.getUserId(), false)).thenReturn(value); + Mockito.when(userAdminOperation.getUserData(userIdToUpdate, false)).thenReturn(value2); + List list = new LinkedList<>(); + + list.add(new DetachedEdge("sdas", "fdfs", new HashMap<>(), Pair.with("sadas", "sadasd"), + Pair.with("sadas", "sadasd"))); + Either, 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 result; + + User updatedUser = new User(); + updatedUser.setUserId(userIdToUpdate); + updatedUser.setRole(UserRoleEnum.TESTER.getName()); + + Either value = Either.left(modifier); + Either value2 = Either.left(updatedUser); + Mockito.when(userAdminOperation.getUserData(modifier.getUserId(), false)).thenReturn(value); + Mockito.when(userAdminOperation.getUserData(userIdToUpdate, false)).thenReturn(value2); + List list = new LinkedList<>(); + + Either, StorageOperationStatus> value3 = Either.left(list); + Mockito.when(userAdminOperation.getUserPendingTasksList(Mockito.any(), Mockito.any())).thenReturn(value3); + Either 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 result; + + User updatedUser = new User(); + updatedUser.setUserId(userIdToUpdate); + updatedUser.setRole(UserRoleEnum.TESTER.getName()); + + Either value = Either.left(modifier); + Either value2 = Either.left(updatedUser); + Mockito.when(userAdminOperation.getUserData(modifier.getUserId(), false)).thenReturn(value); + Mockito.when(userAdminOperation.getUserData(userIdToUpdate, false)).thenReturn(value2); + List list = new LinkedList<>(); + + Either, StorageOperationStatus> value3 = Either.left(list); + Mockito.when(userAdminOperation.getUserPendingTasksList(Mockito.any(), Mockito.any())).thenReturn(value3); + Either 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, ResponseFormat> result; + + Either, 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, ResponseFormat> result; + + Either, 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 roles = null; + String rolesStr = ""; + Either, ResponseFormat> result; + + // test 1 + modifierAttId = null; + result = testSubject.getUsersList(modifierAttId, roles, rolesStr); + } + + @Test + public void testGetUsersListFail() throws Exception { + String modifierAttId = "mockMod"; + List roles = null; + String rolesStr = ""; + Either, ResponseFormat> result; + + Either 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 roles = null; + String rolesStr = ""; + Either, ResponseFormat> result; + + Either 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 roles = new LinkedList<>(); + String rolesStr = ""; + Either, ResponseFormat> result; + + User a = new User(); + Either value3 = Either.left(a); + Mockito.when(userAdminOperation.getUserData(modifierAttId, false)).thenReturn(value3); + Either, 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 roles = new LinkedList<>(); + String rolesStr = ""; + Either, ResponseFormat> result; + + User a = new User(); + Either value3 = Either.left(a); + Mockito.when(userAdminOperation.getUserData(modifierAttId, false)).thenReturn(value3); + Either, 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 roles = new LinkedList<>(); + roles.add("mock"); + String rolesStr = ""; + Either, ResponseFormat> result; + + User a = new User(); + Either value3 = Either.left(a); + Mockito.when(userAdminOperation.getUserData(modifierAttId, false)).thenReturn(value3); + Either, 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 roles = new LinkedList<>(); + roles.add(UserRoleEnum.DESIGNER.name()); + String rolesStr = ""; + Either, ResponseFormat> result; + + User a = new User(); + Either value3 = Either.left(a); + Mockito.when(userAdminOperation.getUserData(modifierAttId, false)).thenReturn(value3); + Either, 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 result; + + // default test + result = testSubject.deActivateUser(modifier, userUniuqeIdToDeactive); + } + + @Test + public void testDeActivateUserModifierNotFound() throws Exception { + User modifier = new User(); + modifier.setUserId("mockMod"); + String userUniuqeIdToDeactive = ""; + Either result; + + Either 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 result; + + Either 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 result; + + Either value = Either.left(modifier); + Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value); + Either 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 result; + + Either value = Either.left(modifier); + Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value); + Either 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 result; + + Either value = Either.left(modifier); + Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value); + Either 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 result; + + Either value = Either.left(modifier); + Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value); + Either value2 = Either.left(deacUser); + Mockito.when(userAdminOperation.getUserData("mockDU", false)).thenReturn(value2); + Either, 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 result; + + Either value = Either.left(modifier); + Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value); + Either value2 = Either.left(deacUser); + Mockito.when(userAdminOperation.getUserData("mockDU", false)).thenReturn(value2); + LinkedList a = new LinkedList<>(); + a.add(new DetachedEdge(userUniuqeIdToDeactive, userUniuqeIdToDeactive, new HashMap<>(), + Pair.with("dsfds", "dsfds"), Pair.with("dsfds", "dsfds"))); + Either, 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 result; + + Either value = Either.left(modifier); + Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value); + Either value2 = Either.left(deacUser); + Mockito.when(userAdminOperation.getUserData("mockDU", false)).thenReturn(value2); + Either, StorageOperationStatus> value3 = Either.left(new LinkedList<>()); + Mockito.when(userAdminOperation.getUserPendingTasksList(Mockito.any(), Mockito.any())).thenReturn(value3); + Either 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 result; + + Either value = Either.left(modifier); + Mockito.when(userAdminOperation.getUserData("mockMod", false)).thenReturn(value); + Either value2 = Either.left(deacUser); + Mockito.when(userAdminOperation.getUserData("mockDU", false)).thenReturn(value2); + Either, StorageOperationStatus> value3 = Either.left(new LinkedList<>()); + Mockito.when(userAdminOperation.getUserPendingTasksList(Mockito.any(), Mockito.any())).thenReturn(value3); + Either 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 result; + + // default test + result = testSubject.authorize(authUser); + } + + @Test + public void testAuthorizeFail1() throws Exception { + User authUser = new User(); + authUser.setUserId("mockAU"); + Either result; + + Either 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 result; + + Either 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 result; + + Either 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 result; + + Either value = Either.left(authUser); + Mockito.when(userAdminOperation.getUserData("mockAU", false)).thenReturn(value); + Either 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 result; + + Either value = Either.left(authUser); + Mockito.when(userAdminOperation.getUserData("mockAU", false)).thenReturn(value); + Either 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 result; + + // default test + result = testSubject.updateUserCredentials(updatedUserCred); + } + + @Test + public void testUpdateUserCredentialsFailedToGet() throws Exception { + User updatedUserCred = new User(); + updatedUserCred.setUserId("mock"); + Either result; + + Either 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 result; + + Either 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 result; + + Either 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 result; + + User updatedUserCred1 = new User(); + updatedUserCred.setUserId("mock1"); + updatedUserCred.setFirstName("mock1"); + updatedUserCred.setLastName("mock1"); + updatedUserCred.setEmail("mock1"); + updatedUserCred.setLastLoginTime(435324L); + + Either value = Either.left(updatedUserCred1); + Mockito.when(userAdminOperation.getUserData("mock1", false)).thenReturn(value); + + Either 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 result; + + Either value = Either.left(updatedUserCred); + Mockito.when(userAdminOperation.getUserData("mock", false)).thenReturn(value); + + Either 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, 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 -- cgit 1.2.3-korg