diff options
author | Roberto E. Escobar | 2013-04-10 01:29:35 +0000 |
---|---|---|
committer | donald.g.dunne | 2013-04-12 22:07:11 +0000 |
commit | c14de5ae559f65a71b6f6389e8ee5fce91136699 (patch) | |
tree | 7b9cdbb2963f68675aad4811eae1b89d4ce528ff /plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/util | |
parent | 27ce368f4e9347e6c5d385045d2bd658ce8c9a3e (diff) | |
download | org.eclipse.osee-c14de5ae559f65a71b6f6389e8ee5fce91136699.tar.gz org.eclipse.osee-c14de5ae559f65a71b6f6389e8ee5fce91136699.tar.xz org.eclipse.osee-c14de5ae559f65a71b6f6389e8ee5fce91136699.zip |
bug[ats_SM0J7]: Fix AtsUsers management
Refactored code so we can better control
ats user management class initialization.
Updated code to use IAtsClient api and request
IAtsUserAdmin instead of using static utility
classes.
Removed user caching from ats.
Change-Id: I3f0aa04c8ea253fc96684dca305bba76636cd0d7
Diffstat (limited to 'plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/util')
3 files changed, 98 insertions, 18 deletions
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/util/AtsCoreClient_Util_Suite.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/util/AtsCoreClient_Util_Suite.java index c719757d9d6..fcd7480bd43 100644 --- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/util/AtsCoreClient_Util_Suite.java +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/util/AtsCoreClient_Util_Suite.java @@ -20,7 +20,7 @@ import org.junit.runners.Suite; * @author Donald G. Dunne */ @RunWith(Suite.class) -@Suite.SuiteClasses({AtsUserTest.class, CopyActionDetailsTest.class}) +@Suite.SuiteClasses({AtsUsersTest.class, AtsUserTest.class, CopyActionDetailsTest.class}) public class AtsCoreClient_Util_Suite { @BeforeClass public static void setUp() throws Exception { diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/util/AtsUserTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/util/AtsUserTest.java index 5890e6296e2..fc316d25187 100644 --- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/util/AtsUserTest.java +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/util/AtsUserTest.java @@ -16,12 +16,13 @@ import java.util.HashSet; import junit.framework.Assert; import org.eclipse.osee.ats.api.user.IAtsUser; import org.eclipse.osee.ats.client.demo.DemoUsers; -import org.eclipse.osee.ats.core.client.util.AtsUser; -import org.eclipse.osee.ats.core.client.util.AtsUsersClient; +import org.eclipse.osee.ats.client.integration.tests.AtsClientService; + import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Collections; import org.eclipse.osee.framework.skynet.core.User; import org.eclipse.osee.framework.skynet.core.UserManager; +import org.junit.Before; import org.mockito.Mockito; /** @@ -29,31 +30,32 @@ import org.mockito.Mockito; */ public class AtsUserTest { + private IAtsUser atsUser; + private User user; + + @Before + public void setUp() throws OseeCoreException { + user = UserManager.getUser(); + atsUser = AtsClientService.get().getUserAdmin().getCurrentUser(); + } + @org.junit.Test public void testGetUserId() throws OseeCoreException { - User user = UserManager.getUser(); - AtsUser atsUser = new AtsUser(user); Assert.assertEquals(user.getUserId(), atsUser.getUserId()); } @org.junit.Test - public void testGetName() throws OseeCoreException { - User user = UserManager.getUser(); - AtsUser atsUser = new AtsUser(user); + public void testGetName() { Assert.assertEquals(user.getName(), atsUser.getName()); } @org.junit.Test public void testGetEmail() throws OseeCoreException { - User user = UserManager.getUser(); - AtsUser atsUser = new AtsUser(user); Assert.assertEquals(user.getEmail(), atsUser.getEmail()); } @org.junit.Test public void testEquals() throws OseeCoreException { - User user = UserManager.getUser(); - AtsUser atsUser = new AtsUser(user); Assert.assertEquals(atsUser, user); IAtsUser atsUser2 = Mockito.mock(IAtsUser.class); @@ -65,16 +67,16 @@ public class AtsUserTest { @org.junit.Test public void testRemove() throws OseeCoreException { Collection<IAtsUser> assignees = new HashSet<IAtsUser>(); - assignees.add(AtsUsersClient.getUserFromToken(DemoUsers.Alex_Kay)); - assignees.add(AtsUsersClient.getUserFromToken(DemoUsers.Joe_Smith)); + assignees.add(AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Alex_Kay)); + assignees.add(AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Joe_Smith)); Assert.assertTrue(Collections.isEqual( assignees, - Arrays.asList(AtsUsersClient.getUserFromToken(DemoUsers.Alex_Kay), - AtsUsersClient.getUserFromToken(DemoUsers.Joe_Smith)))); + Arrays.asList(AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Alex_Kay), + AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Joe_Smith)))); - assignees.remove(AtsUsersClient.getUser()); + assignees.remove(AtsClientService.get().getUserAdmin().getCurrentUser()); Assert.assertTrue(Collections.isEqual(assignees, - Arrays.asList(AtsUsersClient.getUserFromToken(DemoUsers.Alex_Kay)))); + Arrays.asList(AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Alex_Kay)))); } } diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/util/AtsUsersTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/util/AtsUsersTest.java new file mode 100644 index 00000000000..0e0cb18f201 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/util/AtsUsersTest.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ats.client.integration.tests.ats.core.client.util; + +import junit.framework.Assert; +import org.eclipse.osee.ats.api.user.IAtsUser; +import org.eclipse.osee.ats.client.integration.tests.AtsClientService; +import org.eclipse.osee.ats.core.users.AtsCoreUsers; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.core.exception.UserNotInDatabase; +import org.eclipse.osee.framework.skynet.core.User; +import org.eclipse.osee.framework.skynet.core.UserManager; +import org.junit.Test; + +/** + * @author Donald G. Dunne + */ +public class AtsUsersTest { + + @Test + public void testGetUser() throws OseeCoreException { + Assert.assertEquals(AtsCoreUsers.SYSTEM_USER, + AtsClientService.get().getUserAdmin().getUserById(AtsCoreUsers.SYSTEM_USER.getUserId())); + Assert.assertEquals(AtsCoreUsers.GUEST_USER, + AtsClientService.get().getUserAdmin().getUserById(AtsCoreUsers.GUEST_USER.getUserId())); + Assert.assertEquals(AtsCoreUsers.UNASSIGNED_USER, + AtsClientService.get().getUserAdmin().getUserById(AtsCoreUsers.UNASSIGNED_USER.getUserId())); + } + + @Test(expected = UserNotInDatabase.class) + public void testGetUserException() throws OseeCoreException { + Assert.assertNull(AtsClientService.get().getUserAdmin().getUserById("2345")); + } + + @Test + public void testGetUserWithNull() throws OseeCoreException { + Assert.assertNull(AtsClientService.get().getUserAdmin().getUserById(null)); + } + + @Test + public void testGetGuestUser() { + Assert.assertEquals(AtsCoreUsers.GUEST_USER, AtsCoreUsers.GUEST_USER); + } + + @Test + public void testGetSystemUser() { + Assert.assertEquals(AtsCoreUsers.SYSTEM_USER, AtsCoreUsers.SYSTEM_USER); + } + + @Test + public void testGetUnAssigned() { + Assert.assertEquals(AtsCoreUsers.UNASSIGNED_USER, AtsCoreUsers.UNASSIGNED_USER); + } + + @Test + public void testGetCurrentUser() throws OseeCoreException { + User currentUser = UserManager.getUser(); + + Assert.assertEquals(currentUser, AtsClientService.get().getUserAdmin().getCurrentOseeUser()); + + IAtsUser atsUser = AtsClientService.get().getUserAdmin().getUserById(currentUser.getUserId()); + + Assert.assertEquals(currentUser.getUserId(), atsUser.getUserId()); + Assert.assertEquals(currentUser.getEmail(), atsUser.getEmail()); + Assert.assertEquals(currentUser.isActive(), atsUser.isActive()); + Assert.assertEquals(currentUser.getName(), atsUser.getName()); + Assert.assertEquals(atsUser, AtsClientService.get().getUserAdmin().getCurrentUser()); + } + +} |