From 640a48c2684153ac0cd054a785cbe136ade0dbab Mon Sep 17 00:00:00 2001 From: Angel Avila Date: Wed, 2 Mar 2016 02:58:11 -0700 Subject: refactor[ats_ATS253925]: Change ids in Account from int to Long Change-Id: Ie47850668181faa89d9493ce29c688e1a48c04d6 --- .../META-INF/MANIFEST.MF | 3 +- .../admin/internal/AccountAdminImplTest.java | 362 ++++----------------- .../admin/internal/AccountResolverTest.java | 74 +---- .../account/admin/internal/InternalTestSuite.java | 3 +- .../admin/internal/SubscriptionAdminImplTest.java | 181 ++--------- .../admin/internal/SubscriptionResolverTest.java | 205 ------------ .../internal/validator/UuidValidatorTest.java | 35 -- .../internal/validator/ValidatorTestSuite.java | 1 - .../META-INF/MANIFEST.MF | 1 + .../OSGI-INF/subscriptions.admin.xml | 1 - .../org/eclipse/osee/account/admin/Account.java | 2 +- .../eclipse/osee/account/admin/AccountAdmin.java | 50 +-- .../osee/account/admin/AccountPreferences.java | 2 +- .../eclipse/osee/account/admin/AccountSession.java | 2 +- .../eclipse/osee/account/admin/Subscription.java | 6 +- .../osee/account/admin/SubscriptionAdmin.java | 31 +- .../osee/account/admin/SubscriptionGroup.java | 3 +- .../osee/account/admin/ds/AccountStorage.java | 35 +- .../osee/account/admin/ds/SubscriptionStorage.java | 26 +- .../account/admin/internal/AccountAdminImpl.java | 212 +++--------- .../account/admin/internal/AccountResolver.java | 17 - .../admin/internal/SubscriptionAdminImpl.java | 98 +----- .../admin/internal/SubscriptionResolver.java | 56 +--- .../osee/account/rest/client/AccountClient.java | 16 +- .../rest/client/internal/AccountClientImpl.java | 20 +- .../META-INF/MANIFEST.MF | 3 +- .../osee/account/rest/model/AccountActiveData.java | 6 +- .../osee/account/rest/model/AccountInfoData.java | 6 +- .../account/rest/model/AccountPreferencesData.java | 6 +- .../account/rest/model/AccountSessionData.java | 6 +- .../rest/model/AccountSessionDetailsData.java | 6 +- .../account/rest/model/SubscriptionGroupData.java | 10 +- .../account/rest/model/SubscriptionGroupId.java | 57 ++++ .../rest/internal/AccountActiveResourceTest.java | 5 +- .../account/rest/internal/AccountDataUtilTest.java | 16 +- .../osee/account/rest/internal/AccountOpsTest.java | 83 +++-- .../internal/AccountPreferencesResourceTest.java | 10 +- .../account/rest/internal/AccountResourceTest.java | 27 +- .../rest/internal/AccountSessionsResourceTest.java | 6 +- .../rest/internal/AccountsResourceTest.java | 36 +- .../rest/internal/SubscriptionsResourceTest.java | 112 +++---- .../rest/internal/UnsubscribeResourceTest.java | 25 +- .../META-INF/MANIFEST.MF | 1 + .../rest/internal/AccountActiveResource.java | 11 +- .../account/rest/internal/AccountDataUtil.java | 2 +- .../osee/account/rest/internal/AccountOps.java | 58 ++-- .../rest/internal/AccountPreferencesResource.java | 11 +- .../account/rest/internal/AccountResource.java | 32 +- .../rest/internal/AccountSessionsResource.java | 7 +- .../account/rest/internal/AccountsResource.java | 38 ++- .../rest/internal/JaxRsAuthenticatorImpl.java | 8 +- .../rest/internal/SubscriptionsResource.java | 55 ++-- .../account/rest/internal/UnsubscribeResource.java | 8 +- .../osee/ats/core/util/AtsCoreServiceImplTest.java | 8 +- .../osee/ats/core/util/AtsCoreServiceImpl.java | 7 +- .../osee/disposition/rest/DispoConstants.java | 7 +- .../disposition/rest/internal/OrcsStorageImpl.java | 12 +- .../META-INF/MANIFEST.MF | 1 - .../osee/framework/core/data/ArtifactId.java | 7 +- .../osee/framework/core/data/IArtifactToken.java | 5 +- .../osee/framework/core/data/TokenFactory.java | 11 +- .../framework/skynet/core/artifact/Artifact.java | 7 +- .../ui/skynet/blam/operation/EmailGroupsData.java | 2 +- .../META-INF/MANIFEST.MF | 1 + .../security/oauth2/provider/ClientProvider.java | 2 +- .../provider/adapters/ApplicationClient.java | 2 +- .../provider/adapters/ClientProviderImpl.java | 8 +- .../provider/endpoints/ImplicitGrantEndpoint.java | 2 + .../jaxrs/server/security/JaxRsOAuthStorage.java | 5 +- .../osee/jaxrs/server/security/OAuthClient.java | 2 +- .../integration/JdbcJaxRsOAuthStorageTest.java | 97 +++--- .../admin/integration/OrcsAccountStorageTest.java | 96 ++---- .../integration/OrcsSubscriptionStorageTest.java | 55 ++-- .../admin/internal/SubscriptionUtilTest.java | 11 +- .../account/admin/internal/AccountArtifact.java | 2 +- .../account/admin/internal/AccountFactory.java | 9 +- .../admin/internal/AccountPreferencesArtifact.java | 2 +- .../internal/AccountSessionDatabaseStore.java | 7 +- .../account/admin/internal/AccountSessionImpl.java | 8 +- .../admin/internal/AccountSessionStorage.java | 3 +- .../internal/AccountSubscriptionGroupImpl.java | 11 +- .../account/admin/internal/BootstrapAccount.java | 2 +- .../account/admin/internal/OrcsAccountStorage.java | 100 ++---- .../admin/internal/OrcsSubscriptionStorage.java | 105 +++--- .../account/admin/internal/SubscriptionUtil.java | 34 +- .../admin/internal/oauth/ClientArtifact.java | 10 +- .../admin/internal/oauth/ClientStorage.java | 40 +-- .../internal/oauth/JdbcJaxRsOAuthStorage.java | 40 ++- .../account/admin/internal/oauth/OAuthTypes.java | 14 +- .../orcs/core/internal/artifact/ArtifactImpl.java | 12 - .../internal/proxy/impl/ArtifactReadOnlyImpl.java | 17 +- .../internal/transaction/TxDataLoaderImpl.java | 6 +- .../osee/orcs/db/intergration/LoaderTest.java | 94 +++--- .../org/eclipse/osee/orcs/utility/OrcsUtil.java | 57 ---- .../tests/performance/AccountClientTest.java | 67 +--- 95 files changed, 993 insertions(+), 2088 deletions(-) delete mode 100644 plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/SubscriptionResolverTest.java delete mode 100644 plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/validator/UuidValidatorTest.java create mode 100644 plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/SubscriptionGroupId.java delete mode 100644 plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/utility/OrcsUtil.java diff --git a/plugins/org.eclipse.osee.account.admin.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.account.admin.test/META-INF/MANIFEST.MF index 6faba180608..11c6b240d97 100644 --- a/plugins/org.eclipse.osee.account.admin.test/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.account.admin.test/META-INF/MANIFEST.MF @@ -6,7 +6,8 @@ Bundle-Version: 0.24.0.qualifier Fragment-Host: org.eclipse.osee.account.admin Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-Vendor: Eclipse Open System Engineering Environment -Import-Package: org.hamcrest.core, +Import-Package: org.eclipse.osee.orcs.utility, + org.hamcrest.core, org.junit, org.junit.rules, org.junit.runner, diff --git a/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/AccountAdminImplTest.java b/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/AccountAdminImplTest.java index 126e68cd98c..0ce1dca0c60 100644 --- a/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/AccountAdminImplTest.java +++ b/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/AccountAdminImplTest.java @@ -41,11 +41,11 @@ import org.eclipse.osee.account.admin.internal.validator.Validator; import org.eclipse.osee.authentication.admin.AuthenticatedUser; import org.eclipse.osee.authentication.admin.AuthenticationAdmin; import org.eclipse.osee.authentication.admin.AuthenticationRequest; -import org.eclipse.osee.framework.jdk.core.type.Identifiable; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.ResultSet; import org.eclipse.osee.framework.jdk.core.type.ResultSets; -import org.eclipse.osee.framework.jdk.core.util.GUID; import org.eclipse.osee.logger.Log; import org.junit.Before; import org.junit.Rule; @@ -64,7 +64,6 @@ import org.mockito.Mockito; public class AccountAdminImplTest { private static final long ID = 123121412L; - private static final String GUID_STRING = GUID.create(); private static final String USERNAME = "atest"; private static final String EMAIL = "atest@email.com"; private static final String NAME = "myName"; @@ -81,13 +80,14 @@ public class AccountAdminImplTest { @Mock private Account account; @Mock private AccountSession accountSession; @Mock private AccountPreferences preferences; - @Mock private Identifiable newAccount; @Mock private AuthenticatedUser authenticatedUser; @Captor private ArgumentCaptor> newPrefsCaptor; @Captor private ArgumentCaptor tokenCaptor; @Captor private ArgumentCaptor authenticationRequestCaptor; // @formatter:on + private final ArtifactId newAccountId = TokenFactory.createArtifactId(123121412L); + private AccountAdminImpl accountAdmin; @Before @@ -100,7 +100,7 @@ public class AccountAdminImplTest { accountAdmin.setAuthenticationAdmin(authenticationAdmin); accountAdmin.start(Collections. emptyMap()); - when(newAccount.getGuid()).thenReturn(GUID_STRING); + when(account.getId()).thenReturn(newAccountId.getUuid()); } @Test @@ -109,53 +109,11 @@ public class AccountAdminImplTest { verify(storage).getAllAccounts(); } - @Test - public void testGetAccountByIdWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("id cannot be null"); - accountAdmin.getAccountById(null); - } - - @Test - public void testGetById() { - accountAdmin.getAccountById(newAccount); - - verify(storage).getAccountByGuid(GUID_STRING); - } - - @Test - public void testGetAccountByGuidWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("guid cannot be null"); - accountAdmin.getAccountByGuid(null); - } - - @Test - public void testGetByGuiId() { - accountAdmin.getAccountByGuid(GUID_STRING); - - verify(storage).getAccountByGuid(GUID_STRING); - } - @Test public void testGetAccountById() { - accountAdmin.getAccountById(ID); - - verify(storage).getAccountByLocalId(ID); - } + accountAdmin.getAccountById(newAccountId); - @Test - public void testGetAccountByUserNameWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("username cannot be null"); - accountAdmin.getAccountByUserName(null); - } - - @Test - public void testGetByUserName() { - accountAdmin.getAccountByUserName(USERNAME); - - verify(storage).getAccountByUserName(USERNAME); + verify(storage).getAccountById(newAccountId); } @Test @@ -172,53 +130,11 @@ public class AccountAdminImplTest { verify(storage).getAccountByEmail(EMAIL); } - @Test - public void testGetAccountByNameWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("name cannot be null"); - accountAdmin.getAccountByName(null); - } - - @Test - public void testGetByName() { - accountAdmin.getAccountByName(NAME); - - verify(storage).getAccountByName(NAME); - } - - @Test - public void testGetAccountPrefsByUuidWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("guid cannot be null"); - accountAdmin.getAccountPreferencesByGuid(null); - } - - @Test - public void testGetAccountPrefsByUuid() { - accountAdmin.getAccountPreferencesByGuid(GUID_STRING); - - verify(storage).getAccountPreferencesByGuid(GUID_STRING); - } - - @Test - public void testGetAccountPrefsByIdWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("id cannot be null"); - accountAdmin.getAccountPreferencesById(null); - } - @Test public void testGetAccountPrefsById() { - accountAdmin.getAccountPreferencesById(newAccount); + accountAdmin.getAccountPreferencesById(newAccountId); - verify(storage).getAccountPreferencesByGuid(GUID_STRING); - } - - @Test - public void testGetAccountPreferencesById() { - accountAdmin.getAccountPreferencesById(ID); - - verify(storage).getAccountPreferencesById(ID); + verify(storage).getAccountPreferencesById(newAccountId); } @Test @@ -239,59 +155,45 @@ public class AccountAdminImplTest { verify(storage).createAccount(request); } - @Test - public void testSetActiveIdWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("account id cannot be null"); - accountAdmin.setActive(nullID(), true); - } - @Test public void testSetActiveModified() { ResultSet resultSet = ResultSets.singleton(account); - when(storage.getAccountByGuid(GUID_STRING)).thenReturn(resultSet); + when(storage.getAccountById(newAccountId)).thenReturn(resultSet); when(account.isActive()).thenReturn(true); - boolean modified = accountAdmin.setActive(newAccount, false); + boolean modified = accountAdmin.setActive(newAccountId, false); assertTrue(modified); - verify(storage).getAccountByGuid(GUID_STRING); - verify(storage).setActive(account, false); + verify(storage).getAccountById(newAccountId); + verify(storage).setActive(newAccountId, false); } @Test public void testSetActiveNotModified() { ResultSet resultSet = ResultSets.singleton(account); - when(storage.getAccountByGuid(GUID_STRING)).thenReturn(resultSet); + when(storage.getAccountById(newAccountId)).thenReturn(resultSet); when(account.isActive()).thenReturn(true); - boolean modified = accountAdmin.setActive(newAccount, true); + boolean modified = accountAdmin.setActive(newAccountId, true); assertFalse(modified); - verify(storage).getAccountByGuid(GUID_STRING); - verify(storage, times(0)).setActive(account, true); - } - - @Test - public void testDeleteAccountIdWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("account id cannot be null"); - accountAdmin.deleteAccount(nullID()); + verify(storage).getAccountById(newAccountId); + verify(storage, times(0)).setActive(newAccountId, true); } @Test public void testDeleteAccountIdModified() { ResultSet resultSet = ResultSets.singleton(account); - when(storage.getAccountByGuid(GUID_STRING)).thenReturn(resultSet); + when(storage.getAccountById(newAccountId)).thenReturn(resultSet); - boolean modified = accountAdmin.deleteAccount(newAccount); + boolean modified = accountAdmin.deleteAccount(newAccountId); assertTrue(modified); - verify(storage).getAccountByGuid(GUID_STRING); - verify(storage).deleteAccount(account); + verify(storage).getAccountById(newAccountId); + verify(storage).deleteAccount(newAccountId); } @Test @@ -299,27 +201,20 @@ public class AccountAdminImplTest { @SuppressWarnings("unchecked") ResultSet resultSet = Mockito.mock(ResultSet.class); - when(storage.getAccountByGuid(GUID_STRING)).thenReturn(resultSet); + when(storage.getAccountById(newAccountId)).thenReturn(resultSet); when(resultSet.getOneOrNull()).thenReturn(null); - boolean modified = accountAdmin.deleteAccount(newAccount); + boolean modified = accountAdmin.deleteAccount(newAccountId); assertFalse(modified); verify(storage, times(0)).deleteAccount(null); } - @Test - public void testSetAccountPreferencesIdWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("account preference id cannot be null"); - accountAdmin.setAccountPreferences(nullID(), Collections. emptyMap()); - } - @Test public void testSetAccountPreferencesPrefsWithNull() { thrown.expect(OseeArgumentException.class); thrown.expectMessage("preferences cannot be null"); - accountAdmin.setAccountPreferences(newAccount, null); + accountAdmin.setAccountPreferences(newAccountId, null); } @Test @@ -332,14 +227,14 @@ public class AccountAdminImplTest { ResultSet resultSet = ResultSets.singleton(preferences); - when(storage.getAccountPreferencesByGuid(GUID_STRING)).thenReturn(resultSet); + when(storage.getAccountPreferencesById(newAccountId)).thenReturn(resultSet); when(preferences.asMap()).thenReturn(original); - boolean modified = accountAdmin.setAccountPreferences(newAccount, newMap); + boolean modified = accountAdmin.setAccountPreferences(newAccountId, newMap); assertTrue(modified); - verify(storage).setAccountPreferences(preferences, newMap); - verify(storage).getAccountPreferencesByGuid(GUID_STRING); + verify(storage).setAccountPreferences(newAccountId, newMap); + verify(storage).getAccountPreferencesById(newAccountId); verify(preferences).asMap(); } @@ -353,36 +248,29 @@ public class AccountAdminImplTest { ResultSet resultSet = ResultSets.singleton(preferences); - when(storage.getAccountPreferencesByGuid(GUID_STRING)).thenReturn(resultSet); + when(storage.getAccountPreferencesById(newAccountId)).thenReturn(resultSet); when(preferences.asMap()).thenReturn(original); - boolean modified = accountAdmin.setAccountPreferences(newAccount, newMap); + boolean modified = accountAdmin.setAccountPreferences(newAccountId, newMap); assertFalse(modified); - verify(storage, times(0)).setAccountPreferences(newAccount, newMap); - verify(storage).getAccountPreferencesByGuid(GUID_STRING); + verify(storage, times(0)).setAccountPreferences(newAccountId, newMap); + verify(storage).getAccountPreferencesById(newAccountId); verify(preferences).asMap(); } - @Test - public void testSetAccountPreferenceIdWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("account preference id cannot be null"); - accountAdmin.setAccountPreference(nullID(), "b", "value"); - } - @Test public void testSetAccountPreferenceKeyWithNull() { thrown.expect(OseeArgumentException.class); thrown.expectMessage("account preference key cannot be null"); - accountAdmin.setAccountPreference(newAccount, null, "value"); + accountAdmin.setAccountPreference(newAccountId, null, "value"); } @Test public void testSetAccountPreferenceValueWithNull() { thrown.expect(OseeArgumentException.class); thrown.expectMessage("account preference value cannot be null - Use delete account preference instead"); - accountAdmin.setAccountPreference(newAccount, "b", null); + accountAdmin.setAccountPreference(newAccountId, "b", null); } @Test @@ -394,14 +282,14 @@ public class AccountAdminImplTest { ResultSet resultSet = ResultSets.singleton(preferences); - when(storage.getAccountPreferencesByGuid(GUID_STRING)).thenReturn(resultSet); + when(storage.getAccountPreferencesById(newAccountId)).thenReturn(resultSet); when(preferences.asMap()).thenReturn(map); - boolean modified = accountAdmin.setAccountPreference(newAccount, "b", "123412"); + boolean modified = accountAdmin.setAccountPreference(newAccountId, "b", "123412"); assertTrue(modified); - verify(storage).getAccountPreferencesByGuid(GUID_STRING); - verify(storage).setAccountPreferences(eq(preferences), newPrefsCaptor.capture()); + verify(storage).getAccountPreferencesById(newAccountId); + verify(storage).setAccountPreferences(eq(newAccountId), newPrefsCaptor.capture()); Map actual = newPrefsCaptor.getValue(); assertEquals(3, actual.size()); @@ -419,28 +307,21 @@ public class AccountAdminImplTest { ResultSet resultSet = ResultSets.singleton(preferences); - when(storage.getAccountPreferencesByGuid(GUID_STRING)).thenReturn(resultSet); + when(storage.getAccountPreferencesById(newAccountId)).thenReturn(resultSet); when(preferences.asMap()).thenReturn(map); - boolean modified = accountAdmin.setAccountPreference(newAccount, "b", "123412"); + boolean modified = accountAdmin.setAccountPreference(newAccountId, "b", "123412"); assertFalse(modified); - verify(storage).getAccountPreferencesByGuid(GUID_STRING); - verify(storage, times(0)).setAccountPreferences(eq(newAccount), anyMapOf(String.class, String.class)); - } - - @Test - public void testDeleteAccountPreferenceIdWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("account preference id cannot be null"); - accountAdmin.deleteAccountPreference(nullID(), "b"); + verify(storage).getAccountPreferencesById(newAccountId); + verify(storage, times(0)).setAccountPreferences(eq(newAccountId), anyMapOf(String.class, String.class)); } @Test public void testDeleteAccountPreferenceKeyWithNull() { thrown.expect(OseeArgumentException.class); thrown.expectMessage("account preference key cannot be null"); - accountAdmin.deleteAccountPreference(newAccount, null); + accountAdmin.deleteAccountPreference(newAccountId, null); } @Test @@ -452,14 +333,14 @@ public class AccountAdminImplTest { ResultSet resultSet = ResultSets.singleton(preferences); - when(storage.getAccountPreferencesByGuid(GUID_STRING)).thenReturn(resultSet); + when(storage.getAccountPreferencesById(newAccountId)).thenReturn(resultSet); when(preferences.asMap()).thenReturn(map); - boolean modified = accountAdmin.deleteAccountPreference(newAccount, "b"); + boolean modified = accountAdmin.deleteAccountPreference(newAccountId, "b"); assertTrue(modified); - verify(storage).getAccountPreferencesByGuid(GUID_STRING); - verify(storage).setAccountPreferences(eq(preferences), newPrefsCaptor.capture()); + verify(storage).getAccountPreferencesById(newAccountId); + verify(storage).setAccountPreferences(eq(newAccountId), newPrefsCaptor.capture()); Map actual = newPrefsCaptor.getValue(); assertEquals(2, actual.size()); @@ -475,139 +356,28 @@ public class AccountAdminImplTest { ResultSet resultSet = ResultSets.singleton(preferences); - when(storage.getAccountPreferencesByGuid(GUID_STRING)).thenReturn(resultSet); + when(storage.getAccountPreferencesById(newAccountId)).thenReturn(resultSet); when(preferences.asMap()).thenReturn(map); - boolean modified = accountAdmin.deleteAccountPreference(newAccount, "b"); + boolean modified = accountAdmin.deleteAccountPreference(newAccountId, "b"); assertFalse(modified); - verify(storage).getAccountPreferencesByGuid(GUID_STRING); - verify(storage, times(0)).setAccountPreferences(eq(newAccount), anyMapOf(String.class, String.class)); + verify(storage).getAccountPreferencesById(newAccountId); + verify(storage, times(0)).setAccountPreferences(eq(newAccountId), anyMapOf(String.class, String.class)); } @Test - public void testGetAccountByUniqueField() { + public void testGetAccountByEmail() { ResultSet resultSet = ResultSets.singleton(account); when(storage.getAccountByEmail(EMAIL)).thenReturn(resultSet); - ResultSet result = accountAdmin.getAccountByUniqueField(EMAIL); + ResultSet result = accountAdmin.getAccountByEmail(EMAIL); assertEquals(account, result.getExactlyOne()); verify(storage).getAccountByEmail(EMAIL); } - @Test - public void testGetAccountPreferencesByUniqueField() { - ResultSet resultSet = ResultSets.singleton(account); - - when(storage.getAccountByName(NAME)).thenReturn(resultSet); - when(account.getPreferences()).thenReturn(preferences); - - ResultSet result = accountAdmin.getAccountPreferencesByUniqueField(NAME); - assertEquals(preferences, result.getExactlyOne()); - - verify(storage).getAccountByName(NAME); - } - - @Test - public void testDeleteAccountByUniqueField() { - ResultSet resultSet = ResultSets.singleton(account); - - when(storage.getAccountByEmail(EMAIL)).thenReturn(resultSet); - - boolean actual = accountAdmin.deleteAccount(EMAIL); - assertEquals(true, actual); - - verify(storage).getAccountByEmail(EMAIL); - verify(storage).deleteAccount(account); - } - - @Test - public void testSetActiveByUniqueField() { - ResultSet resultSet = ResultSets.singleton(account); - - when(storage.getAccountByEmail(EMAIL)).thenReturn(resultSet); - - boolean actual = accountAdmin.setActive(EMAIL, true); - assertEquals(true, actual); - - verify(storage).getAccountByEmail(EMAIL); - verify(storage).setActive(account, true); - } - - @Test - public void testSetAccountPreferencesByUniqueField() { - Map original = new HashMap<>(); - original.put("a", "1"); - original.put("c", "3"); - - Map newMap = new HashMap<>(); - newMap.put("a", "1"); - - ResultSet resultSet = ResultSets.singleton(account); - - when(storage.getAccountByEmail(EMAIL)).thenReturn(resultSet); - when(account.getPreferences()).thenReturn(preferences); - when(preferences.asMap()).thenReturn(original); - - boolean actual = accountAdmin.setAccountPreferences(EMAIL, newMap); - assertEquals(true, actual); - - verify(storage).getAccountByEmail(EMAIL); - verify(storage).setAccountPreferences(preferences, newMap); - } - - @Test - public void testAccountPreferenceByUniqueField() { - Map original = new HashMap<>(); - original.put("a", "1"); - original.put("c", "3"); - - ResultSet resultSet = ResultSets.singleton(account); - - when(storage.getAccountByEmail(EMAIL)).thenReturn(resultSet); - when(account.getPreferences()).thenReturn(preferences); - when(preferences.asMap()).thenReturn(original); - - boolean actual = accountAdmin.setAccountPreference(EMAIL, "b", "2"); - assertEquals(true, actual); - - verify(storage).getAccountByEmail(EMAIL); - verify(storage).setAccountPreferences(eq(preferences), newPrefsCaptor.capture()); - - Map newValues = newPrefsCaptor.getValue(); - assertEquals(3, newValues.size()); - assertEquals("1", newValues.get("a")); - assertEquals("2", newValues.get("b")); - assertEquals("3", newValues.get("c")); - } - - @Test - public void testDeleteAccountPreferenceByUniqueField() { - Map original = new HashMap<>(); - original.put("a", "1"); - original.put("b", "2"); - original.put("c", "3"); - - ResultSet resultSet = ResultSets.singleton(account); - - when(storage.getAccountByEmail(EMAIL)).thenReturn(resultSet); - when(account.getPreferences()).thenReturn(preferences); - when(preferences.asMap()).thenReturn(original); - - boolean actual = accountAdmin.deleteAccountPreference(EMAIL, "b"); - assertEquals(true, actual); - - verify(storage).getAccountByEmail(EMAIL); - verify(storage).setAccountPreferences(eq(preferences), newPrefsCaptor.capture()); - - Map newValues = newPrefsCaptor.getValue(); - assertEquals(2, newValues.size()); - assertEquals("1", newValues.get("a")); - assertEquals("3", newValues.get("c")); - } - @Test public void testAccountLoginException() { String scheme = "myScheme"; @@ -628,11 +398,11 @@ public class AccountAdminImplTest { .build(); when(authenticationAdmin.authenticate(any(AuthenticationRequest.class))).thenReturn(authenticatedUser); - when(authenticatedUser.getName()).thenReturn(EMAIL); + when(authenticatedUser.getEmailAddress()).thenReturn(EMAIL); thrown.expect(AccountLoginException.class); thrown.expectMessage( - "Login Error - Unable to find account for username[" + userName + "] using authentication scheme[" + scheme + "] and userId[" + userName + "]"); + "Login Error - Unable to find account for username[" + userName + "] using authentication scheme[" + scheme + "]"); accountAdmin.login(request); verify(storage, times(0)).createAccountSession(anyString(), any(Account.class), anyString(), anyString()); @@ -658,7 +428,7 @@ public class AccountAdminImplTest { when(storage.getAccountByEmail(EMAIL)).thenReturn(resultSet); when(storage.createAccountSession(anyString(), eq(account), anyString(), anyString())).thenReturn(session); when(authenticationAdmin.authenticate(any(AuthenticationRequest.class))).thenReturn(authenticatedUser); - when(authenticatedUser.getName()).thenReturn(EMAIL); + when(authenticatedUser.getEmailAddress()).thenReturn(EMAIL); AccountLoginRequest request = AccountLoginRequestBuilder.newBuilder()// .userName(userName)// @@ -730,22 +500,6 @@ public class AccountAdminImplTest { verify(storage, times(0)).deleteAccountSessionBySessionToken(sessionToken); } - @Test - public void testGetAccountAccessByUniqueField() { - ResultSet resultSet = ResultSets.singleton(account); - ResultSet resultSet2 = ResultSets.singleton(accountSession); - - when(storage.getAccountByEmail(EMAIL)).thenReturn(resultSet); - when(account.getId()).thenReturn(ID); - when(storage.getAccountSessionById(ID)).thenReturn(resultSet2); - - ResultSet actual = accountAdmin.getAccountSessionByUniqueField(EMAIL); - assertEquals(resultSet2, actual); - - verify(account).getId(); - verify(storage).getAccountSessionById(ID); - } - @Test public void testUpdateConfig() { String userNamePattern = "\\d+"; @@ -773,8 +527,4 @@ public class AccountAdminImplTest { assertEquals(true, validator.isValid(AccountField.DISPLAY_NAME, "abc def")); } - private static Identifiable nullID() { - return null; - } - } diff --git a/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/AccountResolverTest.java b/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/AccountResolverTest.java index f3b32806632..d9b8488fff0 100644 --- a/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/AccountResolverTest.java +++ b/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/AccountResolverTest.java @@ -11,7 +11,6 @@ package org.eclipse.osee.account.admin.internal; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyLong; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -22,6 +21,7 @@ import org.eclipse.osee.account.admin.AccountAdmin; import org.eclipse.osee.account.admin.AccountField; import org.eclipse.osee.account.admin.AccountPreferences; import org.eclipse.osee.account.admin.internal.validator.Validator; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.ResultSet; import org.eclipse.osee.framework.jdk.core.type.ResultSets; @@ -30,6 +30,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.mockito.Matchers; import org.mockito.Mock; /** @@ -40,8 +41,6 @@ import org.mockito.Mock; public class AccountResolverTest { private static final String TEST_VALUE = "atest"; - private static final String TEST_LOCAID_VALUE = "12334"; - private static final long LOCAID_VALUE = 12334L; @Rule public ExpectedException thrown = ExpectedException.none(); @@ -98,18 +97,6 @@ public class AccountResolverTest { resolver.resolveAccountPreferences(""); } - @Test - public void testResolveAccountAsDisplayName() { - when(validator.guessFormatType(TEST_VALUE)).thenReturn(AccountField.DISPLAY_NAME); - when(accountAdmin.getAccountByName(TEST_VALUE)).thenReturn(accountResult); - - ResultSet actual = resolver.resolveAccount(TEST_VALUE); - assertEquals(accountResult, actual); - - verify(validator).guessFormatType(TEST_VALUE); - verify(accountAdmin).getAccountByName(TEST_VALUE); - } - @Test public void testResolveAccountAsEmail() { when(validator.guessFormatType(TEST_VALUE)).thenReturn(AccountField.EMAIL); @@ -122,58 +109,6 @@ public class AccountResolverTest { verify(accountAdmin).getAccountByEmail(TEST_VALUE); } - @Test - public void testResolveAccountAsLocalId() { - when(validator.guessFormatType(TEST_LOCAID_VALUE)).thenReturn(AccountField.LOCAL_ID); - when(accountAdmin.getAccountById(LOCAID_VALUE)).thenReturn(accountResult); - - ResultSet actual = resolver.resolveAccount(TEST_LOCAID_VALUE); - assertEquals(accountResult, actual); - - verify(validator).guessFormatType(TEST_LOCAID_VALUE); - verify(accountAdmin).getAccountById(LOCAID_VALUE); - } - - @Test - public void testResolveAccountAsUnknown() { - when(validator.guessFormatType(TEST_VALUE)).thenReturn(AccountField.UNKNOWN); - - ResultSet actual = resolver.resolveAccount(TEST_VALUE); - assertEquals(ResultSets.emptyResultSet(), actual); - - verify(validator).guessFormatType(TEST_VALUE); - - verify(accountAdmin, times(0)).getAccountByEmail(anyString()); - verify(accountAdmin, times(0)).getAccountById(anyLong()); - verify(accountAdmin, times(0)).getAccountByGuid(anyString()); - verify(accountAdmin, times(0)).getAccountByName(anyString()); - verify(accountAdmin, times(0)).getAccountByUserName(anyString()); - } - - @Test - public void testResolveAccountAsUserName() { - when(validator.guessFormatType(TEST_VALUE)).thenReturn(AccountField.USERNAME); - when(accountAdmin.getAccountByUserName(TEST_VALUE)).thenReturn(accountResult); - - ResultSet actual = resolver.resolveAccount(TEST_VALUE); - assertEquals(accountResult, actual); - - verify(validator).guessFormatType(TEST_VALUE); - verify(accountAdmin).getAccountByUserName(TEST_VALUE); - } - - @Test - public void testResolveAccountAsGuid() { - when(validator.guessFormatType(TEST_VALUE)).thenReturn(AccountField.GUID); - when(accountAdmin.getAccountByGuid(TEST_VALUE)).thenReturn(accountResult); - - ResultSet actual = resolver.resolveAccount(TEST_VALUE); - assertEquals(accountResult, actual); - - verify(validator).guessFormatType(TEST_VALUE); - verify(accountAdmin).getAccountByGuid(TEST_VALUE); - } - @Test public void testResolveAccountPrefsUnknown() { when(validator.guessFormatType(TEST_VALUE)).thenReturn(AccountField.UNKNOWN); @@ -182,10 +117,7 @@ public class AccountResolverTest { assertEquals(ResultSets.emptyResultSet(), actual); verify(accountAdmin, times(0)).getAccountByEmail(anyString()); - verify(accountAdmin, times(0)).getAccountById(anyLong()); - verify(accountAdmin, times(0)).getAccountByGuid(anyString()); - verify(accountAdmin, times(0)).getAccountByName(anyString()); - verify(accountAdmin, times(0)).getAccountByUserName(anyString()); + verify(accountAdmin, times(0)).getAccountById(Matchers.any(ArtifactId.class)); } @Test diff --git a/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/InternalTestSuite.java b/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/InternalTestSuite.java index 7656952dad2..03534beacee 100644 --- a/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/InternalTestSuite.java +++ b/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/InternalTestSuite.java @@ -22,8 +22,7 @@ import org.junit.runners.Suite; AccountAdminImplTest.class, AccountResolverTest.class, ValidatorTestSuite.class, - SubscriptionAdminImplTest.class, - SubscriptionResolverTest.class}) + SubscriptionAdminImplTest.class}) public class InternalTestSuite { // Test Suite } diff --git a/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/SubscriptionAdminImplTest.java b/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/SubscriptionAdminImplTest.java index cfbae7a1e4b..0b1c55edd00 100644 --- a/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/SubscriptionAdminImplTest.java +++ b/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/SubscriptionAdminImplTest.java @@ -28,17 +28,15 @@ import org.eclipse.osee.account.admin.Subscription; import org.eclipse.osee.account.admin.SubscriptionGroup; import org.eclipse.osee.account.admin.ds.SubscriptionStorage; import org.eclipse.osee.account.admin.internal.validator.Validator; -import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; -import org.eclipse.osee.framework.jdk.core.type.ResultSet; -import org.eclipse.osee.framework.jdk.core.type.ResultSets; -import org.eclipse.osee.framework.jdk.core.util.GUID; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.logger.Log; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.Mock; -import org.mockito.Mockito; /** * Test Case for {@link SubscriptionAdminImpl} @@ -47,12 +45,10 @@ import org.mockito.Mockito; */ public class SubscriptionAdminImplTest { - private static final long ID = 123121412L; - private static final String GUID_STRING = GUID.create(); private static final String GROUP_NAME = "group-name"; - private static final String EMAIL = "atest@email.com"; - private static final long ACCOUNT_ID = 21231L; - private static final long GROUP_ID = 7885741L; + private static final String ENCODED_UUID = "D1jfajgjoiasdajv32"; + private static final ArtifactId ACCOUNT_ID = TokenFactory.createArtifactId(21231L); + private static final SubscriptionGroupId GROUP_ID = new SubscriptionGroupId(7885741L); @Rule public ExpectedException thrown = ExpectedException.none(); @@ -76,7 +72,6 @@ public class SubscriptionAdminImplTest { manager = new SubscriptionAdminImpl(); manager.setLogger(logger); manager.setSubscriptionStorage(storage); - manager.setAccountAdmin(accountManager); manager.start(Collections. emptyMap()); when(subscription.getAccountId()).thenReturn(ACCOUNT_ID); @@ -89,81 +84,18 @@ public class SubscriptionAdminImplTest { verify(storage).getSubscriptionGroups(); } - @Test - public void testGetSubscriptionWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("subscription uuid cannot be null"); - manager.getSubscription(null); - } - @Test public void testGetSubscription() { - manager.getSubscription(GUID_STRING); - - verify(storage).getSubscription(GUID_STRING); - } - - @Test - public void testGetSubscriptionsByAccountUniqueField() { - when(account.getId()).thenReturn(ID); - ResultSet resultSet = ResultSets.singleton(account); - ResultSet subcriptionResultSet = ResultSets.singleton(subscription); - - when(accountManager.getAccountByUniqueField(EMAIL)).thenReturn(resultSet); - when(storage.getSubscriptionsByAccountLocalId(ID)).thenReturn(subcriptionResultSet); - - ResultSet result = manager.getSubscriptionsByAccountUniqueField(EMAIL); - assertEquals(subscription, result.getExactlyOne()); - - verify(account).getId(); - verify(storage).getSubscriptionsByAccountLocalId(ID); - } - - @Test - public void testGetSubscriptionGroupByUuidWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("group uuid cannot be null"); - manager.getSubscriptionGroupByGuid(null); - } - - @Test - public void testGetSubscriptionGroupByUuiId() { - manager.getSubscriptionGroupByGuid(GUID_STRING); + manager.getSubscriptionGroupById(GROUP_ID); - verify(storage).getSubscriptionGroupByGuid(GUID_STRING); + verify(storage).getSubscriptionGroupById(GROUP_ID); } @Test - public void testGetSubscriptionGroupById() { - manager.getSubscriptionGroupByLocalId(ID); + public void testGetSubscriptionById() { + manager.getSubscriptionGroupById(GROUP_ID); - verify(storage).getSubscriptionGroupByLocalId(ID); - } - - @Test - public void testGetSubscriptionGroupByNameWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("group name cannot be null"); - manager.getSubscriptionGroupByName(null); - } - - @Test - public void testGetSubscriptionGroupByName() { - manager.getSubscriptionGroupByName(GROUP_NAME); - - verify(storage).getSubscriptionGroupByName(GROUP_NAME); - } - - @Test - public void testGetSubscriptionGroupByUniqueField() { - ResultSet resultSet = ResultSets.singleton(group); - - when(storage.getSubscriptionGroupByName(GROUP_NAME)).thenReturn(resultSet); - - ResultSet result = manager.getSubscriptionGroupByUniqueField(GROUP_NAME); - assertEquals(group, result.getExactlyOne()); - - verify(storage).getSubscriptionGroupByName(GROUP_NAME); + verify(storage).getSubscriptionGroupById(GROUP_ID); } @Test @@ -174,108 +106,39 @@ public class SubscriptionAdminImplTest { } @Test - public void testDeleteSubscriptionGroupWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("subscription group unique field value cannot be null"); - manager.deleteSubscriptionGroupByUniqueField(null); - } - - @Test - public void testDeleteSubscriptionGroupIdModified() { - ResultSet resultSet = ResultSets.singleton(group); - - when(storage.getSubscriptionGroupByName(GROUP_NAME)).thenReturn(resultSet); - - boolean modified = manager.deleteSubscriptionGroupByUniqueField(GROUP_NAME); - assertTrue(modified); - - verify(storage).getSubscriptionGroupByName(GROUP_NAME); - verify(storage).deleteSubscriptionGroup(group); - } - - @Test - public void testDeleteSubscriptionGroupIdNotModified() { - @SuppressWarnings("unchecked") - ResultSet resultSet = Mockito.mock(ResultSet.class); + public void testDeleteSubscription() { + manager.deleteSubscriptionById(GROUP_ID); - when(storage.getSubscriptionGroupByName(GROUP_NAME)).thenReturn(resultSet); - when(resultSet.getOneOrNull()).thenReturn(null); - - boolean modified = manager.deleteSubscriptionGroupByUniqueField(GROUP_NAME); - assertFalse(modified); - - verify(storage, times(0)).deleteSubscriptionGroup(group); - } - - @Test - public void testGetMembersByGuidWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("uuid cannot be null"); - manager.getSubscriptionGroupMembersByGuid(null); - } - - @Test - public void testGetMembersByGuiId() { - manager.getSubscriptionGroupMembersByGuid(GUID_STRING); - - verify(storage).getSubscriptionGroupMembersByGuid(GUID_STRING); + verify(storage).deleteSubscriptionGroup(GROUP_ID); } @Test public void testGetMembersById() { - manager.getSubscriptionGroupMembersByLocalId(ID); - - verify(storage).getSubscriptionGroupMembersByLocalId(ID); - } - - @Test - public void testGetMembersByNameWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("group name cannot be null"); - manager.getSubscriptionGroupMembersByName(null); - } - - @Test - public void testGetMembersByName() { - manager.getSubscriptionGroupMembersByName(GROUP_NAME); - - verify(storage).getSubscriptionGroupMembersByName(GROUP_NAME); - } - - @Test - public void testGetMembersByUniqueField() { - ResultSet resultSet = ResultSets.singleton(account); - - when(storage.getSubscriptionGroupMembersByName(GROUP_NAME)).thenReturn(resultSet); - - ResultSet result = manager.getSubscriptionGroupMembersByUniqueField(GROUP_NAME); - assertEquals(account, result.getExactlyOne()); + manager.getSubscriptionMembersOfSubscriptionById(GROUP_ID); - verify(storage).getSubscriptionGroupMembersByName(GROUP_NAME); + verify(storage).getMembersOfSubscriptionGroupById(GROUP_ID); } @Test public void testSetSubscriptionActiveModified() { - when(storage.getSubscription(GUID_STRING)).thenReturn(subscription); + when(storage.getSubscriptionByEncodedId(ENCODED_UUID)).thenReturn(subscription); when(subscription.isActive()).thenReturn(true); - boolean modified = manager.setSubscriptionActive(GUID_STRING, false); + boolean modified = manager.setSubscriptionActive(subscription, false); assertTrue(modified); - verify(storage).getSubscription(GUID_STRING); - verify(storage).updateSubscription(ACCOUNT_ID, GROUP_ID, false); + verify(storage).updateSubscription(subscription, false); } @Test public void testSetSubscriptionActiveNotModified() { - when(storage.getSubscription(GUID_STRING)).thenReturn(subscription); + when(storage.getSubscriptionByEncodedId(ENCODED_UUID)).thenReturn(subscription); when(subscription.isActive()).thenReturn(true); - boolean modified = manager.setSubscriptionActive(GUID_STRING, true); + boolean modified = manager.setSubscriptionActive(subscription, true); assertFalse(modified); - verify(storage).getSubscription(GUID_STRING); - verify(storage, times(0)).updateSubscription(ACCOUNT_ID, GROUP_ID, true); + verify(storage, times(0)).updateSubscription(subscription, true); } @Test diff --git a/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/SubscriptionResolverTest.java b/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/SubscriptionResolverTest.java deleted file mode 100644 index 3b8852e33a4..00000000000 --- a/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/SubscriptionResolverTest.java +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 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.account.admin.internal; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyLong; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; -import org.eclipse.osee.account.admin.Account; -import org.eclipse.osee.account.admin.AccountField; -import org.eclipse.osee.account.admin.SubscriptionAdmin; -import org.eclipse.osee.account.admin.SubscriptionGroup; -import org.eclipse.osee.account.admin.internal.validator.Validator; -import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; -import org.eclipse.osee.framework.jdk.core.type.ResultSet; -import org.eclipse.osee.framework.jdk.core.type.ResultSets; -import org.eclipse.osee.framework.jdk.core.util.GUID; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.Mock; - -/** - * Test Case for {@link SubscriptionResolver} - * - * @author Roberto E. Escobar - */ -public class SubscriptionResolverTest { - - private static final String TEST_VALUE = "atest"; - private static final String TEST_LOCAID_VALUE = "12334"; - private static final long LOCAID_VALUE = 12334L; - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - // @formatter:off - @Mock private Validator validator; - @Mock private SubscriptionAdmin manager; - - @Mock private SubscriptionGroup group; - @Mock private ResultSet groups; - - @Mock private Account account; - @Mock private ResultSet members; - // @formatter:on - - private SubscriptionResolver resolver; - - @Before - public void testSetup() { - initMocks(this); - - resolver = new SubscriptionResolver(validator, manager); - - String uuid1 = GUID.create(); - when(group.getGuid()).thenReturn(uuid1); - - String uuid2 = GUID.create(); - when(account.getGuid()).thenReturn(uuid2); - - when(groups.getExactlyOne()).thenReturn(group); - } - - @Test - public void testResolveSubscriptionGroupWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("subscription group unique field value cannot be null"); - resolver.resolveSubscriptionGroup(null); - } - - @Test - public void testResolveSubscriptionGroupWithEmpty() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("subscription group unique field value cannot be empty"); - resolver.resolveSubscriptionGroup(""); - } - - @Test - public void testResolveSubscriptionGroupAsUnknown() { - when(validator.guessFormatType(TEST_VALUE)).thenReturn(AccountField.UNKNOWN); - - ResultSet actual = resolver.resolveSubscriptionGroup(TEST_VALUE); - assertEquals(ResultSets.emptyResultSet(), actual); - - verify(validator).guessFormatType(TEST_VALUE); - - verify(manager, times(0)).getSubscriptionGroupByLocalId(anyLong()); - verify(manager, times(0)).getSubscriptionGroupByGuid(anyString()); - verify(manager, times(0)).getSubscriptionGroupByName(anyString()); - } - - @Test - public void testResolveSubscriptionGroupAsLocalId() { - when(validator.guessFormatType(TEST_LOCAID_VALUE)).thenReturn(AccountField.LOCAL_ID); - when(manager.getSubscriptionGroupByLocalId(LOCAID_VALUE)).thenReturn(groups); - - ResultSet actual = resolver.resolveSubscriptionGroup(TEST_LOCAID_VALUE); - assertEquals(groups, actual); - - verify(validator).guessFormatType(TEST_LOCAID_VALUE); - verify(manager).getSubscriptionGroupByLocalId(LOCAID_VALUE); - } - - @Test - public void testResolveSubscriptionGroupAsUuid() { - when(validator.guessFormatType(TEST_VALUE)).thenReturn(AccountField.GUID); - when(manager.getSubscriptionGroupByGuid(TEST_VALUE)).thenReturn(groups); - - ResultSet actual = resolver.resolveSubscriptionGroup(TEST_VALUE); - assertEquals(groups, actual); - - verify(validator).guessFormatType(TEST_VALUE); - verify(manager).getSubscriptionGroupByGuid(TEST_VALUE); - } - - @Test - public void testResolveSubscriptionGroupAsName() { - when(validator.guessFormatType(TEST_VALUE)).thenReturn(AccountField.SUBSCRIPTION_GROUP_NAME); - when(manager.getSubscriptionGroupByName(TEST_VALUE)).thenReturn(groups); - - ResultSet actual = resolver.resolveSubscriptionGroup(TEST_VALUE); - assertEquals(groups, actual); - - verify(validator).guessFormatType(TEST_VALUE); - verify(manager).getSubscriptionGroupByName(TEST_VALUE); - } - - //////////////////////////////////////// - @Test - public void testResolveSubscriptionGroupMembersWithNull() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("subscription group unique field value cannot be null"); - resolver.resolveSubscriptionGroupMembersByGroupUniqueField(null); - } - - @Test - public void testResolveSubscriptionGroupMembersWithEmpty() { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("subscription group unique field value cannot be empty"); - resolver.resolveSubscriptionGroupMembersByGroupUniqueField(""); - } - - @Test - public void testResolveMembersAsUnknown() { - when(validator.guessFormatType(TEST_VALUE)).thenReturn(AccountField.UNKNOWN); - - ResultSet actual = resolver.resolveSubscriptionGroupMembersByGroupUniqueField(TEST_VALUE); - assertEquals(ResultSets.emptyResultSet(), actual); - - verify(validator).guessFormatType(TEST_VALUE); - - verify(manager, times(0)).getSubscriptionGroupMembersByLocalId(anyLong()); - verify(manager, times(0)).getSubscriptionGroupMembersByGuid(anyString()); - verify(manager, times(0)).getSubscriptionGroupMembersByName(anyString()); - } - - @Test - public void testResolveMembersAsLocalId() { - when(validator.guessFormatType(TEST_LOCAID_VALUE)).thenReturn(AccountField.LOCAL_ID); - when(manager.getSubscriptionGroupMembersByLocalId(LOCAID_VALUE)).thenReturn(members); - - ResultSet actual = resolver.resolveSubscriptionGroupMembersByGroupUniqueField(TEST_LOCAID_VALUE); - assertEquals(members, actual); - - verify(validator).guessFormatType(TEST_LOCAID_VALUE); - verify(manager).getSubscriptionGroupMembersByLocalId(LOCAID_VALUE); - } - - @Test - public void testResolveMembersAsGuid() { - when(validator.guessFormatType(TEST_VALUE)).thenReturn(AccountField.GUID); - when(manager.getSubscriptionGroupMembersByGuid(TEST_VALUE)).thenReturn(members); - - ResultSet actual = resolver.resolveSubscriptionGroupMembersByGroupUniqueField(TEST_VALUE); - assertEquals(members, actual); - - verify(validator).guessFormatType(TEST_VALUE); - verify(manager).getSubscriptionGroupMembersByGuid(TEST_VALUE); - } - - @Test - public void testResolveMembersAsName() { - when(validator.guessFormatType(TEST_VALUE)).thenReturn(AccountField.SUBSCRIPTION_GROUP_NAME); - when(manager.getSubscriptionGroupMembersByName(TEST_VALUE)).thenReturn(members); - - ResultSet actual = resolver.resolveSubscriptionGroupMembersByGroupUniqueField(TEST_VALUE); - assertEquals(members, actual); - - verify(validator).guessFormatType(TEST_VALUE); - verify(manager).getSubscriptionGroupMembersByName(TEST_VALUE); - } -} diff --git a/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/validator/UuidValidatorTest.java b/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/validator/UuidValidatorTest.java deleted file mode 100644 index 98290211065..00000000000 --- a/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/validator/UuidValidatorTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * 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.account.admin.internal.validator; - -import org.eclipse.osee.account.admin.AccountField; -import org.eclipse.osee.framework.jdk.core.util.GUID; - -/** - * Test Case for {@link UuidValidator} - * - * @author Roberto E. Escobar - */ -public class UuidValidatorTest extends AbstractValidatorTest { - - private static final String VALID_GUID = GUID.create(); - private static final String INVALID_GUID = "12 31 asd"; - - public UuidValidatorTest() { - super(AccountField.GUID, VALID_GUID, INVALID_GUID); - } - - @Override - protected UuidValidator createValidator() { - return new UuidValidator(); - } - -} diff --git a/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/validator/ValidatorTestSuite.java b/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/validator/ValidatorTestSuite.java index 0e7289745a8..b83cc265452 100644 --- a/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/validator/ValidatorTestSuite.java +++ b/plugins/org.eclipse.osee.account.admin.test/src/org/eclipse/osee/account/admin/internal/validator/ValidatorTestSuite.java @@ -23,7 +23,6 @@ import org.junit.runners.Suite; LocalIdValidatorTest.class, SubscriptionGroupNameValidatorTest.class, UserNameValidatorTest.class, - UuidValidatorTest.class, ValidatorTest.class}) public class ValidatorTestSuite { // Test Suite diff --git a/plugins/org.eclipse.osee.account.admin/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.account.admin/META-INF/MANIFEST.MF index a9865be6356..9678478b799 100644 --- a/plugins/org.eclipse.osee.account.admin/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.account.admin/META-INF/MANIFEST.MF @@ -8,6 +8,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Service-Component: OSGI-INF/*.xml Import-Package: org.eclipse.osee.account.rest.model, org.eclipse.osee.authentication.admin, + org.eclipse.osee.framework.core.data, org.eclipse.osee.framework.jdk.core.type, org.eclipse.osee.framework.jdk.core.util, org.eclipse.osee.logger diff --git a/plugins/org.eclipse.osee.account.admin/OSGI-INF/subscriptions.admin.xml b/plugins/org.eclipse.osee.account.admin/OSGI-INF/subscriptions.admin.xml index 32997094eee..c66d6f786cf 100644 --- a/plugins/org.eclipse.osee.account.admin/OSGI-INF/subscriptions.admin.xml +++ b/plugins/org.eclipse.osee.account.admin/OSGI-INF/subscriptions.admin.xml @@ -6,5 +6,4 @@ - diff --git a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/Account.java b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/Account.java index a3e542d01ca..d779e9669a6 100644 --- a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/Account.java +++ b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/Account.java @@ -18,7 +18,7 @@ import org.eclipse.osee.framework.jdk.core.type.Identifiable; */ public interface Account extends Identifiable { - long getId(); + Long getId(); boolean isActive(); diff --git a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/AccountAdmin.java b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/AccountAdmin.java index 3b4c3b54bc1..c7eba99e304 100644 --- a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/AccountAdmin.java +++ b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/AccountAdmin.java @@ -11,7 +11,7 @@ package org.eclipse.osee.account.admin; import java.util.Map; -import org.eclipse.osee.framework.jdk.core.type.Identifiable; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.ResultSet; /** @@ -21,49 +21,21 @@ public interface AccountAdmin { ResultSet getAllAccounts(); - ResultSet getAccountByUniqueField(String uniqueField); - - ResultSet getAccountById(long id); - - ResultSet getAccountById(Identifiable id); - - ResultSet getAccountByGuid(String guid); - - ResultSet getAccountByUserName(String username); + ResultSet getAccountById(ArtifactId accountId); ResultSet getAccountByEmail(String email); - ResultSet getAccountByName(String name); - - ResultSet getAccountPreferencesByUniqueField(String uniqueField); - - ResultSet getAccountPreferencesById(long id); - - ResultSet getAccountPreferencesById(Identifiable id); - - ResultSet getAccountPreferencesByGuid(String id); + ResultSet getAccountPreferencesById(ArtifactId accountId); - Identifiable createAccount(CreateAccountRequest request); + ArtifactId createAccount(CreateAccountRequest request); - boolean deleteAccount(Identifiable id); + boolean setActive(ArtifactId accountId, boolean active); - boolean deleteAccount(String uniqueField); + boolean setAccountPreferences(ArtifactId accountId, Map preferences); - boolean setActive(Identifiable id, boolean active); + boolean setAccountPreference(ArtifactId accountId, String key, String value); - boolean setActive(String uniqueField, boolean active); - - boolean setAccountPreferences(Identifiable id, Map preferences); - - boolean setAccountPreferences(String uniqueField, Map preferences); - - boolean setAccountPreference(Identifiable id, String key, String value); - - boolean setAccountPreference(String uniqueField, String key, String value); - - boolean deleteAccountPreference(Identifiable id, String key); - - boolean deleteAccountPreference(String uniqueField, String key); + boolean deleteAccountPreference(ArtifactId accountId, String key); AccountSession login(AccountLoginRequest request); @@ -71,10 +43,12 @@ public interface AccountAdmin { ResultSet getAccountSessionBySessionToken(String token); - ResultSet getAccountSessionByUniqueField(String uniqueField); + ResultSet getAccountSessionById(ArtifactId accountId); ResultSet getAnonymousAccount(); - boolean setAccountWebPreference(String accountGuid, String key, String itemId, String newValue); + boolean setAccountWebPreference(ArtifactId accountId, String key, String itemId, String newValue); + + boolean deleteAccount(ArtifactId accountId); } diff --git a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/AccountPreferences.java b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/AccountPreferences.java index b85f55b30e9..81ccbfef4e1 100644 --- a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/AccountPreferences.java +++ b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/AccountPreferences.java @@ -19,7 +19,7 @@ import org.eclipse.osee.framework.jdk.core.type.Identity; */ public interface AccountPreferences extends Identity { - long getId(); + Long getId(); Map asMap(); diff --git a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/AccountSession.java b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/AccountSession.java index e92f6ead525..7f5361c4cf9 100644 --- a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/AccountSession.java +++ b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/AccountSession.java @@ -17,7 +17,7 @@ import java.util.Date; */ public interface AccountSession { - long getAccountId(); + Long getAccountId(); String getSessionToken(); diff --git a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/Subscription.java b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/Subscription.java index 36191b85bba..361d48e1c72 100644 --- a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/Subscription.java +++ b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/Subscription.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.osee.account.admin; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.Identity; import org.eclipse.osee.framework.jdk.core.type.Named; @@ -18,11 +20,11 @@ import org.eclipse.osee.framework.jdk.core.type.Named; */ public interface Subscription extends Identity, Named { - long getAccountId(); + ArtifactId getAccountId(); String getAccountName(); - long getGroupId(); + SubscriptionGroupId getGroupId(); boolean isActive(); diff --git a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/SubscriptionAdmin.java b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/SubscriptionAdmin.java index 9f202ecfd8e..37eb7aaa1eb 100644 --- a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/SubscriptionAdmin.java +++ b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/SubscriptionAdmin.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.osee.account.admin; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.ResultSet; /** @@ -17,36 +19,19 @@ import org.eclipse.osee.framework.jdk.core.type.ResultSet; */ public interface SubscriptionAdmin { - ResultSet getSubscriptionsByAccountUniqueField(String accountUniqueField); + Subscription getSubscriptionsByEncodedId(String encodedId); - ResultSet getSubscriptionsByGuid(String guid); + ResultSet getSubscriptionsByAccountId(ArtifactId accountId); - Subscription getSubscription(String subscriptionUuid); + SubscriptionGroup getSubscriptionGroupById(SubscriptionGroupId subscriptionId); boolean setSubscriptionActive(Subscription subscription, boolean active); - boolean setSubscriptionActive(String subscriptionUuid, boolean active); - ResultSet getSubscriptionGroups(); - ResultSet getSubscriptionGroupByUniqueField(String groupUniqueField); - - ResultSet getSubscriptionGroupByLocalId(long groupId); - - ResultSet getSubscriptionGroupByName(String groupName); - - ResultSet getSubscriptionGroupByGuid(String groupUuid); - - SubscriptionGroup createSubscriptionGroup(String groupName); - - boolean deleteSubscriptionGroupByUniqueField(String groupId); - - ResultSet getSubscriptionGroupMembersByUniqueField(String groupUniqueField); - - ResultSet getSubscriptionGroupMembersByLocalId(long groupId); - - ResultSet getSubscriptionGroupMembersByName(String groupName); + SubscriptionGroupId createSubscriptionGroup(String groupName); - ResultSet getSubscriptionGroupMembersByGuid(String groupUuid); + boolean deleteSubscriptionById(SubscriptionGroupId subscriptionId); + ResultSet getSubscriptionMembersOfSubscriptionById(SubscriptionGroupId groupId); } diff --git a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/SubscriptionGroup.java b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/SubscriptionGroup.java index 66bd9251d88..b95dd70b709 100644 --- a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/SubscriptionGroup.java +++ b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/SubscriptionGroup.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.account.admin; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; import org.eclipse.osee.framework.jdk.core.type.Identifiable; /** @@ -17,6 +18,6 @@ import org.eclipse.osee.framework.jdk.core.type.Identifiable; */ public interface SubscriptionGroup extends Identifiable { - long getId(); + SubscriptionGroupId getId(); } \ No newline at end of file diff --git a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/ds/AccountStorage.java b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/ds/AccountStorage.java index 26e81ef45bf..612987df755 100644 --- a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/ds/AccountStorage.java +++ b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/ds/AccountStorage.java @@ -16,8 +16,7 @@ import org.eclipse.osee.account.admin.AccountPreferences; import org.eclipse.osee.account.admin.AccountSession; import org.eclipse.osee.account.admin.CreateAccountRequest; import org.eclipse.osee.account.rest.model.AccountWebPreferences; -import org.eclipse.osee.framework.jdk.core.type.Identifiable; -import org.eclipse.osee.framework.jdk.core.type.Identity; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.ResultSet; /** @@ -27,29 +26,15 @@ public interface AccountStorage { ResultSet getAllAccounts(); - ResultSet getAccountByUserName(String username); - - ResultSet getAccountByGuid(String guid); - - ResultSet getAccountByUuid(String accountUuid); - - ResultSet getAccountByLocalId(long accountId); + ResultSet getAccountById(ArtifactId accountUuid); ResultSet getAccountByEmail(String email); - ResultSet getAccountByName(String name); - - ResultSet getAccountPreferencesById(long accountId); + ResultSet getAccountPreferencesById(ArtifactId accountId); - ResultSet getAccountPreferencesByGuid(String guid); + ArtifactId createAccount(CreateAccountRequest request); - Identifiable createAccount(CreateAccountRequest request); - - void setActive(Identifiable account, boolean active); - - void setAccountPreferences(Identity account, Map preferences); - - void deleteAccount(Identifiable account); + void setActive(ArtifactId accountId, boolean active); boolean userNameExists(String username); @@ -57,7 +42,7 @@ public interface AccountStorage { boolean displayNameExists(String displayName); - ResultSet getAccountSessionById(long accountId); + ResultSet getAccountSessionById(ArtifactId accountId); ResultSet getAccountSessionBySessionToken(String sessionToken); @@ -67,10 +52,12 @@ public interface AccountStorage { ResultSet getAnonymousAccount(); - AccountWebPreferences getAccountWebPreferencesByGuid(String accountGuid); + AccountWebPreferences getAccountWebPreferencesById(ArtifactId accountId); + + void setAccountWebPreferences(ArtifactId artifactId, String preferences); - AccountWebPreferences getAccountWebPreferencesById(int accountId); + void setAccountPreferences(ArtifactId accountId, Map preferences); - void setAccountWebPreferences(String accountGuid, String newPreferences); + void deleteAccount(ArtifactId accountId); } diff --git a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/ds/SubscriptionStorage.java b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/ds/SubscriptionStorage.java index 173404e4023..07dd8ee75d0 100644 --- a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/ds/SubscriptionStorage.java +++ b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/ds/SubscriptionStorage.java @@ -13,6 +13,8 @@ package org.eclipse.osee.account.admin.ds; import org.eclipse.osee.account.admin.Account; import org.eclipse.osee.account.admin.Subscription; import org.eclipse.osee.account.admin.SubscriptionGroup; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.ResultSet; /** @@ -20,30 +22,24 @@ import org.eclipse.osee.framework.jdk.core.type.ResultSet; */ public interface SubscriptionStorage { - ResultSet getSubscriptionsByAccountLocalId(long accountId); + ResultSet getSubscriptionsByAccountId(ArtifactId accountId); - Subscription getSubscription(String subscriptionUuid); + SubscriptionGroup getSubscriptionGroupById(SubscriptionGroupId subscriptionId); - void updateSubscription(long accountId, long groupId, boolean activate); + Subscription getSubscriptionByEncodedId(String encodedId); - ResultSet getSubscriptionGroups(); - - ResultSet getSubscriptionGroupByLocalId(long groupId); - - ResultSet getSubscriptionGroupByName(String name); + void updateSubscription(Subscription subscription, boolean activate); - ResultSet getSubscriptionGroupByGuid(String guid); + ResultSet getSubscriptionGroups(); boolean subscriptionGroupNameExists(String groupName); - SubscriptionGroup createSubscriptionGroup(String name); - - void deleteSubscriptionGroup(SubscriptionGroup group); + SubscriptionGroupId createSubscriptionGroup(String name); - ResultSet getSubscriptionGroupMembersByLocalId(long groupId); + ResultSet getMembersOfSubscriptionGroupById(SubscriptionGroupId subscriptionId); - ResultSet getSubscriptionGroupMembersByName(String name); + boolean deleteSubscriptionGroup(SubscriptionGroupId subscriptionId); - ResultSet getSubscriptionGroupMembersByGuid(String guid); + ResultSet getSubscriptionMembersById(SubscriptionGroupId subscriptionId); } diff --git a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/AccountAdminImpl.java b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/AccountAdminImpl.java index d97d8d62580..d17357a7544 100644 --- a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/AccountAdminImpl.java +++ b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/AccountAdminImpl.java @@ -32,7 +32,7 @@ import org.eclipse.osee.authentication.admin.AuthenticatedUser; import org.eclipse.osee.authentication.admin.AuthenticationAdmin; import org.eclipse.osee.authentication.admin.AuthenticationRequest; import org.eclipse.osee.authentication.admin.AuthenticationRequestBuilder; -import org.eclipse.osee.framework.jdk.core.type.Identifiable; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.ResultSet; import org.eclipse.osee.framework.jdk.core.util.Compare; import org.eclipse.osee.framework.jdk.core.util.Conditions; @@ -48,7 +48,6 @@ public class AccountAdminImpl implements AccountAdmin { private AccountStorage storage; private AuthenticationAdmin authenticationAdmin; - private AccountResolver resolver; private Validator validator; public void setLogger(Log logger) { @@ -67,7 +66,6 @@ public class AccountAdminImpl implements AccountAdmin { logger.trace("Starting OrcsAccountAdminImpl..."); validator = Validators.newAccountValidator(logger, storage); - resolver = new AccountResolver(validator, this); update(props); } @@ -93,69 +91,17 @@ public class AccountAdminImpl implements AccountAdmin { } @Override - public ResultSet getAccountById(long id) { - return getStorage().getAccountByLocalId(id); + public ResultSet getAccountById(ArtifactId accountId) { + return getStorage().getAccountById(accountId); } @Override - public ResultSet getAccountPreferencesById(long id) { - return getStorage().getAccountPreferencesById(id); + public ResultSet getAccountPreferencesById(ArtifactId accountId) { + return getStorage().getAccountPreferencesById(accountId); } @Override - public ResultSet getAccountById(Identifiable id) { - Conditions.checkNotNull(id, "id"); - return getAccountByGuid(id.getGuid()); - } - - @Override - public ResultSet getAccountByGuid(String guid) { - Conditions.checkNotNull(guid, "guid"); - return getStorage().getAccountByGuid(guid); - } - - @Override - public ResultSet getAccountByUserName(String username) { - Conditions.checkNotNull(username, "username"); - return getStorage().getAccountByUserName(username); - } - - @Override - public ResultSet getAccountByEmail(String email) { - Conditions.checkNotNull(email, "email"); - return getStorage().getAccountByEmail(email); - } - - @Override - public ResultSet getAccountByName(String name) { - Conditions.checkNotNull(name, "name"); - return getStorage().getAccountByName(name); - } - - @Override - public ResultSet getAccountByUniqueField(String uniqueField) { - return resolver.resolveAccount(uniqueField); - } - - @Override - public ResultSet getAccountPreferencesByGuid(String guid) { - Conditions.checkNotNull(guid, "guid"); - return getStorage().getAccountPreferencesByGuid(guid); - } - - @Override - public ResultSet getAccountPreferencesById(Identifiable id) { - Conditions.checkNotNull(id, "id"); - return getAccountPreferencesByGuid(id.getGuid()); - } - - @Override - public ResultSet getAccountPreferencesByUniqueField(String uniqueField) { - return resolver.resolveAccountPreferences(uniqueField); - } - - @Override - public Identifiable createAccount(CreateAccountRequest request) { + public ArtifactId createAccount(CreateAccountRequest request) { Conditions.checkNotNull(request, "create account request"); Validator validator = getValidator(); @@ -167,144 +113,86 @@ public class AccountAdminImpl implements AccountAdmin { } @Override - public boolean setActive(Identifiable id, boolean active) { - Conditions.checkNotNull(id, "account id"); - ResultSet result = getAccountById(id); - return setActive(result, active); - } - - @Override - public boolean setActive(String uniqueField, boolean active) { - ResultSet result = getAccountByUniqueField(uniqueField); - return setActive(result, active); - } - - private boolean setActive(ResultSet result, boolean active) { + public boolean setActive(ArtifactId accountId, boolean active) { boolean modified = false; - Account account = result.getExactlyOne(); + Account account = getAccountById(accountId).getOneOrNull(); if (account.isActive() != active) { - getStorage().setActive(account, active); + getStorage().setActive(accountId, active); modified = true; } return modified; } @Override - public boolean deleteAccount(Identifiable id) { - Conditions.checkNotNull(id, "account id"); - ResultSet result = getAccountById(id); - return deleteAccount(result); - } - - @Override - public boolean deleteAccount(String uniqueField) { - ResultSet result = getAccountByUniqueField(uniqueField); - return deleteAccount(result); - } - - private boolean deleteAccount(ResultSet result) { + public boolean deleteAccount(ArtifactId accountId) { boolean modified = false; + ResultSet result = getAccountById(accountId); Account account = result.getOneOrNull(); if (account != null) { - getStorage().deleteAccount(account); + getStorage().deleteAccount(accountId); modified = true; } return modified; } @Override - public boolean setAccountPreferences(Identifiable id, Map preferences) { - Conditions.checkNotNull(id, "account preference id"); - Conditions.checkNotNull(preferences, "preferences"); - ResultSet result = getAccountPreferencesById(id); - return setAccountPreferences(result, preferences); - } - - @Override - public boolean setAccountPreferences(String uniqueField, Map preferences) { - Conditions.checkNotNull(preferences, "preferences"); - ResultSet result = getAccountPreferencesByUniqueField(uniqueField); - return setAccountPreferences(result, preferences); - } - - private boolean setAccountPreferences(ResultSet result, Map preferences) { + public boolean setAccountPreferences(ArtifactId accountId, Map preferences) { boolean modified = false; + Conditions.checkNotNull(preferences, "preferences"); + ResultSet result = getAccountPreferencesById(accountId); AccountPreferences prefs = result.getExactlyOne(); Map original = prefs.asMap(); if (Compare.isDifferent(original, preferences)) { - getStorage().setAccountPreferences(prefs, preferences); + getStorage().setAccountPreferences(accountId, preferences); modified = true; } return modified; } @Override - public boolean setAccountPreference(Identifiable id, String key, String value) { - Conditions.checkNotNull(id, "account preference id"); - ResultSet result = getAccountPreferencesById(id); - return setAccountPreference(result, key, value); - } - - @Override - public boolean setAccountPreference(String uniqueField, String key, String value) { - ResultSet result = getAccountPreferencesByUniqueField(uniqueField); - return setAccountPreference(result, key, value); - } - - @Override - public boolean setAccountWebPreference(String accountGuid, String key, String itemId, String newValue) { - Conditions.checkNotNull(key, "account preference key"); - Conditions.checkNotNull(newValue, "account preference value", "Use delete account preference instead"); - - AccountWebPreferences allPreferences = getStorage().getAccountWebPreferencesByGuid(accountGuid); - String newPreferences = AccountUtil.updateSinglePreference(allPreferences, key, itemId, newValue); - + public boolean setAccountPreference(ArtifactId accountId, String key, String value) { boolean modified = false; - if (Strings.isValid(newPreferences) && !newPreferences.equalsIgnoreCase(allPreferences.toString())) { - getStorage().setAccountWebPreferences(accountGuid, newPreferences); - modified = true; - } - return modified; - } - - private boolean setAccountPreference(ResultSet result, String key, String value) { Conditions.checkNotNull(key, "account preference key"); Conditions.checkNotNull(value, "account preference value", "Use delete account preference instead"); - - boolean modified = false; + ResultSet result = getAccountPreferencesById(accountId); AccountPreferences prefs = result.getExactlyOne(); Map original = prefs.asMap(); HashMap newPrefs = new HashMap<>(original); newPrefs.put(key, value); if (Compare.isDifferent(original, newPrefs)) { - getStorage().setAccountPreferences(prefs, newPrefs); + getStorage().setAccountPreferences(accountId, newPrefs); modified = true; } return modified; } @Override - public boolean deleteAccountPreference(Identifiable id, String key) { - Conditions.checkNotNull(id, "account preference id"); - ResultSet result = getAccountPreferencesById(id); - return deleteAccountPreference(result, key); - } + public boolean setAccountWebPreference(ArtifactId accountId, String key, String itemId, String newValue) { + Conditions.checkNotNull(key, "account preference key"); + Conditions.checkNotNull(newValue, "account preference value", "Use delete account preference instead"); - @Override - public boolean deleteAccountPreference(String uniqueField, String key) { - ResultSet result = getAccountPreferencesByUniqueField(uniqueField); - return deleteAccountPreference(result, key); + AccountWebPreferences allPreferences = getStorage().getAccountWebPreferencesById(accountId); + String newPreferences = AccountUtil.updateSinglePreference(allPreferences, key, itemId, newValue); + + boolean modified = false; + if (Strings.isValid(newPreferences) && !newPreferences.equalsIgnoreCase(allPreferences.toString())) { + getStorage().setAccountWebPreferences(accountId, newPreferences); + modified = true; + } + return modified; } - private boolean deleteAccountPreference(ResultSet result, String key) { - Conditions.checkNotNull(key, "account preference key"); + @Override + public boolean deleteAccountPreference(ArtifactId accountId, String key) { boolean modified = false; + Conditions.checkNotNull(key, "account preference key"); + ResultSet result = getAccountPreferencesById(accountId); AccountPreferences prefs = result.getExactlyOne(); Map original = prefs.asMap(); HashMap newPrefs = new HashMap<>(original); newPrefs.remove(key); if (Compare.isDifferent(original, newPrefs)) { - getStorage().setAccountPreferences(prefs, newPrefs); + getStorage().setAccountPreferences(accountId, newPrefs); modified = true; } return modified; @@ -316,13 +204,13 @@ public class AccountAdminImpl implements AccountAdmin { @Override public AccountSession login(AccountLoginRequest request) { - String id = authenticate(request); - ResultSet result = getAccountByUniqueField(id); + String email = authenticate(request); + ResultSet result = getAccountByEmail(email); Account account = result.getAtMostOneOrNull(); if (account == null) { throw new AccountLoginException( - "Login Error - Unable to find account for username[%s] using authentication scheme[%s] and userId[%s]", - request.getUserName(), request.getScheme(), id); + "Login Error - Unable to find account for username[%s] using authentication scheme[%s]", + request.getUserName(), request.getScheme()); } String sessionToken = UUID.randomUUID().toString(); @@ -346,14 +234,7 @@ public class AccountAdminImpl implements AccountAdmin { .build(); AuthenticatedUser authenticate = authenticationAdmin.authenticate(request); - return authenticate.getName(); - } - - @Override - public ResultSet getAccountSessionByUniqueField(String uniqueField) { - ResultSet result = getAccountByUniqueField(uniqueField); - Account account = result.getExactlyOne(); - return storage.getAccountSessionById(account.getId()); + return authenticate.getEmailAddress(); } @Override @@ -373,4 +254,15 @@ public class AccountAdminImpl implements AccountAdmin { return storage.getAnonymousAccount(); } + @Override + public ResultSet getAccountByEmail(String email) { + Conditions.checkNotNull(email, "email"); + return getStorage().getAccountByEmail(email); + } + + @Override + public ResultSet getAccountSessionById(ArtifactId accountId) { + return getStorage().getAccountSessionById(accountId); + } + } diff --git a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/AccountResolver.java b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/AccountResolver.java index a8e5768fb6e..634fc9bc388 100644 --- a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/AccountResolver.java +++ b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/AccountResolver.java @@ -34,10 +34,6 @@ public class AccountResolver { this.accountAdmin = accountAdmin; } - private long parseLocalId(String uniqueFieldValue) { - return Long.valueOf(uniqueFieldValue); - } - public ResultSet resolveAccount(String uniqueFieldValue) { Conditions.checkNotNullOrEmpty(uniqueFieldValue, "account unique field value"); ResultSet toReturn; @@ -46,19 +42,6 @@ public class AccountResolver { case EMAIL: toReturn = accountAdmin.getAccountByEmail(uniqueFieldValue); break; - case LOCAL_ID: - long id = parseLocalId(uniqueFieldValue); - toReturn = accountAdmin.getAccountById(id); - break; - case GUID: - toReturn = accountAdmin.getAccountByGuid(uniqueFieldValue); - break; - case DISPLAY_NAME: - toReturn = accountAdmin.getAccountByName(uniqueFieldValue); - break; - case USERNAME: - toReturn = accountAdmin.getAccountByUserName(uniqueFieldValue); - break; default: toReturn = ResultSets.emptyResultSet(); break; diff --git a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/SubscriptionAdminImpl.java b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/SubscriptionAdminImpl.java index 0bb8d011d50..a374a1f607e 100644 --- a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/SubscriptionAdminImpl.java +++ b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/SubscriptionAdminImpl.java @@ -12,7 +12,6 @@ package org.eclipse.osee.account.admin.internal; import java.util.Map; import org.eclipse.osee.account.admin.Account; -import org.eclipse.osee.account.admin.AccountAdmin; import org.eclipse.osee.account.admin.AccountField; import org.eclipse.osee.account.admin.Subscription; import org.eclipse.osee.account.admin.SubscriptionAdmin; @@ -20,6 +19,8 @@ import org.eclipse.osee.account.admin.SubscriptionGroup; import org.eclipse.osee.account.admin.ds.SubscriptionStorage; import org.eclipse.osee.account.admin.internal.validator.Validator; import org.eclipse.osee.account.admin.internal.validator.Validators; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.ResultSet; import org.eclipse.osee.framework.jdk.core.util.Conditions; import org.eclipse.osee.logger.Log; @@ -31,9 +32,7 @@ public class SubscriptionAdminImpl implements SubscriptionAdmin { private Log logger; private SubscriptionStorage storage; - private AccountAdmin accountAdmin; - private SubscriptionResolver resolver; private Validator validator; public void setLogger(Log logger) { @@ -44,15 +43,9 @@ public class SubscriptionAdminImpl implements SubscriptionAdmin { this.storage = storage; } - public void setAccountAdmin(AccountAdmin accountAdmin) { - this.accountAdmin = accountAdmin; - } - public void start(Map props) { logger.trace("Starting SubscriptionsAdminImpl..."); - validator = Validators.newSubscriptionValidator(logger, storage); - resolver = new SubscriptionResolver(validator, this); update(props); } @@ -72,36 +65,26 @@ public class SubscriptionAdminImpl implements SubscriptionAdmin { return validator; } - private SubscriptionResolver getResolver() { - return resolver; - } - @Override - public ResultSet getSubscriptionsByAccountUniqueField(String uniqueField) { - ResultSet result = accountAdmin.getAccountByUniqueField(uniqueField); - Account account = result.getExactlyOne(); - return getStorage().getSubscriptionsByAccountLocalId(account.getId()); + public SubscriptionGroup getSubscriptionGroupById(SubscriptionGroupId subscriptionId) { + return getStorage().getSubscriptionGroupById(subscriptionId); } @Override - public Subscription getSubscription(String subscriptionUuid) { - Conditions.checkNotNull(subscriptionUuid, "subscription uuid"); - return getStorage().getSubscription(subscriptionUuid); + public ResultSet getSubscriptionsByAccountId(ArtifactId accountId) { + return getStorage().getSubscriptionsByAccountId(accountId); } @Override - public boolean setSubscriptionActive(String subscriptionUuid, boolean active) { - Subscription subscription = getSubscription(subscriptionUuid); - return setSubscriptionActive(subscription, active); + public Subscription getSubscriptionsByEncodedId(String encodedId) { + return getStorage().getSubscriptionByEncodedId(encodedId); } @Override public boolean setSubscriptionActive(Subscription subscription, boolean active) { boolean modified = false; if (subscription != null && subscription.isActive() != active) { - long accountId = subscription.getAccountId(); - long groupId = subscription.getGroupId(); - getStorage().updateSubscription(accountId, groupId, active); + getStorage().updateSubscription(subscription, active); modified = true; } return modified; @@ -113,7 +96,7 @@ public class SubscriptionAdminImpl implements SubscriptionAdmin { } @Override - public SubscriptionGroup createSubscriptionGroup(String groupName) { + public SubscriptionGroupId createSubscriptionGroup(String groupName) { Conditions.checkNotNull(groupName, "group name"); Validator validator = getValidator(); @@ -123,66 +106,13 @@ public class SubscriptionAdminImpl implements SubscriptionAdmin { } @Override - public boolean deleteSubscriptionGroupByUniqueField(String groupId) { - boolean modified = false; - ResultSet results = getSubscriptionGroupByUniqueField(groupId); - SubscriptionGroup group = results.getOneOrNull(); - if (group != null) { - getStorage().deleteSubscriptionGroup(group); - modified = true; - } - return modified; - } - - @Override - public ResultSet getSubscriptionGroupByUniqueField(String groupUniqueField) { - return getResolver().resolveSubscriptionGroup(groupUniqueField); - } - - @Override - public ResultSet getSubscriptionGroupMembersByUniqueField(String groupUniqueField) { - return getResolver().resolveSubscriptionGroupMembersByGroupUniqueField(groupUniqueField); - } - - @Override - public ResultSet getSubscriptionGroupByLocalId(long groupId) { - return getStorage().getSubscriptionGroupByLocalId(groupId); - } - - @Override - public ResultSet getSubscriptionGroupByName(String groupName) { - Conditions.checkNotNull(groupName, "group name"); - return getStorage().getSubscriptionGroupByName(groupName); - } - - @Override - public ResultSet getSubscriptionGroupByGuid(String groupUuid) { - Conditions.checkNotNull(groupUuid, "group uuid"); - return getStorage().getSubscriptionGroupByGuid(groupUuid); - } - - @Override - public ResultSet getSubscriptionGroupMembersByLocalId(long groupId) { - return getStorage().getSubscriptionGroupMembersByLocalId(groupId); - } - - @Override - public ResultSet getSubscriptionGroupMembersByName(String groupName) { - Conditions.checkNotNull(groupName, "group name"); - return getStorage().getSubscriptionGroupMembersByName(groupName); - } - - @Override - public ResultSet getSubscriptionGroupMembersByGuid(String groupUuid) { - Conditions.checkNotNull(groupUuid, "group uuid"); - return getStorage().getSubscriptionGroupMembersByGuid(groupUuid); + public boolean deleteSubscriptionById(SubscriptionGroupId subscriptionId) { + return getStorage().deleteSubscriptionGroup(subscriptionId); } @Override - public ResultSet getSubscriptionsByGuid(String guid) { - ResultSet result = accountAdmin.getAccountByGuid(guid); - Account account = result.getExactlyOne(); - return getStorage().getSubscriptionsByAccountLocalId(account.getId()); + public ResultSet getSubscriptionMembersOfSubscriptionById(SubscriptionGroupId subscriptionId) { + return getStorage().getMembersOfSubscriptionGroupById(subscriptionId); } } diff --git a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/SubscriptionResolver.java b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/SubscriptionResolver.java index 1d869f659bc..9b9aa849168 100644 --- a/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/SubscriptionResolver.java +++ b/plugins/org.eclipse.osee.account.admin/src/org/eclipse/osee/account/admin/internal/SubscriptionResolver.java @@ -11,73 +11,25 @@ package org.eclipse.osee.account.admin.internal; import org.eclipse.osee.account.admin.Account; -import org.eclipse.osee.account.admin.AccountField; import org.eclipse.osee.account.admin.SubscriptionAdmin; -import org.eclipse.osee.account.admin.SubscriptionGroup; -import org.eclipse.osee.account.admin.internal.validator.Validator; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; import org.eclipse.osee.framework.jdk.core.type.ResultSet; -import org.eclipse.osee.framework.jdk.core.type.ResultSets; -import org.eclipse.osee.framework.jdk.core.util.Conditions; /** * @author Roberto E. Escobar */ public class SubscriptionResolver { - private final Validator validator; private final SubscriptionAdmin subscriptionsAdmin; - public SubscriptionResolver(Validator validator, SubscriptionAdmin subscriptionsAdmin) { + public SubscriptionResolver(SubscriptionAdmin subscriptionsAdmin) { super(); - this.validator = validator; this.subscriptionsAdmin = subscriptionsAdmin; } - private long parseLocalId(String uniqueFieldValue) { - return Long.valueOf(uniqueFieldValue); - } - - public ResultSet resolveSubscriptionGroup(String uniqueFieldValue) { - Conditions.checkNotNullOrEmpty(uniqueFieldValue, "subscription group unique field value"); - ResultSet toReturn; - AccountField type = validator.guessFormatType(uniqueFieldValue); - switch (type) { - case LOCAL_ID: - long id = parseLocalId(uniqueFieldValue); - toReturn = subscriptionsAdmin.getSubscriptionGroupByLocalId(id); - break; - case GUID: - toReturn = subscriptionsAdmin.getSubscriptionGroupByGuid(uniqueFieldValue); - break; - case SUBSCRIPTION_GROUP_NAME: - toReturn = subscriptionsAdmin.getSubscriptionGroupByName(uniqueFieldValue); - break; - default: - toReturn = ResultSets.emptyResultSet(); - break; - } - return toReturn; - } - - public ResultSet resolveSubscriptionGroupMembersByGroupUniqueField(String uniqueFieldValue) { - Conditions.checkNotNullOrEmpty(uniqueFieldValue, "subscription group unique field value"); + public ResultSet getSubscriptionMembersById(SubscriptionGroupId groupId) { ResultSet toReturn; - AccountField type = validator.guessFormatType(uniqueFieldValue); - switch (type) { - case LOCAL_ID: - long id = parseLocalId(uniqueFieldValue); - toReturn = subscriptionsAdmin.getSubscriptionGroupMembersByLocalId(id); - break; - case GUID: - toReturn = subscriptionsAdmin.getSubscriptionGroupMembersByGuid(uniqueFieldValue); - break; - case SUBSCRIPTION_GROUP_NAME: - toReturn = subscriptionsAdmin.getSubscriptionGroupMembersByName(uniqueFieldValue); - break; - default: - toReturn = ResultSets.emptyResultSet(); - break; - } + toReturn = subscriptionsAdmin.getSubscriptionMembersOfSubscriptionById(groupId); return toReturn; } } diff --git a/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/AccountClient.java b/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/AccountClient.java index a942c26f9aa..bf6d20dfe60 100644 --- a/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/AccountClient.java +++ b/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/AccountClient.java @@ -30,7 +30,7 @@ import org.eclipse.osee.framework.jdk.core.type.ResultSet; *
  • User name
  • *
  • Display name
  • * - * + * * @author Roberto E. Escobar */ public interface AccountClient { @@ -47,22 +47,22 @@ public interface AccountClient { AccountInfoData createAccount(String userName, AccountInput input); - boolean deleteAccount(String uuid); + boolean deleteAccount(Long accountId); ResultSet getAccountSessionDataByUniqueField(String accountId); ResultSet getAllAccounts(); - AccountDetailsData getAccountDetailsByUniqueField(String accountId); + AccountDetailsData getAccountDetailsById(Long accountId); - AccountPreferencesData getAccountPreferencesByUniqueField(String accountId); + AccountPreferencesData getAccountPreferencesById(Long accountId); - boolean setAccountActive(String accountId, boolean active); + boolean setAccountActive(Long accountId, boolean active); - boolean isAccountActive(String accountId); + boolean isAccountActive(Long accountId); - boolean setAccountPreferences(String accountId, Map preferences); + boolean setAccountPreferences(Long accountId, Map preferences); - ResultSet getUnsubscribeUris(String userUuid, Collection groupNames); + ResultSet getUnsubscribeUris(Long accountId, Collection groupNames); } diff --git a/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientImpl.java b/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientImpl.java index 163e684140d..f6192e60777 100644 --- a/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientImpl.java +++ b/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientImpl.java @@ -116,7 +116,7 @@ public class AccountClientImpl implements AccountClient { } @Override - public boolean deleteAccount(String accountId) { + public boolean deleteAccount(Long accountId) { URI uri = UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_ID_TEMPLATE).build(accountId); try { Response response = newTarget(uri).request().delete(); @@ -152,7 +152,7 @@ public class AccountClientImpl implements AccountClient { } @Override - public AccountDetailsData getAccountDetailsByUniqueField(String accountId) { + public AccountDetailsData getAccountDetailsById(Long accountId) { URI uri = UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_ID_TEMPLATE).build(accountId); try { return newTarget(uri).request(MediaType.APPLICATION_JSON_TYPE).get(AccountDetailsData.class); @@ -162,7 +162,7 @@ public class AccountClientImpl implements AccountClient { } @Override - public AccountPreferencesData getAccountPreferencesByUniqueField(String accountId) { + public AccountPreferencesData getAccountPreferencesById(Long accountId) { URI uri = UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_ID_TEMPLATE).path(ACCOUNT_PREFERENCES).build( accountId); try { @@ -173,7 +173,7 @@ public class AccountClientImpl implements AccountClient { } @Override - public boolean setAccountActive(String accountId, boolean active) { + public boolean setAccountActive(Long accountId, boolean active) { URI uri = UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_ID_TEMPLATE).path(ACCOUNT_ACTIVE).build(accountId); @@ -187,7 +187,7 @@ public class AccountClientImpl implements AccountClient { } @Override - public boolean isAccountActive(String accountId) { + public boolean isAccountActive(Long accountId) { URI uri = UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_ID_TEMPLATE).path(ACCOUNT_ACTIVE).build(accountId); @@ -218,7 +218,7 @@ public class AccountClientImpl implements AccountClient { } @Override - public boolean setAccountPreferences(String accountId, Map preferences) { + public boolean setAccountPreferences(Long accountId, Map preferences) { URI uri = UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_ID_TEMPLATE).path(ACCOUNT_PREFERENCES).build( accountId); @@ -232,9 +232,9 @@ public class AccountClientImpl implements AccountClient { } } - private ResultSet getSubscriptionsForAccount(String userId) { + private ResultSet getSubscriptionsForAccount(Long accountId) { URI uri = - UriBuilder.fromUri(baseUri).path("subscriptions").path("for-account").path("{account-id}").build(userId); + UriBuilder.fromUri(baseUri).path("subscriptions").path("for-account").path("{account-id}").build(accountId); try { SubscriptionData[] data = newTarget(uri).request(MediaType.APPLICATION_JSON_TYPE).get(SubscriptionData[].class); @@ -245,9 +245,9 @@ public class AccountClientImpl implements AccountClient { } @Override - public ResultSet getUnsubscribeUris(String userUuid, Collection groupNames) { + public ResultSet getUnsubscribeUris(Long accountId, Collection groupNames) { ResultSet toReturn = ResultSets.emptyResultSet(); - ResultSet results = getSubscriptionsForAccount(userUuid); + ResultSet results = getSubscriptionsForAccount(accountId); if (!results.isEmpty()) { List infos = new ArrayList<>(); diff --git a/plugins/org.eclipse.osee.account.rest.model/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.account.rest.model/META-INF/MANIFEST.MF index 696765fd755..da189c26f90 100644 --- a/plugins/org.eclipse.osee.account.rest.model/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.account.rest.model/META-INF/MANIFEST.MF @@ -6,6 +6,7 @@ Bundle-Version: 0.24.0.qualifier Bundle-Vendor: Eclipse Open System Engineering Environment Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: org.eclipse.osee.account.rest.model -Import-Package: org.eclipse.osee.framework.jdk.core.type, +Import-Package: org.eclipse.osee.framework.core.data, + org.eclipse.osee.framework.jdk.core.type, org.eclipse.osee.framework.jdk.core.util, org.json diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountActiveData.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountActiveData.java index 5530a80f3d5..272bc58f00b 100644 --- a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountActiveData.java +++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountActiveData.java @@ -19,15 +19,15 @@ import org.eclipse.osee.framework.jdk.core.type.Identity; @XmlRootElement public class AccountActiveData implements Identity { - private long accountId; + private Long accountId; private boolean isActive; private String uuid; - public long getAccountId() { + public Long getAccountId() { return accountId; } - public void setAccountId(long accountId) { + public void setAccountId(Long accountId) { this.accountId = accountId; } diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountInfoData.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountInfoData.java index 4e7b2bd4a3c..4d7851615e7 100644 --- a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountInfoData.java +++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountInfoData.java @@ -24,7 +24,7 @@ public class AccountInfoData implements Identity { private String userName; private String email; private String uuid; - private long accountId; + private Long accountId; private boolean isActive; private Set roles; @@ -56,11 +56,11 @@ public class AccountInfoData implements Identity { this.email = email; } - public long getAccountId() { + public Long getAccountId() { return accountId; } - public void setAccountId(long accountId) { + public void setAccountId(Long accountId) { this.accountId = accountId; } diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountPreferencesData.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountPreferencesData.java index e7ecda77eef..0a89e0f3518 100644 --- a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountPreferencesData.java +++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountPreferencesData.java @@ -20,14 +20,14 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class AccountPreferencesData { - private long id; + private Long id; private Map preferences; - public long getId() { + public Long getId() { return id; } - public void setId(long id) { + public void setId(Long id) { this.id = id; } diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountSessionData.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountSessionData.java index 350fae33301..5f546ea08db 100644 --- a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountSessionData.java +++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountSessionData.java @@ -18,7 +18,7 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class AccountSessionData { - private long accountId; + private Long accountId; private String token; public String getToken() { @@ -29,11 +29,11 @@ public class AccountSessionData { this.token = token; } - public long getAccountId() { + public Long getAccountId() { return accountId; } - public void setAccountId(long accountId) { + public void setAccountId(Long accountId) { this.accountId = accountId; } diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountSessionDetailsData.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountSessionDetailsData.java index 3eeb2612931..1f46c1ce446 100644 --- a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountSessionDetailsData.java +++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountSessionDetailsData.java @@ -19,17 +19,17 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class AccountSessionDetailsData { - private long accountId; + private Long accountId; private Date createdOn; private Date lastAccessedOn; private String accessedFrom; private String accessDetails; - public long getAccountId() { + public Long getAccountId() { return accountId; } - public void setAccountId(long accountId) { + public void setAccountId(Long accountId) { this.accountId = accountId; } diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/SubscriptionGroupData.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/SubscriptionGroupData.java index 9de16429f22..0ba12a3fac6 100644 --- a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/SubscriptionGroupData.java +++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/SubscriptionGroupData.java @@ -22,7 +22,7 @@ public class SubscriptionGroupData implements Identifiable { private String uuid; private String name; - private long id; + private SubscriptionGroupId groupId; @Override public String getName() { @@ -42,12 +42,12 @@ public class SubscriptionGroupData implements Identifiable { this.uuid = uuid; } - public long getId() { - return id; + public SubscriptionGroupId getSubscriptionGroupId() { + return groupId; } - public void setId(long id) { - this.id = id; + public void setSubscriptionGroupId(SubscriptionGroupId id) { + this.groupId = id; } @Override diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/SubscriptionGroupId.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/SubscriptionGroupId.java new file mode 100644 index 00000000000..b03dfdf931c --- /dev/null +++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/SubscriptionGroupId.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2016 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.account.rest.model; + +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.jdk.core.type.Named; +import org.eclipse.osee.framework.jdk.core.type.NamedIdentity; + +/** + * @author Angel Avila + */ +public class SubscriptionGroupId extends NamedIdentity implements ArtifactId { + + private final Long uuid; + + public SubscriptionGroupId(Long uuid) { + super(null, String.valueOf(uuid)); + this.uuid = uuid; + } + + @Override + public Long getUuid() { + return uuid; + } + + @Override + public boolean equals(Object other) { + boolean toReturn = false; + if (other instanceof SubscriptionGroupId) { + toReturn = this.getUuid().equals(((SubscriptionGroupId) other).getUuid()); + } + return toReturn; + } + + @Override + public int hashCode() { + return getUuid().hashCode(); + } + + @Override + public int compareTo(Named arg0) { + return getName().compareTo(arg0.getName()); + } + + @Override + public String toStringWithId() { + return String.format("[%s][%s]", getName(), getUuid()); + } +} diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountActiveResourceTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountActiveResourceTest.java index 0aabcf535e6..c9d66bf1454 100644 --- a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountActiveResourceTest.java +++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountActiveResourceTest.java @@ -17,13 +17,14 @@ import static org.mockito.MockitoAnnotations.initMocks; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import org.eclipse.osee.account.rest.model.AccountActiveData; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; /** * Test Case for {@link AccountActiveResource} - * + * * @author Roberto E. Escobar */ public class AccountActiveResourceTest { @@ -33,7 +34,7 @@ public class AccountActiveResourceTest { @Mock private AccountActiveData activeData; //@formatter:on - private String accountId; + private ArtifactId accountId; private AccountActiveResource resource; @Before diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountDataUtilTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountDataUtilTest.java index de3c5c33505..af4ebdcba1f 100644 --- a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountDataUtilTest.java +++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountDataUtilTest.java @@ -21,12 +21,14 @@ import org.eclipse.osee.account.rest.model.AccountSessionData; import org.eclipse.osee.account.rest.model.AccountSessionDetailsData; import org.eclipse.osee.account.rest.model.SubscriptionData; import org.eclipse.osee.account.rest.model.SubscriptionGroupData; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.junit.Test; import org.mockito.Mockito; /** * Test Case for {@link AccountDataUtil} - * + * * @author Roberto E. Escobar */ public class AccountDataUtilTest { @@ -51,7 +53,7 @@ public class AccountDataUtilTest { AccountSessionData actual = AccountDataUtil.asSessionData(access); - assertEquals(123L, actual.getAccountId()); + assertEquals((Long) 123L, actual.getAccountId()); assertEquals("t1", actual.getToken()); } @@ -60,8 +62,8 @@ public class AccountDataUtilTest { Subscription subscription = Mockito.mock(Subscription.class); when(subscription.getGuid()).thenReturn("ABCDE"); when(subscription.getName()).thenReturn("group-1"); - when(subscription.getGroupId()).thenReturn(98765L); - when(subscription.getAccountId()).thenReturn(123145L); + when(subscription.getGroupId()).thenReturn(new SubscriptionGroupId(98765L)); + when(subscription.getAccountId()).thenReturn(TokenFactory.createArtifactId(123145L)); when(subscription.getAccountName()).thenReturn("account-1"); when(subscription.isActive()).thenReturn(true); @@ -81,13 +83,13 @@ public class AccountDataUtilTest { SubscriptionGroup group = Mockito.mock(SubscriptionGroup.class); when(group.getGuid()).thenReturn("ABCDE"); when(group.getName()).thenReturn("group-1"); - when(group.getId()).thenReturn(98765L); + when(group.getId()).thenReturn(new SubscriptionGroupId(98765L)); SubscriptionGroupData actual = AccountDataUtil.asSubscriptionGroupData(group); assertEquals("ABCDE", actual.getGuid()); assertEquals("group-1", actual.getName()); - assertEquals(98765L, actual.getId()); + assertEquals((Long) 98765L, actual.getSubscriptionGroupId().getUuid()); assertEquals(true, actual.matches(group)); assertEquals(true, actual.equals(group)); @@ -108,7 +110,7 @@ public class AccountDataUtilTest { return access; } - private static void assertAccess(AccountSessionDetailsData actual, long id, Date created, Date accessed, String accessFrom, String accessDetails) { + private static void assertAccess(AccountSessionDetailsData actual, Long id, Date created, Date accessed, String accessFrom, String accessDetails) { assertEquals(accessDetails, actual.getAccessDetails()); assertEquals(accessFrom, actual.getAccessedFrom()); assertEquals(id, actual.getAccountId()); diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountOpsTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountOpsTest.java index 77c6db2d8d1..059d7de5197 100644 --- a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountOpsTest.java +++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountOpsTest.java @@ -40,7 +40,8 @@ import org.eclipse.osee.account.rest.model.AccountPreferencesData; import org.eclipse.osee.account.rest.model.AccountPreferencesInput; import org.eclipse.osee.account.rest.model.AccountSessionData; import org.eclipse.osee.account.rest.model.AccountSessionDetailsData; -import org.eclipse.osee.framework.jdk.core.type.Identifiable; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.jdk.core.type.ResultSet; import org.eclipse.osee.framework.jdk.core.type.ResultSets; import org.eclipse.osee.framework.jdk.core.util.GUID; @@ -58,7 +59,7 @@ import org.mockito.MockitoAnnotations; */ public class AccountOpsTest { - private static final String ACCOUNT_UID = "hello@hello.com"; + private static final ArtifactId ACCOUNT_UID = TokenFactory.createArtifactId(235622L); //@formatter:off @Mock private AccountAdmin accountAdmin; @@ -95,26 +96,22 @@ public class AccountOpsTest { ArgumentCaptor captor = ArgumentCaptor.forClass(CreateAccountRequest.class); - @SuppressWarnings("unchecked") - Identifiable id = mock(Identifiable.class); - when(id.getGuid()).thenReturn(guid); + ArtifactId newAccountId = TokenFactory.createArtifactId(235151L); - when(accountAdmin.createAccount(any(CreateAccountRequest.class))).thenReturn(id); + when(accountAdmin.createAccount(any(CreateAccountRequest.class))).thenReturn(newAccountId); - long accountId = 1982671L; - Account account = mockAccount(accountId, guid, name, email, username, active); + Account account = mockAccount(newAccountId, guid, name, email, username, active); ResultSet result = ResultSets.singleton(account); - when(accountAdmin.getAccountByGuid(guid)).thenReturn(result); + when(accountAdmin.getAccountById(newAccountId)).thenReturn(result); AccountInfoData actual = ops.createAccount(username, input); verify(accountAdmin).createAccount(captor.capture()); CreateAccountRequest request = captor.getValue(); assertNotNull(request); - assertAccount(actual, accountId, guid, name, email, username, active); + assertAccount(actual, newAccountId, guid, name, email, username, active); assertEquals(name, request.getDisplayName()); assertEquals(email, request.getEmail()); - assertEquals(username, request.getUserName()); assertEquals(active, request.isActive()); assertEquals(map, request.getPreferences()); } @@ -150,7 +147,7 @@ public class AccountOpsTest { AccountLoginRequest request = captor.getValue(); AccessDetails details = request.getDetails(); assertNotNull(details); - assertEquals(789L, actual.getAccountId()); + assertEquals((Long) 789L, actual.getAccountId()); assertEquals("t3", actual.getToken()); assertEquals(scheme, request.getScheme()); @@ -212,7 +209,7 @@ public class AccountOpsTest { AccountSession access3 = mockAccess(789L, "t3", d5, d6, "f3", "d3"); ResultSet result = ResultSets.newResultSet(access1, access2, access3); - when(accountAdmin.getAccountSessionByUniqueField(ACCOUNT_UID)).thenReturn(result); + when(accountAdmin.getAccountSessionById(ACCOUNT_UID)).thenReturn(result); List actual = ops.getAccountSessionById(ACCOUNT_UID); @@ -222,24 +219,24 @@ public class AccountOpsTest { assertAccess(iterator.next(), 456L, d3, d4, "f2", "d2"); assertAccess(iterator.next(), 789L, d5, d6, "f3", "d3"); - verify(accountAdmin).getAccountSessionByUniqueField(ACCOUNT_UID); + verify(accountAdmin).getAccountSessionById(ACCOUNT_UID); } @Test public void testGetAccountData() { - Account account = mockAccount(456L, "DEF", "acc2", "acc2@email.com", "u2", true); + Account account = mockAccount(TokenFactory.createArtifactId(456L), "DEF", "acc2", "acc2@email.com", "u2", true); ResultSet accounts = ResultSets.singleton(account); - when(accountAdmin.getAccountByUniqueField(ACCOUNT_UID)).thenReturn(accounts); + when(accountAdmin.getAccountById(ACCOUNT_UID)).thenReturn(accounts); AccountInfoData actual = ops.getAccountData(ACCOUNT_UID); - assertAccount(actual, 456L, "DEF", "acc2", "acc2@email.com", "u2", true); - verify(accountAdmin).getAccountByUniqueField(ACCOUNT_UID); + assertAccount(actual, TokenFactory.createArtifactId(456L), "DEF", "acc2", "acc2@email.com", "u2", true); + verify(accountAdmin).getAccountById(ACCOUNT_UID); } @Test public void testGetAccountDetailsData() { - Account account = mockAccount(789L, "GHI", "acc3", "acc3@email.com", "u3", true); + Account account = mockAccount(TokenFactory.createArtifactId(789L), "GHI", "acc3", "acc3@email.com", "u3", true); Map map = new HashMap<>(); map.put("a", "1"); map.put("b", "2"); @@ -251,21 +248,21 @@ public class AccountOpsTest { when(account.getPreferences()).thenReturn(preferences); ResultSet accounts = ResultSets.singleton(account); - when(accountAdmin.getAccountByUniqueField(ACCOUNT_UID)).thenReturn(accounts); + when(accountAdmin.getAccountById(ACCOUNT_UID)).thenReturn(accounts); AccountDetailsData actual = ops.getAccountDetailsData(ACCOUNT_UID); - assertAccount(actual, 789L, "GHI", "acc3", "acc3@email.com", "u3", true); + assertAccount(actual, TokenFactory.createArtifactId(789L), "GHI", "acc3", "acc3@email.com", "u3", true); AccountPreferencesData actualPrefs = actual.getPreferences(); Map actualMap = actualPrefs.getMap(); - assertEquals(789L, actualPrefs.getId()); + assertEquals((Long) 789L, actualPrefs.getId()); assertEquals(3, actualMap.size()); assertEquals("1", actualMap.get("a")); assertEquals("2", actualMap.get("b")); assertEquals("3", actualMap.get("c")); - verify(accountAdmin).getAccountByUniqueField(ACCOUNT_UID); + verify(accountAdmin).getAccountById(ACCOUNT_UID); } @Test @@ -283,10 +280,10 @@ public class AccountOpsTest { when(account.getPreferences()).thenReturn(preferences); ResultSet accounts = ResultSets.singleton(account); - when(accountAdmin.getAccountByUniqueField(ACCOUNT_UID)).thenReturn(accounts); + when(accountAdmin.getAccountById(ACCOUNT_UID)).thenReturn(accounts); - AccountPreferencesData actual = ops.getAccountPreferencesData(ACCOUNT_UID); - assertEquals(123L, actual.getId()); + AccountPreferencesData actual = ops.getAccountPreferencesDataById(ACCOUNT_UID); + assertEquals((Long) 123L, actual.getId()); Map actualPrefs = actual.getMap(); assertEquals(3, actualPrefs.size()); @@ -294,14 +291,14 @@ public class AccountOpsTest { assertEquals("2", actualPrefs.get("b")); assertEquals("3", actualPrefs.get("c")); - verify(accountAdmin).getAccountByUniqueField(ACCOUNT_UID); + verify(accountAdmin).getAccountById(ACCOUNT_UID); } @Test public void testGetAllAccounts() { - Account account1 = mockAccount(123L, "ABC", "acc1", "acc1@email.com", "u1", true); - Account account2 = mockAccount(456L, "DEF", "acc2", "acc2@email.com", "u2", false); - Account account3 = mockAccount(789L, "GHI", "acc3", "acc3@email.com", "u3", true); + Account account1 = mockAccount(TokenFactory.createArtifactId(123L), "ABC", "acc1", "acc1@email.com", "u1", true); + Account account2 = mockAccount(TokenFactory.createArtifactId(456L), "DEF", "acc2", "acc2@email.com", "u2", false); + Account account3 = mockAccount(TokenFactory.createArtifactId(789L), "GHI", "acc3", "acc3@email.com", "u3", true); ResultSet accounts = ResultSets.newResultSet(account1, account2, account3); @@ -312,9 +309,9 @@ public class AccountOpsTest { assertEquals(3, actual.size()); Iterator iterator = actual.iterator(); - assertAccount(iterator.next(), 123L, "ABC", "acc1", "acc1@email.com", "u1", true); - assertAccount(iterator.next(), 456L, "DEF", "acc2", "acc2@email.com", "u2", false); - assertAccount(iterator.next(), 789L, "GHI", "acc3", "acc3@email.com", "u3", true); + assertAccount(iterator.next(), TokenFactory.createArtifactId(123L), "ABC", "acc1", "acc1@email.com", "u1", true); + assertAccount(iterator.next(), TokenFactory.createArtifactId(456L), "DEF", "acc2", "acc2@email.com", "u2", false); + assertAccount(iterator.next(), TokenFactory.createArtifactId(789L), "GHI", "acc3", "acc3@email.com", "u3", true); verify(accountAdmin).getAllAccounts(); } @@ -322,22 +319,22 @@ public class AccountOpsTest { @Test public void testIsActive() { String guid = GUID.create(); - long accountId = 23127916023214L; + ArtifactId accountId = TokenFactory.createArtifactId(23127916023214L); Account account = mock(Account.class); ResultSet result = ResultSets.singleton(account); when(account.getGuid()).thenReturn(guid); - when(account.getId()).thenReturn(accountId); + when(account.getId()).thenReturn(accountId.getUuid()); when(account.isActive()).thenReturn(true); - when(accountAdmin.getAccountByUniqueField(ACCOUNT_UID)).thenReturn(result); + when(accountAdmin.getAccountById(ACCOUNT_UID)).thenReturn(result); AccountActiveData actual = ops.isActive(ACCOUNT_UID); - assertEquals(accountId, actual.getAccountId()); + assertEquals(accountId.getUuid(), actual.getAccountId()); assertEquals(guid, actual.getGuid()); assertEquals(true, actual.isActive()); - verify(accountAdmin).getAccountByUniqueField(ACCOUNT_UID); + verify(accountAdmin).getAccountById(ACCOUNT_UID); } @Test @@ -382,7 +379,7 @@ public class AccountOpsTest { return access; } - private static void assertAccess(AccountSessionDetailsData actual, long id, Date created, Date accessed, String accessFrom, String accessDetails) { + private static void assertAccess(AccountSessionDetailsData actual, Long id, Date created, Date accessed, String accessFrom, String accessDetails) { assertEquals(accessDetails, actual.getAccessDetails()); assertEquals(accessFrom, actual.getAccessedFrom()); assertEquals(id, actual.getAccountId()); @@ -390,9 +387,9 @@ public class AccountOpsTest { assertEquals(accessed, actual.getLastAccessedOn()); } - private static Account mockAccount(long id, String uuid, String name, String email, String username, boolean active) { + private static Account mockAccount(ArtifactId id, String uuid, String name, String email, String username, boolean active) { Account account = Mockito.mock(Account.class); - when(account.getId()).thenReturn(id); + when(account.getId()).thenReturn(id.getUuid()); when(account.getGuid()).thenReturn(uuid); when(account.getName()).thenReturn(name); when(account.getEmail()).thenReturn(email); @@ -401,8 +398,8 @@ public class AccountOpsTest { return account; } - private static void assertAccount(AccountInfoData data, long id, String uuid, String name, String email, String username, boolean active) { - assertEquals(id, data.getAccountId()); + private static void assertAccount(AccountInfoData data, ArtifactId id, String uuid, String name, String email, String username, boolean active) { + assertEquals(id.getUuid(), data.getAccountId()); assertEquals(uuid, data.getGuid()); assertEquals(name, data.getName()); assertEquals(email, data.getEmail()); diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResourceTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResourceTest.java index e6a40bca39a..71c7fead703 100644 --- a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResourceTest.java +++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResourceTest.java @@ -20,18 +20,20 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import org.eclipse.osee.account.rest.model.AccountPreferencesData; import org.eclipse.osee.account.rest.model.AccountPreferencesInput; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; /** * Test Case for {@link AccountPreferencesResource} - * + * * @author Roberto E. Escobar */ public class AccountPreferencesResourceTest { - private static final String ACCOUNT_ID = "hello@hello.com"; + private static final ArtifactId ACCOUNT_ID = TokenFactory.createArtifactId(134522L); //@formatter:off @Mock private AccountOps accountOps; @@ -50,12 +52,12 @@ public class AccountPreferencesResourceTest { @Test public void testGetAccountPreferences() { - when(accountOps.getAccountPreferencesData(ACCOUNT_ID)).thenReturn(preferences); + when(accountOps.getAccountPreferencesDataById(ACCOUNT_ID)).thenReturn(preferences); AccountPreferencesData actual = resource.getAccountPreferences(); assertEquals(preferences, actual); - verify(accountOps).getAccountPreferencesData(ACCOUNT_ID); + verify(accountOps).getAccountPreferencesDataById(ACCOUNT_ID); } @Test diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountResourceTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountResourceTest.java index 42c13d59afb..5a041b52c67 100644 --- a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountResourceTest.java +++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountResourceTest.java @@ -24,25 +24,28 @@ import javax.ws.rs.core.UriInfo; import org.eclipse.osee.account.rest.model.AccountDetailsData; import org.eclipse.osee.account.rest.model.AccountInfoData; import org.eclipse.osee.account.rest.model.AccountInput; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; /** * Test Case for {@link AccountResource} - * + * * @author Roberto E. Escobar */ public class AccountResourceTest { - private static final String ACCOUNT_ID = "hello@hello.com"; + private static final String NEW_USERNAME = "helloWorld"; + private static final ArtifactId ACCOUNT_ID = TokenFactory.createArtifactId(93253L); //@formatter:off @Mock private AccountOps accountOps; @Mock private AccountInput accountInput; @Mock private AccountInfoData accountInfoData; @Mock private AccountDetailsData details; - + @Mock private UriInfo uriInfo; //@formatter:on @@ -55,16 +58,6 @@ public class AccountResourceTest { resource = new AccountResource(accountOps, ACCOUNT_ID); } - @Test - public void testCreateAccount() { - when(accountOps.createAccount(ACCOUNT_ID, accountInput)).thenReturn(accountInfoData); - - AccountInfoData actual = resource.createAccount(accountInput); - assertEquals(accountInfoData, actual); - - verify(accountOps).createAccount(ACCOUNT_ID, accountInput); - } - @Test public void testDeleteAccount() { when(accountOps.deleteAccount(ACCOUNT_ID)).thenReturn(true); @@ -102,7 +95,7 @@ public class AccountResourceTest { // Ensure resource constructed correctly; actual.getAccountPreferences(); - verify(accountOps).getAccountPreferencesData(ACCOUNT_ID); + verify(accountOps).getAccountPreferencesDataById(ACCOUNT_ID); } @Test @@ -127,8 +120,8 @@ public class AccountResourceTest { @Test public void testGetSubscriptions() { - URI uri = - UriBuilder.fromPath("http://localhost:8089/oseex/accounts/{account-id}/subscriptions").build(ACCOUNT_ID); + URI uri = UriBuilder.fromPath("http://localhost:8089/oseex/accounts/{account-id}/subscriptions").build( + ACCOUNT_ID.getUuid()); when(uriInfo.getRequestUri()).thenReturn(uri); Response response = resource.getSubscriptions(uriInfo); @@ -139,7 +132,7 @@ public class AccountResourceTest { URI location = (URI) response.getMetadata().getFirst(HttpHeaders.LOCATION); URI expectedLocation = UriBuilder.fromUri(uri).path("..").path("..").path("..").path("subscriptions").path("for-account").path( - "{account-id}").build(ACCOUNT_ID); + "{account-id}").build(ACCOUNT_ID.getUuid()); assertEquals(expectedLocation, location); } diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountSessionsResourceTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountSessionsResourceTest.java index 93ce04f5b87..42486f48852 100644 --- a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountSessionsResourceTest.java +++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountSessionsResourceTest.java @@ -17,18 +17,20 @@ import static org.mockito.MockitoAnnotations.initMocks; import java.util.ArrayList; import java.util.List; import org.eclipse.osee.account.rest.model.AccountSessionDetailsData; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; /** * Test Case for {@link AccountSessionsResource} - * + * * @author Roberto E. Escobar */ public class AccountSessionsResourceTest { - private static final String ACCOUNT_ID = "hello@hello.com"; + private static final ArtifactId ACCOUNT_ID = TokenFactory.createArtifactId(823952L); //@formatter:off @Mock private AccountOps accountOps; diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountsResourceTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountsResourceTest.java index 37c2ad9a949..6a5fffb7e88 100644 --- a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountsResourceTest.java +++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountsResourceTest.java @@ -11,7 +11,7 @@ package org.eclipse.osee.account.rest.internal; import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; @@ -19,18 +19,21 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.osee.account.rest.model.AccountInfoData; import org.eclipse.osee.account.rest.model.AccountInput; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; /** * Test Case for {@link AccountsResource} - * + * * @author Roberto E. Escobar */ public class AccountsResourceTest { - private static final String ACCOUNT_ID = "hello@hello.com"; + private static final String NEW_USERNAME = "helloWorld"; + private static final ArtifactId ACCOUNT_ID = TokenFactory.createArtifactId(93253L); //@formatter:off @Mock private AccountOps accountOps; @@ -47,6 +50,16 @@ public class AccountsResourceTest { resource = new AccountsResource(accountOps); } + @Test + public void testCreateAccount() { + when(accountOps.createAccount(NEW_USERNAME, input)).thenReturn(account); + + AccountInfoData actual = resource.createAccount(NEW_USERNAME, input); + assertEquals(account, actual); + + verify(accountOps).createAccount(NEW_USERNAME, input); + } + @Test public void testGetAccounts() { List accesses = new ArrayList<>(); @@ -59,21 +72,4 @@ public class AccountsResourceTest { assertArrayEquals(expected, actual); verify(accountOps).getAllAccounts(); } - - @Test - public void testGetAccount() { - AccountResource actual = resource.getAccount(ACCOUNT_ID); - assertNotNull(actual); - - // Ensure resource constructed correctly; - actual.createAccount(input); - verify(accountOps).createAccount(ACCOUNT_ID, input); - } - - @Test - public void testGetLoginResource() { - AccountLoginResource actual = resource.getLoginResource(); - assertNotNull(actual); - } - } diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/SubscriptionsResourceTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/SubscriptionsResourceTest.java index bc48349337b..b2c4d641a3c 100644 --- a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/SubscriptionsResourceTest.java +++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/SubscriptionsResourceTest.java @@ -23,6 +23,9 @@ import org.eclipse.osee.account.admin.SubscriptionGroup; import org.eclipse.osee.account.rest.model.AccountInfoData; import org.eclipse.osee.account.rest.model.SubscriptionData; import org.eclipse.osee.account.rest.model.SubscriptionGroupData; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.jdk.core.type.ResultSet; import org.eclipse.osee.framework.jdk.core.type.ResultSets; import org.junit.Before; @@ -33,31 +36,32 @@ import org.mockito.Mock; /** * Test Case for {@link SubscriptionsResource} - * + * * @author Roberto E. Escobar */ public class SubscriptionsResourceTest { - private static final String SUBSCRIPTION_UUID = "D_UhOLi6D7q_MbOiUYny75bUWxYdlHI9yCLyosilpDMYxRhasnqYvwCOlNEPgvrk"; + private static final String SUBSCRIPTION_ENCODED = + "D_UhOLi6D7q_MbOiUYny75bUWxYdlHI9yCLyosilpDMYxRhasnqYvwCOlNEPgvrk"; private static final boolean SUBSCRIPTION_IS_ACTIVE = true; private static final String ACCOUNT_UUID = "asdksa"; private static final String ACCOUNT_NAME = "account-1"; - private static final long ACCOUNT_ID = 3129303L; + private static final ArtifactId ACCOUNT_ID = TokenFactory.createArtifactId(3129303L); private static final String ACCOUNT_USERNAME = "sadfaa"; private static final String ACCOUNT_EMAIL = "hello@hello.com"; private static final boolean ACCOUNT_IS_ACTIVE = true; private static final String GROUP_UUID = "sadjha322"; private static final String GROUP_NAME = "group-1"; - private static final long GROUP_ID = 37219891L; + private static final SubscriptionGroupId GROUP_ID = new SubscriptionGroupId(37219891L); @Rule public ExpectedException thrown = ExpectedException.none(); //@formatter:off @Mock private SubscriptionAdmin manager; - + @Mock private Subscription subscription; @Mock private SubscriptionGroup group; @Mock private Account account; @@ -71,6 +75,7 @@ public class SubscriptionsResourceTest { resource = new SubscriptionsResource(manager); + when(subscription.getGroupId()).thenReturn(GROUP_ID); when(subscription.getGuid()).thenReturn(GROUP_UUID); when(subscription.getName()).thenReturn(GROUP_NAME); when(subscription.getAccountName()).thenReturn(ACCOUNT_NAME); @@ -82,7 +87,7 @@ public class SubscriptionsResourceTest { when(account.getGuid()).thenReturn(ACCOUNT_UUID); when(account.getName()).thenReturn(ACCOUNT_NAME); - when(account.getId()).thenReturn(ACCOUNT_ID); + when(account.getId()).thenReturn(ACCOUNT_ID.getUuid()); when(account.getUserName()).thenReturn(ACCOUNT_USERNAME); when(account.getEmail()).thenReturn(ACCOUNT_EMAIL); when(account.isActive()).thenReturn(ACCOUNT_IS_ACTIVE); @@ -91,70 +96,85 @@ public class SubscriptionsResourceTest { @Test public void testGetSubscriptions() { ResultSet results = ResultSets.singleton(subscription); - when(manager.getSubscriptionsByAccountUniqueField(ACCOUNT_UUID)).thenReturn(results); + when(manager.getSubscriptionsByAccountId(ACCOUNT_ID)).thenReturn(results); - SubscriptionData[] actual = resource.getSubscriptions(ACCOUNT_UUID); + SubscriptionData[] actual = resource.getSubscriptions(ACCOUNT_ID.getUuid()); assertEquals(1, actual.length); SubscriptionData data = actual[0]; checkSubscription(data, GROUP_UUID, GROUP_NAME, ACCOUNT_NAME, SUBSCRIPTION_IS_ACTIVE); - verify(manager).getSubscriptionsByAccountUniqueField(ACCOUNT_UUID); + verify(manager).getSubscriptionsByAccountId(ACCOUNT_ID); + } + + @Test + public void testGetSubscriptionEncoded() { + when(manager.getSubscriptionsByEncodedId(SUBSCRIPTION_ENCODED)).thenReturn(subscription); + + SubscriptionData actual = resource.getSubscriptionByEncoded(SUBSCRIPTION_ENCODED); + + checkSubscription(actual, GROUP_UUID, GROUP_NAME, ACCOUNT_NAME, SUBSCRIPTION_IS_ACTIVE); + verify(manager).getSubscriptionsByEncodedId(SUBSCRIPTION_ENCODED); } @Test public void testGetSubscription() { - when(manager.getSubscription(SUBSCRIPTION_UUID)).thenReturn(subscription); + when(manager.getSubscriptionsByEncodedId(SUBSCRIPTION_ENCODED)).thenReturn(subscription); - SubscriptionData actual = resource.getSubscription(SUBSCRIPTION_UUID); + SubscriptionData actual = resource.getSubscriptionByEncoded(SUBSCRIPTION_ENCODED); checkSubscription(actual, GROUP_UUID, GROUP_NAME, ACCOUNT_NAME, SUBSCRIPTION_IS_ACTIVE); - verify(manager).getSubscription(SUBSCRIPTION_UUID); + verify(manager).getSubscriptionsByEncodedId(SUBSCRIPTION_ENCODED); } @Test public void testSetSubscriptionActiveOk() { - when(manager.setSubscriptionActive(SUBSCRIPTION_UUID, true)).thenReturn(true); + when(manager.getSubscriptionsByEncodedId(SUBSCRIPTION_ENCODED)).thenReturn(subscription); + when(manager.setSubscriptionActive(subscription, true)).thenReturn(true); - Response response = resource.setSubscriptionActive(SUBSCRIPTION_UUID); + Response response = resource.setSubscriptionActive(SUBSCRIPTION_ENCODED); assertEquals(Status.OK.getStatusCode(), response.getStatus()); - verify(manager).setSubscriptionActive(SUBSCRIPTION_UUID, true); + verify(manager).setSubscriptionActive(subscription, true); } @Test public void testSetSubscriptionActiveNotModified() { - when(manager.setSubscriptionActive(SUBSCRIPTION_UUID, true)).thenReturn(false); + when(manager.getSubscriptionsByEncodedId(SUBSCRIPTION_ENCODED)).thenReturn(subscription); + when(manager.setSubscriptionActive(subscription, true)).thenReturn(false); - Response response = resource.setSubscriptionActive(SUBSCRIPTION_UUID); + Response response = resource.setSubscriptionActive(SUBSCRIPTION_ENCODED); assertEquals(Status.NOT_MODIFIED.getStatusCode(), response.getStatus()); - verify(manager).setSubscriptionActive(SUBSCRIPTION_UUID, true); + verify(manager).setSubscriptionActive(subscription, true); } @Test public void testSetSubscriptionInactiveOk() { - when(manager.setSubscriptionActive(SUBSCRIPTION_UUID, false)).thenReturn(true); + when(manager.getSubscriptionsByEncodedId(SUBSCRIPTION_ENCODED)).thenReturn(subscription); + when(manager.setSubscriptionActive(subscription, false)).thenReturn(true); - Response response = resource.setSubscriptionInactive(SUBSCRIPTION_UUID); + Response response = resource.setSubscriptionInactive(SUBSCRIPTION_ENCODED); assertEquals(Status.OK.getStatusCode(), response.getStatus()); - verify(manager).setSubscriptionActive(SUBSCRIPTION_UUID, false); + verify(manager).setSubscriptionActive(subscription, false); } @Test public void testSetSubscriptionInactiveMotModified() { - when(manager.setSubscriptionActive(SUBSCRIPTION_UUID, false)).thenReturn(false); + when(manager.getSubscriptionsByEncodedId(SUBSCRIPTION_ENCODED)).thenReturn(subscription); + when(manager.setSubscriptionActive(subscription, false)).thenReturn(false); - Response response = resource.setSubscriptionInactive(SUBSCRIPTION_UUID); + Response response = resource.setSubscriptionInactive(SUBSCRIPTION_ENCODED); assertEquals(Status.NOT_MODIFIED.getStatusCode(), response.getStatus()); - verify(manager).setSubscriptionActive(SUBSCRIPTION_UUID, false); + verify(manager).setSubscriptionActive(subscription, false); } @Test public void testGetSubscriptionGroups() { ResultSet results = ResultSets.singleton(group); when(manager.getSubscriptionGroups()).thenReturn(results); + when(manager.getSubscriptionGroupById(GROUP_ID)).thenReturn(group); SubscriptionGroupData[] actual = resource.getSubscriptionGroups(); @@ -164,20 +184,10 @@ public class SubscriptionsResourceTest { verify(manager).getSubscriptionGroups(); } - @Test - public void testGetSubscriptionGroup() { - ResultSet results = ResultSets.singleton(group); - when(manager.getSubscriptionGroupByUniqueField(GROUP_UUID)).thenReturn(results); - - SubscriptionGroupData actual = resource.getSubscriptionGroup(GROUP_UUID); - - checkSubscriptionGroup(actual, GROUP_UUID, GROUP_NAME, GROUP_ID); - verify(manager).getSubscriptionGroupByUniqueField(GROUP_UUID); - } - @Test public void testCreateSubscriptionGroup() { - when(manager.createSubscriptionGroup(GROUP_NAME)).thenReturn(group); + when(manager.createSubscriptionGroup(GROUP_NAME)).thenReturn(GROUP_ID); + when(manager.getSubscriptionGroupById(GROUP_ID)).thenReturn(group); SubscriptionGroupData actual = resource.createSubscriptionGroup(GROUP_NAME); @@ -187,35 +197,25 @@ public class SubscriptionsResourceTest { @Test public void testDeleteSubscriptionGroup() { - when(manager.deleteSubscriptionGroupByUniqueField(GROUP_UUID)).thenReturn(true); + when(manager.deleteSubscriptionById(GROUP_ID)).thenReturn(true); - Response actual = resource.deleteSubscriptionGroup(GROUP_UUID); + Response actual = resource.deleteSubscriptionGroup(GROUP_ID.getUuid()); assertEquals(Status.OK.getStatusCode(), actual.getStatus()); - verify(manager).deleteSubscriptionGroupByUniqueField(GROUP_UUID); - } - - @Test - public void testDeleteSubscriptionGroupNotModified() { - when(manager.deleteSubscriptionGroupByUniqueField(GROUP_UUID)).thenReturn(false); - - Response actual = resource.deleteSubscriptionGroup(GROUP_UUID); - assertEquals(Status.NOT_MODIFIED.getStatusCode(), actual.getStatus()); - - verify(manager).deleteSubscriptionGroupByUniqueField(GROUP_UUID); + verify(manager).deleteSubscriptionById(GROUP_ID); } @Test public void testGetSubscriptionGroupMembers() { ResultSet results = ResultSets.singleton(account); - when(manager.getSubscriptionGroupMembersByUniqueField(GROUP_UUID)).thenReturn(results); + when(manager.getSubscriptionMembersOfSubscriptionById(GROUP_ID)).thenReturn(results); - AccountInfoData[] actual = resource.getSubscriptionGroupMembers(GROUP_UUID); + AccountInfoData[] actual = resource.getSubscriptionGroupMembers(GROUP_ID.getUuid()); assertEquals(1, actual.length); AccountInfoData data = actual[0]; checkAccount(data, ACCOUNT_UUID, ACCOUNT_NAME, ACCOUNT_ID, ACCOUNT_USERNAME, ACCOUNT_EMAIL, ACCOUNT_IS_ACTIVE); - verify(manager).getSubscriptionGroupMembersByUniqueField(GROUP_UUID); + verify(manager).getSubscriptionMembersOfSubscriptionById(GROUP_ID); } private static void checkSubscription(SubscriptionData actual, String guid, String name, String accountName, boolean active) { @@ -225,16 +225,16 @@ public class SubscriptionsResourceTest { assertEquals(active, actual.isActive()); } - private static void checkSubscriptionGroup(SubscriptionGroupData actual, String guid, String name, long groupId) { + private static void checkSubscriptionGroup(SubscriptionGroupData actual, String guid, String name, SubscriptionGroupId groupId) { assertEquals(guid, actual.getGuid()); assertEquals(name, actual.getName()); - assertEquals(groupId, actual.getId()); + assertEquals(groupId, actual.getSubscriptionGroupId()); } - private static void checkAccount(AccountInfoData actual, String guid, String name, long accountId, String username, String email, boolean active) { + private static void checkAccount(AccountInfoData actual, String guid, String name, ArtifactId accountId, String username, String email, boolean active) { assertEquals(guid, actual.getGuid()); assertEquals(name, actual.getName()); - assertEquals(accountId, actual.getAccountId()); + assertEquals(accountId.getUuid(), actual.getAccountId()); assertEquals(username, actual.getUserName()); assertEquals(email, actual.getEmail()); assertEquals(active, actual.isActive()); diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/UnsubscribeResourceTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/UnsubscribeResourceTest.java index c2a111bf335..43c011fc638 100644 --- a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/UnsubscribeResourceTest.java +++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/UnsubscribeResourceTest.java @@ -24,6 +24,9 @@ import java.net.URI; import javax.ws.rs.core.UriBuilder; import org.eclipse.osee.account.admin.Subscription; import org.eclipse.osee.account.admin.SubscriptionAdmin; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.jdk.core.type.ViewModel; import org.junit.Before; import org.junit.Test; @@ -31,7 +34,7 @@ import org.mockito.Mock; /** * Test Case for {@link UnsubscribeResource} - * + * * @author Roberto E. Escobar */ public class UnsubscribeResourceTest { @@ -39,9 +42,9 @@ public class UnsubscribeResourceTest { private static final String SUBSCRIPTION_UUID = "D_UhOLi6D7q_MbOiUYny75bUWxYdlHI9yCLyosilpDMYxRhasnqYvwCOlNEPgvrk"; private static final String GROUP_UUID = "sadjha322"; - private static final long GROUP_ID = 37219891L; + private static final SubscriptionGroupId GROUP_ID = new SubscriptionGroupId(37219891L); private static final String GROUP_NAME = "group-1"; - private static final long ACCOUNT_ID = 3129303L; + private static final ArtifactId ACCOUNT_ID = TokenFactory.createArtifactId(3129303L); private static final String ACCOUNT_NAME = "account-1"; //@formatter:off @@ -66,7 +69,7 @@ public class UnsubscribeResourceTest { @Test public void testGetUnsubscribePageActiveSubscription() { - when(manager.getSubscription(SUBSCRIPTION_UUID)).thenReturn(subscription); + when(manager.getSubscriptionsByEncodedId(SUBSCRIPTION_UUID)).thenReturn(subscription); when(subscription.isActive()).thenReturn(true); when(subscription.getGuid()).thenReturn(SUBSCRIPTION_UUID); @@ -74,7 +77,7 @@ public class UnsubscribeResourceTest { ViewModel actual = resource.getUnsubscribePage(SUBSCRIPTION_UUID); - verify(manager).getSubscription(SUBSCRIPTION_UUID); + verify(manager).getSubscriptionsByEncodedId(SUBSCRIPTION_UUID); verify(subscription).isActive(); verify(subscription).getGuid(); @@ -86,12 +89,12 @@ public class UnsubscribeResourceTest { @Test public void testGetUnsubscribePageInActiveSubscription() { - when(manager.getSubscription(SUBSCRIPTION_UUID)).thenReturn(subscription); + when(manager.getSubscriptionsByEncodedId(SUBSCRIPTION_UUID)).thenReturn(subscription); when(subscription.isActive()).thenReturn(false); ViewModel actual = resource.getUnsubscribePage(SUBSCRIPTION_UUID); - verify(manager).getSubscription(SUBSCRIPTION_UUID); + verify(manager).getSubscriptionsByEncodedId(SUBSCRIPTION_UUID); verify(subscription).isActive(); verify(subscription, times(0)).getGuid(); @@ -102,12 +105,12 @@ public class UnsubscribeResourceTest { @Test public void testProcessUnsubscribePageSubscriptionRemoved() { - when(manager.getSubscription(SUBSCRIPTION_UUID)).thenReturn(subscription); + when(manager.getSubscriptionsByEncodedId(SUBSCRIPTION_UUID)).thenReturn(subscription); when(manager.setSubscriptionActive(subscription, false)).thenReturn(true); ViewModel actual = resource.processUnsubscribePage(SUBSCRIPTION_UUID); - verify(manager).getSubscription(SUBSCRIPTION_UUID); + verify(manager).getSubscriptionsByEncodedId(SUBSCRIPTION_UUID); verify(manager).setSubscriptionActive(subscription, false); assertEquals(UnsubscribeResource.UNSUBSCRIBE_SUCCESS_TEMPLATE, actual.getViewId()); @@ -117,12 +120,12 @@ public class UnsubscribeResourceTest { @Test public void testProcessUnsubscribePageSubscriptionNoChange() { - when(manager.getSubscription(SUBSCRIPTION_UUID)).thenReturn(subscription); + when(manager.getSubscriptionsByEncodedId(SUBSCRIPTION_UUID)).thenReturn(subscription); when(manager.setSubscriptionActive(subscription, false)).thenReturn(false); ViewModel actual = resource.processUnsubscribePage(SUBSCRIPTION_UUID); - verify(manager).getSubscription(SUBSCRIPTION_UUID); + verify(manager).getSubscriptionsByEncodedId(SUBSCRIPTION_UUID); verify(manager).setSubscriptionActive(subscription, false); assertEquals(UNSUBSCRIBE_NO_SUBSCRIPTION_TEMPLATE, actual.getViewId()); diff --git a/plugins/org.eclipse.osee.account.rest/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.account.rest/META-INF/MANIFEST.MF index 17ddddd8aa9..49d31e8ca02 100644 --- a/plugins/org.eclipse.osee.account.rest/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.account.rest/META-INF/MANIFEST.MF @@ -17,6 +17,7 @@ Import-Package: javax.annotation.security, org.eclipse.osee.account.rest.model, org.eclipse.osee.authentication.admin, org.eclipse.osee.authorization.admin, + org.eclipse.osee.framework.core.data, org.eclipse.osee.framework.core.util, org.eclipse.osee.framework.jdk.core.type, org.eclipse.osee.framework.jdk.core.util, diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountActiveResource.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountActiveResource.java index 6a1812b14a4..a4ecb8f3bb6 100644 --- a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountActiveResource.java +++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountActiveResource.java @@ -19,6 +19,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.ResponseBuilder; import org.eclipse.osee.account.rest.model.AccountActiveData; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.SystemRoles; /** @@ -27,16 +28,16 @@ import org.eclipse.osee.framework.jdk.core.type.SystemRoles; public class AccountActiveResource { private final AccountOps accountOps; - private final String accountId; + private final ArtifactId accountId; - public AccountActiveResource(AccountOps accountOps, String accountId) { + public AccountActiveResource(AccountOps accountOps, ArtifactId accountId) { this.accountOps = accountOps; this.accountId = accountId; } /** * Get account active status - * + * * @return account active information */ @GET @@ -48,7 +49,7 @@ public class AccountActiveResource { /** * Set account status to active - * + * * @return response * @response.representation.200.doc account status set to active * @response.representation.304.doc account active status not modified @@ -68,7 +69,7 @@ public class AccountActiveResource { /** * Set account status to inactive - * + * * @return response * @response.representation.200.doc account status set to inactive * @response.representation.304.doc account status not modified diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountDataUtil.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountDataUtil.java index 7774710df63..c2ac7427213 100644 --- a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountDataUtil.java +++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountDataUtil.java @@ -102,7 +102,7 @@ public final class AccountDataUtil { SubscriptionGroupData data = new SubscriptionGroupData(); data.setGuid(src.getGuid()); data.setName(src.getName()); - data.setId(src.getId()); + data.setSubscriptionGroupId(src.getId()); return data; } diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountOps.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountOps.java index ac287ae69e7..73b3f699403 100644 --- a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountOps.java +++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountOps.java @@ -31,7 +31,7 @@ import org.eclipse.osee.account.rest.model.AccountPreferencesInput; import org.eclipse.osee.account.rest.model.AccountSessionData; import org.eclipse.osee.account.rest.model.AccountSessionDetailsData; import org.eclipse.osee.account.rest.model.AccountWebPreferences; -import org.eclipse.osee.framework.jdk.core.type.Identifiable; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.ResultSet; /** @@ -64,8 +64,8 @@ public class AccountOps { }; } - public List getAccountSessionById(String accountId) { - ResultSet result = accountAdmin.getAccountSessionByUniqueField(accountId); + public List getAccountSessionById(ArtifactId accountId) { + ResultSet result = accountAdmin.getAccountSessionById(accountId); List toReturn = new ArrayList<>(); for (AccountSession session : result) { toReturn.add(AccountDataUtil.asAccountAccessData(session)); @@ -73,6 +73,12 @@ public class AccountOps { return toReturn; } + public AccountInfoData getAccountData(ArtifactId value) { + ResultSet result = accountAdmin.getAccountById(value); + Account account = result.getExactlyOne(); + return AccountDataUtil.asAccountData(account); + } + public AccountSessionData doLogin(RequestInfo info, AccountLoginData input) { AccountLoginRequestBuilder builder = AccountLoginRequestBuilder.newBuilder(); AccountLoginRequest request = builder// @@ -100,22 +106,22 @@ public class AccountOps { .prefs(input.getPreferences()) // .build(); - Identifiable id = accountAdmin.createAccount(request); - ResultSet result = accountAdmin.getAccountByGuid(id.getGuid()); + ArtifactId id = accountAdmin.createAccount(request); + ResultSet result = accountAdmin.getAccountById(id); Account account = result.getExactlyOne(); return AccountDataUtil.asAccountData(account); } - public boolean deleteAccount(String accountId) { + public boolean deleteAccount(ArtifactId accountId) { return accountAdmin.deleteAccount(accountId); } - public boolean setAccountActive(String accountId, boolean active) { + public boolean setAccountActive(ArtifactId accountId, boolean active) { return accountAdmin.setActive(accountId, active); } - public AccountActiveData isActive(String accountId) { - ResultSet result = accountAdmin.getAccountByUniqueField(accountId); + public AccountActiveData isActive(ArtifactId accountId) { + ResultSet result = accountAdmin.getAccountById(accountId); Account account = result.getExactlyOne(); return AccountDataUtil.asAccountActiveData(account); } @@ -129,45 +135,45 @@ public class AccountOps { return toReturn; } - public AccountDetailsData getAccountDetailsData(String accountId) { - System.out.println("**********LOOKING FOR: " + accountId); - ResultSet result = accountAdmin.getAccountByUniqueField(accountId); + public AccountDetailsData getAccountDetailsData(ArtifactId accountId) { + ResultSet result = accountAdmin.getAccountById(accountId); Account account = result.getExactlyOne(); return AccountDataUtil.asAccountDetailsData(account); } - public AccountInfoData getAccountData(String value) { - ResultSet result = accountAdmin.getAccountByUniqueField(value); - Account account = result.getExactlyOne(); - return AccountDataUtil.asAccountData(account); - } - - public boolean editAccountWebPreferencesData(String accountGuid, String key, String itemId, String newValue) { - return accountAdmin.setAccountWebPreference(accountGuid, key, itemId, newValue); + public boolean editAccountWebPreferencesData(ArtifactId accountId, String key, String itemId, String newValue) { + return accountAdmin.setAccountWebPreference(accountId, key, itemId, newValue); } - public AccountWebPreferences getDefaultAccountWebPreferencesData(String value) { - ResultSet result = accountAdmin.getAccountByGuid(value); + public AccountWebPreferences getDefaultAccountWebPreferencesData(ArtifactId accountId) { + ResultSet result = accountAdmin.getAccountById(accountId); Account account = result.getExactlyOne(); AccountWebPreferences preferences = account.getWebPreferences(); return preferences; } - public AccountWebPreferences getAccountWebPreferencesData(Long id) { + public AccountWebPreferences getAccountWebPreferencesData(ArtifactId id) { ResultSet result = accountAdmin.getAccountById(id); Account account = result.getExactlyOne(); AccountWebPreferences preferences = account.getWebPreferences(); return preferences; } - public AccountPreferencesData getAccountPreferencesData(String value) { - ResultSet result = accountAdmin.getAccountByUniqueField(value); + public AccountPreferencesData getAccountPreferencesDataById(ArtifactId accountId) { + ResultSet result = accountAdmin.getAccountById(accountId); + Account account = result.getExactlyOne(); + AccountPreferences preferences = account.getPreferences(); + return AccountDataUtil.asAccountPreferencesData(preferences); + } + + public AccountPreferencesData getAccountPreferencesDataByEmail(String email) { + ResultSet result = accountAdmin.getAccountByEmail(email); Account account = result.getExactlyOne(); AccountPreferences preferences = account.getPreferences(); return AccountDataUtil.asAccountPreferencesData(preferences); } - public boolean setAccountPreferences(String accountId, AccountPreferencesInput input) { + public boolean setAccountPreferences(ArtifactId accountId, AccountPreferencesInput input) { return accountAdmin.setAccountPreferences(accountId, input.getMap()); } diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResource.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResource.java index c10a5c6ff7d..9c2f48138b5 100644 --- a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResource.java +++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResource.java @@ -20,6 +20,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.ResponseBuilder; import org.eclipse.osee.account.rest.model.AccountPreferencesData; import org.eclipse.osee.account.rest.model.AccountPreferencesInput; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.SystemRoles; /** @@ -28,28 +29,28 @@ import org.eclipse.osee.framework.jdk.core.type.SystemRoles; public class AccountPreferencesResource { private final AccountOps accountOps; - private final String accountId; + private final ArtifactId accountId; - public AccountPreferencesResource(AccountOps accountOps, String accountId) { + public AccountPreferencesResource(AccountOps accountOps, ArtifactId accountId) { this.accountOps = accountOps; this.accountId = accountId; } /** * Get account preferences - * + * * @return account preferences */ @GET @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public AccountPreferencesData getAccountPreferences() { - return accountOps.getAccountPreferencesData(accountId); + return accountOps.getAccountPreferencesDataById(accountId); } /** * Sets all preferences to match the incoming preferences. - * + * * @return response * @response.representation.200.doc successfully logged out * @response.representation.304.doc session not modified diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountResource.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountResource.java index 9ffc6fb200c..6279f077300 100644 --- a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountResource.java +++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountResource.java @@ -11,12 +11,9 @@ package org.eclipse.osee.account.rest.internal; import java.net.URI; -import javax.annotation.security.PermitAll; import javax.annotation.security.RolesAllowed; -import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; -import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; @@ -27,8 +24,7 @@ import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; import org.eclipse.osee.account.rest.model.AccountContexts; import org.eclipse.osee.account.rest.model.AccountDetailsData; -import org.eclipse.osee.account.rest.model.AccountInfoData; -import org.eclipse.osee.account.rest.model.AccountInput; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.SystemRoles; /** @@ -37,30 +33,16 @@ import org.eclipse.osee.framework.jdk.core.type.SystemRoles; public class AccountResource { private final AccountOps accountOps; - private final String accountId; + private final ArtifactId accountId; - public AccountResource(AccountOps accountOps, String accountId) { + public AccountResource(AccountOps accountOps, ArtifactId accountId) { this.accountOps = accountOps; this.accountId = accountId; } - /** - * Creates a new Account - all fields must be unique - * - * @param accountInput Account data - * @return new account info data - */ - @POST - @PermitAll - @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public AccountInfoData createAccount(AccountInput accountInput) { - return accountOps.createAccount(accountId, accountInput); - } - /** * Deletes the account - * + * * @return response * @response.representation.200.doc account status set to active * @response.representation.304.doc account active status not modified @@ -80,7 +62,7 @@ public class AccountResource { /** * Get account details - * + * * @return account details */ @GET @@ -92,7 +74,7 @@ public class AccountResource { /** * Get All account subscriptions - * + * * @return accountSubscriptions */ @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED) @@ -101,7 +83,7 @@ public class AccountResource { public Response getSubscriptions(@Context UriInfo uriInfo) { URI requestUri = uriInfo.getRequestUri(); URI uri = UriBuilder.fromUri(requestUri).path("../../../").path("subscriptions").path("for-account").path( - "{account-id}").build(accountId); + "{account-id}").build(accountId.getUuid()); return Response.seeOther(uri).build(); } diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountSessionsResource.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountSessionsResource.java index cae7e8be514..c1a13f65a64 100644 --- a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountSessionsResource.java +++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountSessionsResource.java @@ -15,6 +15,7 @@ import javax.ws.rs.GET; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.eclipse.osee.account.rest.model.AccountSessionDetailsData; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.SystemRoles; /** @@ -23,16 +24,16 @@ import org.eclipse.osee.framework.jdk.core.type.SystemRoles; public class AccountSessionsResource { private final AccountOps accountOps; - private final String accountId; + private final ArtifactId accountId; - public AccountSessionsResource(AccountOps accountOps, String accountId) { + public AccountSessionsResource(AccountOps accountOps, ArtifactId accountId) { this.accountOps = accountOps; this.accountId = accountId; } /** * Get all sessions for this account - * + * * @return account sessions */ @GET diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountsResource.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountsResource.java index c87ab4089b4..f47a229da22 100644 --- a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountsResource.java +++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountsResource.java @@ -11,7 +11,9 @@ package org.eclipse.osee.account.rest.internal; import javax.annotation.security.PermitAll; +import javax.ws.rs.Consumes; import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -22,6 +24,9 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.eclipse.osee.account.rest.model.AccountContexts; import org.eclipse.osee.account.rest.model.AccountInfoData; +import org.eclipse.osee.account.rest.model.AccountInput; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.jdk.core.type.OseePrincipal; /** @@ -55,7 +60,8 @@ public class AccountsResource { @PermitAll @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response getPreferences(@PathParam("id") Long id) { - return Response.ok().entity(accountOps.getAccountWebPreferencesData(id)).build(); + ArtifactId artifactId = TokenFactory.createArtifactId(id); + return Response.ok().entity(accountOps.getAccountWebPreferencesData(artifactId)).build(); } @PUT @@ -63,7 +69,8 @@ public class AccountsResource { @PermitAll @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response editPreferences(@PathParam("id") String userUuid, @QueryParam("key") String key, @QueryParam("itemId") String itemId, String newValue) { - return Response.ok().entity(accountOps.editAccountWebPreferencesData(userUuid, key, itemId, newValue)).build(); + ArtifactId artifactId = TokenFactory.createArtifactId(Long.valueOf(userUuid)); + return Response.ok().entity(accountOps.editAccountWebPreferencesData(artifactId, key, itemId, newValue)).build(); } /** @@ -77,19 +84,24 @@ public class AccountsResource { return accountOps.getAllAccounts().toArray(new AccountInfoData[] {}); } - @Path(AccountContexts.ACCOUNT_LOGIN) - public AccountLoginResource getLoginResource() { - return new AccountLoginResource(accountOps); - } - - @Path(AccountContexts.ACCOUNT_LOGOUT) - public AccountLogoutResource getLogoutResource() { - return new AccountLogoutResource(accountOps); + /** + * Creates a new Account - all fields must be unique + * + * @param accountInput Account data + * @return new account info data + */ + @POST + @PermitAll + @Path(AccountContexts.ACCOUNT_ID_TEMPLATE) + @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + public AccountInfoData createAccount(@PathParam(AccountContexts.ACCOUNT_ID_PARAM) String username, AccountInput accountInput) { + return accountOps.createAccount(username, accountInput); } @Path(AccountContexts.ACCOUNT_ID_TEMPLATE) - public AccountResource getAccount(@PathParam(AccountContexts.ACCOUNT_ID_PARAM) String accountId) { - return new AccountResource(accountOps, accountId); + public AccountResource getAccount(@PathParam(AccountContexts.ACCOUNT_ID_PARAM) Long accountId) { + ArtifactId artifactId = TokenFactory.createArtifactId(accountId); + return new AccountResource(accountOps, artifactId); } - } diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/JaxRsAuthenticatorImpl.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/JaxRsAuthenticatorImpl.java index 14edc2ff012..4071359354e 100644 --- a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/JaxRsAuthenticatorImpl.java +++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/JaxRsAuthenticatorImpl.java @@ -29,8 +29,8 @@ import org.eclipse.osee.authorization.admin.AuthorizationAdmin; import org.eclipse.osee.authorization.admin.AuthorizationRequest; import org.eclipse.osee.authorization.admin.AuthorizationRequestBuilder; import org.eclipse.osee.authorization.admin.AuthorizationUser; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.BaseIdentity; -import org.eclipse.osee.framework.jdk.core.type.Identifiable; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.type.OseePrincipal; import org.eclipse.osee.framework.jdk.core.type.ResultSet; @@ -139,8 +139,8 @@ public class JaxRsAuthenticatorImpl implements JaxRsAuthenticator { .email(subject.getEmailAddress())// .userName(subject.getUserName())// .build(); - Identifiable id = accountAdmin.createAccount(request); - account = accountAdmin.getAccountById(id).getExactlyOne(); + ArtifactId accountId = accountAdmin.createAccount(request); + account = accountAdmin.getAccountById(accountId).getExactlyOne(); } else { // or log in as anonymous ? throw new OseeCoreException("Account not found for [%s]", login); @@ -162,7 +162,7 @@ public class JaxRsAuthenticatorImpl implements JaxRsAuthenticator { return toReturn; } - private static final class OseePrincipalImpl extends BaseIdentityimplements OseePrincipal { + private static final class OseePrincipalImpl extends BaseIdentity implements OseePrincipal { private final String login; private final Account data; private final boolean authenticated; diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/SubscriptionsResource.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/SubscriptionsResource.java index 921e83c043b..8268ac7eb37 100644 --- a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/SubscriptionsResource.java +++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/SubscriptionsResource.java @@ -28,6 +28,9 @@ import org.eclipse.osee.account.admin.SubscriptionGroup; import org.eclipse.osee.account.rest.model.AccountInfoData; import org.eclipse.osee.account.rest.model.SubscriptionData; import org.eclipse.osee.account.rest.model.SubscriptionGroupData; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.jdk.core.type.ResultSet; import org.eclipse.osee.framework.jdk.core.type.SystemRoles; @@ -46,14 +49,15 @@ public class SubscriptionsResource { /** * Get All account subscriptions - * + * * @return accountSubscriptions */ @Path("/for-account/{account-id}") @GET @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public SubscriptionData[] getSubscriptions(@PathParam("account-id") String accountId) { - ResultSet subscriptions = manager.getSubscriptionsByAccountUniqueField(accountId); + public SubscriptionData[] getSubscriptions(@PathParam("account-id") Long accountId) { + ArtifactId artId = TokenFactory.createArtifactId(accountId); + ResultSet subscriptions = manager.getSubscriptionsByAccountId(artId); SubscriptionData[] toReturn = new SubscriptionData[subscriptions.size()]; int index = 0; for (Subscription subscription : subscriptions) { @@ -64,20 +68,20 @@ public class SubscriptionsResource { /** * Get account subscription info - * + * * @return accountSubscription */ @Path("/{subscription-uuid}") @GET @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public SubscriptionData getSubscription(@PathParam("subscription-uuid") String subscriptionUuid) { - Subscription accountSubscription = manager.getSubscription(subscriptionUuid); + public SubscriptionData getSubscriptionByEncoded(@PathParam("subscription-uuid") String encodedId) { + Subscription accountSubscription = manager.getSubscriptionsByEncodedId(encodedId); return AccountDataUtil.asAccountSubscriptionData(accountSubscription); } /** * Set subscription status to active - * + * * @return response * @response.representation.200.doc subscription status set to active * @response.representation.304.doc subscription active status not modified @@ -86,7 +90,8 @@ public class SubscriptionsResource { @PUT public Response setSubscriptionActive(@PathParam("subscription-uuid") String subscriptionUuid) { ResponseBuilder builder; - boolean modified = manager.setSubscriptionActive(subscriptionUuid, true); + Subscription subcription = manager.getSubscriptionsByEncodedId(subscriptionUuid); + boolean modified = manager.setSubscriptionActive(subcription, true); if (modified) { builder = Response.ok(); } else { @@ -97,7 +102,7 @@ public class SubscriptionsResource { /** * Set subscription status to inactive - * + * * @return response * @response.representation.200.doc subscription status set to inactive * @response.representation.304.doc subscription status not modified @@ -106,7 +111,8 @@ public class SubscriptionsResource { @DELETE public Response setSubscriptionInactive(@PathParam("subscription-uuid") String subscriptionUuid) { ResponseBuilder builder; - boolean modified = manager.setSubscriptionActive(subscriptionUuid, false); + Subscription subcription = manager.getSubscriptionsByEncodedId(subscriptionUuid); + boolean modified = manager.setSubscriptionActive(subcription, false); if (modified) { builder = Response.ok(); } else { @@ -117,7 +123,7 @@ public class SubscriptionsResource { /** * Get all subscription groups - * + * * @return subscription groups */ @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED) @@ -136,29 +142,29 @@ public class SubscriptionsResource { /** * Get subscription group - * + * * @return subscription group */ @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED) @Path("/groups/{group-id}") @GET @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public SubscriptionGroupData getSubscriptionGroup(@PathParam("group-id") String groupId) { - SubscriptionGroup group = manager.getSubscriptionGroupByUniqueField(groupId).getExactlyOne(); - return AccountDataUtil.asSubscriptionGroupData(group); + public SubscriptionGroupData getSubscriptionGroup(@PathParam("group-id") Long groupId) { + SubscriptionGroup subscription = manager.getSubscriptionGroupById(new SubscriptionGroupId(groupId)); + return AccountDataUtil.asSubscriptionGroupData(subscription); } /** * Get subscription group - * + * * @return subscription group */ @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED) @Path("/groups/{group-id}/members") @GET @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public AccountInfoData[] getSubscriptionGroupMembers(@PathParam("group-id") String groupId) { - ResultSet accounts = manager.getSubscriptionGroupMembersByUniqueField(groupId); + public AccountInfoData[] getSubscriptionGroupMembers(@PathParam("group-id") Long groupId) { + ResultSet accounts = manager.getSubscriptionMembersOfSubscriptionById(new SubscriptionGroupId(groupId)); AccountInfoData[] toReturn = new AccountInfoData[accounts.size()]; int index = 0; for (Account group : accounts) { @@ -169,7 +175,7 @@ public class SubscriptionsResource { /** * Create a subscription group - * + * * @return subscription group */ @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED) @@ -177,21 +183,22 @@ public class SubscriptionsResource { @POST @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public SubscriptionGroupData createSubscriptionGroup(@PathParam("group-name") String groupName) { - SubscriptionGroup group = manager.createSubscriptionGroup(groupName); - return AccountDataUtil.asSubscriptionGroupData(group); + SubscriptionGroupId groupId = manager.createSubscriptionGroup(groupName); + SubscriptionGroup subscription = manager.getSubscriptionGroupById(groupId); + return AccountDataUtil.asSubscriptionGroupData(subscription); } /** * Delete subscription group - * + * * @return subscription group */ @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED) @Path("/groups/{group-id}") @DELETE - public Response deleteSubscriptionGroup(@PathParam("group-id") String groupId) { + public Response deleteSubscriptionGroup(@PathParam("group-id") Long groupId) { ResponseBuilder builder; - boolean modified = manager.deleteSubscriptionGroupByUniqueField(groupId); + boolean modified = manager.deleteSubscriptionById(new SubscriptionGroupId(groupId)); if (modified) { builder = Response.ok(); } else { diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/UnsubscribeResource.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/UnsubscribeResource.java index 4fa07a669b8..e7b442af7f0 100644 --- a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/UnsubscribeResource.java +++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/UnsubscribeResource.java @@ -40,14 +40,14 @@ public class UnsubscribeResource { /** * Gets an Unsubscribe page to allow the user to select to unsubscribe - * + * * @param subscriptionUuid */ @Path("/ui/{subscription-uuid}") @GET @Produces(MediaType.TEXT_HTML) public ViewModel getUnsubscribePage(@PathParam("subscription-uuid") String subscriptionUuid) { - Subscription subscription = manager.getSubscription(subscriptionUuid); + Subscription subscription = manager.getSubscriptionsByEncodedId(subscriptionUuid); ViewModel page; if (subscription.isActive()) { String uuid = subscription.getGuid(); @@ -61,7 +61,7 @@ public class UnsubscribeResource { /** * Gets an Unsubscribe page to allow the user to select to unsubscribe - * + * * @param subscriptionUuid */ @Path("/ui/{subscription-uuid}/confirm") @@ -69,7 +69,7 @@ public class UnsubscribeResource { @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.TEXT_HTML) public ViewModel processUnsubscribePage(@Encoded @PathParam("subscription-uuid") String subscriptionUuid) { - Subscription subscription = manager.getSubscription(subscriptionUuid); + Subscription subscription = manager.getSubscriptionsByEncodedId(subscriptionUuid); boolean modified = manager.setSubscriptionActive(subscription, false); ViewModel page; if (modified) { diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/util/AtsCoreServiceImplTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/util/AtsCoreServiceImplTest.java index 39c2751e6b4..6bd8926ee4a 100644 --- a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/util/AtsCoreServiceImplTest.java +++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/util/AtsCoreServiceImplTest.java @@ -30,7 +30,6 @@ public class AtsCoreServiceImplTest { // @formatter:off @Mock private ArtifactId artifact; - @Mock private ArtifactId storeArtifact; @Mock private IAtsObject atsObject; @Mock private IAttributeResolver attrResolver; // @formatter:on @@ -43,8 +42,7 @@ public class AtsCoreServiceImplTest { @Test public void testGetAtsId() { when(attrResolver.getSoleAttributeValue(artifact, AtsAttributeTypes.AtsId, null)).thenReturn(null); - when(artifact.getStoreObject()).thenReturn(storeArtifact); - when(storeArtifact.getGuid()).thenReturn("guid"); + when(artifact.getGuid()).thenReturn("guid"); String result = AtsCoreServiceImpl.getAtsId(attrResolver, artifact); assertEquals(result, "guid"); @@ -53,11 +51,11 @@ public class AtsCoreServiceImplTest { result = AtsCoreServiceImpl.getAtsId(attrResolver, atsObject); assertEquals(result, "guid"); - when(attrResolver.getSoleAttributeValue(storeArtifact, AtsAttributeTypes.AtsId, null)).thenReturn("ATS23"); + when(attrResolver.getSoleAttributeValue(artifact, AtsAttributeTypes.AtsId, null)).thenReturn("ATS23"); result = AtsCoreServiceImpl.getAtsId(attrResolver, artifact); assertEquals(result, "ATS23"); - when(attrResolver.getSoleAttributeValue(storeArtifact, AtsAttributeTypes.AtsId, null)).thenReturn("ATS23"); + when(attrResolver.getSoleAttributeValue(artifact, AtsAttributeTypes.AtsId, null)).thenReturn("ATS23"); assertEquals(result, "ATS23"); } diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsCoreServiceImpl.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsCoreServiceImpl.java index 41fe9766f11..f63928ffa51 100644 --- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsCoreServiceImpl.java +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsCoreServiceImpl.java @@ -37,11 +37,10 @@ public abstract class AtsCoreServiceImpl implements IAtsServices { } protected static String getAtsId(IAttributeResolver attrResolver, ArtifactId artifact) { - ArtifactId art = artifact.getStoreObject(); - Conditions.checkNotNull(art, "artifact"); - String toReturn = attrResolver.getSoleAttributeValue(art, AtsAttributeTypes.AtsId, null); + Conditions.checkNotNull(artifact, "artifact"); + String toReturn = attrResolver.getSoleAttributeValue(artifact, AtsAttributeTypes.AtsId, null); if (toReturn == null) { - toReturn = art.getGuid(); + toReturn = artifact.getGuid(); } return toReturn; } diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/DispoConstants.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/DispoConstants.java index b4546a36dab..e6f73f954ab 100644 --- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/DispoConstants.java +++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/DispoConstants.java @@ -10,11 +10,11 @@ *******************************************************************************/ package org.eclipse.osee.disposition.rest; -import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.IArtifactToken; import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.data.IAttributeType; import org.eclipse.osee.framework.core.data.TokenFactory; -import org.eclipse.osee.orcs.utility.OrcsUtil; +import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; /** * @author Angel Avila @@ -49,7 +49,8 @@ public final class DispoConstants { public static final IAttributeType DispoItemMethodNumber = TokenFactory.createAttributeType(0x3000000000000214L, "dispo.Method Number"); - public static final ArtifactId DispoTypesArtifact = OrcsUtil.newArtifactId(4757831, "BEQGMZJDBHPd4OeWg6AA", "DispositionTypes"); + public static final IArtifactToken DISPO_ARTIFACT = TokenFactory.createArtifactToken(4757831L, "DispositionTypes", CoreArtifactTypes.OseeTypeDefinition); + // @formatter:on private DispoConstants() { diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/OrcsStorageImpl.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/OrcsStorageImpl.java index 5e4c4ee43cb..27cfc6631d6 100644 --- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/OrcsStorageImpl.java +++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/OrcsStorageImpl.java @@ -10,8 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.disposition.rest.internal; -import static org.eclipse.osee.disposition.rest.DispoConstants.DispoTypesArtifact; -import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.OseeTypeDefinition; +import static org.eclipse.osee.disposition.rest.DispoConstants.DISPO_ARTIFACT; import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.UriGeneralStringData; import java.io.InputStream; import java.util.ArrayList; @@ -97,9 +96,9 @@ public class OrcsStorageImpl implements Storage { orcsApi.getOrcsTypes().invalidateAll(); } - @SuppressWarnings("unchecked") private ResultSet getDispoTypesArtifact() throws OseeCoreException { - return getQuery().fromBranch(getAdminBranch()).andIds(DispoConstants.DispoTypesArtifact).getResults(); + return getQuery().fromBranch(getAdminBranch()).andUuid(DISPO_ARTIFACT.getUuid()).andTypeEquals( + DISPO_ARTIFACT.getArtifactType()).getResults(); } @Override @@ -117,10 +116,7 @@ public class OrcsStorageImpl implements Storage { public void storeTypes(IResource resource) { TransactionBuilder tx = getTxFactory().createTransaction(getAdminBranch(), getDispoUser(), "Initialize Dispo Types"); - ArtifactId artifactId = DispoTypesArtifact; - if (!typesExist()) { - tx.createArtifact(OseeTypeDefinition, artifactId.getName(), artifactId.getGuid()); - } + ArtifactId artifactId = tx.createArtifact(DISPO_ARTIFACT); InputStream stream = null; try { stream = resource.getContent(); diff --git a/plugins/org.eclipse.osee.framework.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.core/META-INF/MANIFEST.MF index fbab325f81a..b303513d106 100644 --- a/plugins/org.eclipse.osee.framework.core/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.core/META-INF/MANIFEST.MF @@ -17,7 +17,6 @@ Import-Package: org.apache.commons.httpclient, org.eclipse.osee.framework.jdk.core.util, org.eclipse.osee.framework.logging, org.eclipse.osgi.framework.console, - org.osgi.framework, org.osgi.util.tracker Export-Package: org.eclipse.osee.framework.core.data, org.eclipse.osee.framework.core.enums, diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactId.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactId.java index 0bb44b82e79..399d7c5b4a2 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactId.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactId.java @@ -17,8 +17,7 @@ import org.eclipse.osee.framework.jdk.core.type.Identifiable; */ public interface ArtifactId extends Identifiable, HasUuid, HasBranch { - String toStringWithId(); - - ArtifactId getStoreObject(); - + default String toStringWithId() { + return String.format("[%s][%s]", getName(), getUuid()); + } } diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/IArtifactToken.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/IArtifactToken.java index 25874e6ecd6..7100c5b717b 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/IArtifactToken.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/IArtifactToken.java @@ -10,12 +10,11 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.data; -import org.eclipse.osee.framework.jdk.core.type.Identifiable; - /** * @author Ryan D. Brooks * @author Donald G. Dunne */ -public interface IArtifactToken extends Identifiable, HasArtifactType, HasUuid, HasBranch { +public interface IArtifactToken extends ArtifactId, HasArtifactType { // composition interface requires no additional methods,fields + } diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/TokenFactory.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/TokenFactory.java index 5fbd8479239..25656d36c49 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/TokenFactory.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/TokenFactory.java @@ -49,6 +49,16 @@ public final class TokenFactory { return new AccessContextIdToken(guid, name); } + public static ArtifactId createArtifactId(Long uuid) { + return new ArtifactToken(uuid, null, null, null); + } + + public static IArtifactToken createArtifactToken(long uuid, String name, IArtifactType artifactType) { + Conditions.checkExpressionFailOnTrue(uuid <= 0, "Artifact Token Uuid must be > 0 for token [%s] type [%s]", name, + artifactType); + return new ArtifactToken(uuid, null, name, artifactType); + } + public static IArtifactToken createArtifactToken(long uuid, String guid, String name, IArtifactType artifactType) { Conditions.checkExpressionFailOnTrue(uuid <= 0, "Artifact Token Uuid must be > 0 for token [%s] type [%s]", name, artifactType); @@ -215,7 +225,6 @@ public final class TokenFactory { public Long getUuid() { return uuid; } - } private final static class AccessContextIdToken extends NamedIdentity implements IAccessContextId { diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java index 6b3afbbd3c2..d2c7df882f1 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java @@ -90,7 +90,7 @@ import org.eclipse.osee.framework.skynet.core.types.IArtifact; * @author Ryan D. Brooks */ -public class Artifact extends FullyNamedIdentityimplements IArtifact, IAdaptable, IBasicGuidArtifact, ArtifactId { +public class Artifact extends FullyNamedIdentity implements IArtifact, IAdaptable, IBasicGuidArtifact, ArtifactId { public static final String UNNAMED = "Unnamed"; public static final String BEFORE_GUID_STRING = "/BeforeGUID/PrePend"; public static final String AFTER_GUID_STRING = "/AfterGUID"; @@ -1743,9 +1743,4 @@ public class Artifact extends FullyNamedIdentityimplements IArtifact, IA return artifact; } - @Override - public ArtifactId getStoreObject() { - return this; - } - } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/EmailGroupsData.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/EmailGroupsData.java index e35e3f39e1a..9e428db4baa 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/EmailGroupsData.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/EmailGroupsData.java @@ -119,7 +119,7 @@ public class EmailGroupsData { } AccountClient client = ServiceUtil.getAccountClient(); - ResultSet results = client.getUnsubscribeUris(user.getGuid(), groupsAllowed); + ResultSet results = client.getUnsubscribeUris(user.getUuid(), groupsAllowed); for (UnsubscribeInfo entry : results) { String subscriptionName = entry.getName(); URI unsubscribeUri = entry.getUnsubscribeUri(); diff --git a/plugins/org.eclipse.osee.jaxrs.server/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.jaxrs.server/META-INF/MANIFEST.MF index 5401227518e..66c15974036 100644 --- a/plugins/org.eclipse.osee.jaxrs.server/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.jaxrs.server/META-INF/MANIFEST.MF @@ -63,6 +63,7 @@ Import-Package: com.google.common.cache;version="15.0.0", org.apache.cxf.transport.http;version="3.0.0", org.apache.cxf.transport.servlet;version="3.0.0", org.codehaus.jackson.jaxrs;version="1.9.13", + org.eclipse.osee.framework.core.data, org.eclipse.osee.framework.jdk.core.type, org.eclipse.osee.framework.jdk.core.util, org.eclipse.osee.jaxrs, diff --git a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/ClientProvider.java b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/ClientProvider.java index 69669c13198..ac351880532 100644 --- a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/ClientProvider.java +++ b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/ClientProvider.java @@ -10,12 +10,12 @@ *******************************************************************************/ package org.eclipse.osee.jaxrs.server.internal.security.oauth2.provider; -import com.google.common.io.InputSupplier; import java.io.InputStream; import javax.ws.rs.core.UriInfo; import org.apache.cxf.rs.security.oauth2.common.Client; import org.eclipse.osee.framework.jdk.core.type.OseePrincipal; import org.eclipse.osee.jaxrs.server.internal.security.oauth2.provider.endpoints.ClientFormData; +import com.google.common.io.InputSupplier; /** * @author Roberto E. Escobar diff --git a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/adapters/ApplicationClient.java b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/adapters/ApplicationClient.java index 4fdb25fa0dc..b23ec07f603 100644 --- a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/adapters/ApplicationClient.java +++ b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/adapters/ApplicationClient.java @@ -10,11 +10,11 @@ *******************************************************************************/ package org.eclipse.osee.jaxrs.server.internal.security.oauth2.provider.adapters; -import com.google.common.io.InputSupplier; import java.io.InputStream; import org.apache.cxf.rs.security.oauth2.common.Client; import org.eclipse.osee.framework.jdk.core.type.Identity; import org.eclipse.osee.jaxrs.server.security.OAuthClient; +import com.google.common.io.InputSupplier; /** * @author Roberto E. Escobar diff --git a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/adapters/ClientProviderImpl.java b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/adapters/ClientProviderImpl.java index eaa9b84e669..1c084e1c8a7 100644 --- a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/adapters/ClientProviderImpl.java +++ b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/adapters/ClientProviderImpl.java @@ -10,10 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.jaxrs.server.internal.security.oauth2.provider.adapters; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.io.InputSupplier; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; @@ -36,6 +32,10 @@ import org.eclipse.osee.jaxrs.server.internal.security.oauth2.provider.SubjectPr import org.eclipse.osee.jaxrs.server.internal.security.oauth2.provider.endpoints.ClientFormData; import org.eclipse.osee.jaxrs.server.security.JaxRsOAuthStorage; import org.eclipse.osee.jaxrs.server.security.OAuthClient; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.common.io.InputSupplier; /** * @author Roberto E. Escobar diff --git a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/endpoints/ImplicitGrantEndpoint.java b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/endpoints/ImplicitGrantEndpoint.java index 7b5a09ef0bc..16e81e86654 100644 --- a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/endpoints/ImplicitGrantEndpoint.java +++ b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/security/oauth2/provider/endpoints/ImplicitGrantEndpoint.java @@ -144,6 +144,8 @@ public class ImplicitGrantEndpoint extends ImplicitGrantService { .buildFromEncoded(); secData.setApplicationLogoUri(newClientLogoUri.toString()); + } else { + secData.setApplicationLogoUri(clientLogoUri.toString()); } return secData; diff --git a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/security/JaxRsOAuthStorage.java b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/security/JaxRsOAuthStorage.java index 0fceae66c35..b32ae577782 100644 --- a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/security/JaxRsOAuthStorage.java +++ b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/security/JaxRsOAuthStorage.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.jaxrs.server.security; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.OseePrincipal; /** @@ -21,9 +22,11 @@ public interface JaxRsOAuthStorage { OAuthClient getClientByClientGuid(String guid); + OAuthClient getClientByClientUuid(Long uuid); + OAuthClient getClientByClientKey(String clientKey); - void storeClient(OseePrincipal principal, OAuthClient client); + ArtifactId storeClient(OseePrincipal principal, OAuthClient client); void removeClient(OseePrincipal principal, OAuthClient client); diff --git a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/security/OAuthClient.java b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/security/OAuthClient.java index 4517c801b54..1d7c67cd341 100644 --- a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/security/OAuthClient.java +++ b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/security/OAuthClient.java @@ -10,11 +10,11 @@ *******************************************************************************/ package org.eclipse.osee.jaxrs.server.security; -import com.google.common.io.InputSupplier; import java.io.InputStream; import java.util.List; import java.util.Map; import org.eclipse.osee.framework.jdk.core.type.Identity; +import com.google.common.io.InputSupplier; /** * @author Roberto E. Escobar diff --git a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/JdbcJaxRsOAuthStorageTest.java b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/JdbcJaxRsOAuthStorageTest.java index 999b3ca3883..48665d69adb 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/JdbcJaxRsOAuthStorageTest.java +++ b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/JdbcJaxRsOAuthStorageTest.java @@ -19,8 +19,8 @@ import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.OseePrincipal; -import org.eclipse.osee.framework.jdk.core.util.GUID; import org.eclipse.osee.jaxrs.server.security.JaxRsOAuthStorage; import org.eclipse.osee.jaxrs.server.security.OAuthClient; import org.eclipse.osee.jaxrs.server.security.OAuthCodeGrant; @@ -38,7 +38,7 @@ import org.mockito.Mock; /** * Test Case for {@link JdbcJaxRsOAuthStorage} - * + * * @author Roberto E. Escobar */ public class JdbcJaxRsOAuthStorageTest { @@ -46,7 +46,7 @@ public class JdbcJaxRsOAuthStorageTest { private static final String AUTH_CODE_1 = "auth-code-1"; public static final long CODE_UUID = 5679L; - public static final long CLIENT_ID = 912371L; + public static final long CLIENT_ID = 912371; public static final long SUBJECT_ID = 876523L; public static final long ISSUED_AT = 1231L; public static final long EXPIRES_IN = 9876L; @@ -68,7 +68,6 @@ public class JdbcJaxRsOAuthStorageTest { private static final String RT_GRANT_TYPE_1 = "rt-grant-type-1"; private static final OAuthTokenType RT_TYPE_1 = OAuthTokenType.REFRESH_TOKEN; - public static final String CLIENT_GUID = GUID.create(); public static final List APPLICATION_CERTIFICATE = Arrays.asList("certificate-1"); public static final String APPLICATION_DESCRIPTION = "description-1"; public static final String APPLICATION_LOGO_URI = "logo-uri-1"; @@ -149,7 +148,6 @@ public class JdbcJaxRsOAuthStorageTest { when(principal.getGuid()).thenReturn(-1L); - when(client.getGuid()).thenReturn(CLIENT_GUID); when(client.getClientUuid()).thenReturn(CLIENT_ID); when(client.getSubjectId()).thenReturn(SUBJECT_ID); when(client.getApplicationName()).thenReturn(APPLICATION_NAME); @@ -173,15 +171,19 @@ public class JdbcJaxRsOAuthStorageTest { @Test public void testClientStorage() { - storage.storeClient(principal, client); + ArtifactId createdClientId = storage.storeClient(principal, client); + long createdClientUuid = Long.valueOf(createdClientId.getUuid()); + when(client.getClientUuid()).thenReturn(createdClientUuid); + when(authCode.getClientId()).thenReturn(createdClientUuid); + when(accessToken.getClientId()).thenReturn(createdClientUuid); + when(refreshToken.getClientId()).thenReturn(createdClientUuid); long clientUuid = storage.getClientUuidByKey(CLIENT_KEY); - assertEquals(CLIENT_ID, clientUuid); + assertEquals(createdClientId.getUuid(), Long.valueOf(clientUuid)); - OAuthClient actualClient = storage.getClientByClientGuid(CLIENT_GUID); + OAuthClient actualClient = storage.getClientByClientUuid(createdClientUuid); - assertEquals(CLIENT_GUID, actualClient.getGuid()); - assertEquals(CLIENT_ID, actualClient.getClientUuid()); + assertEquals(createdClientUuid, actualClient.getClientUuid()); assertEquals(SUBJECT_ID, actualClient.getSubjectId()); assertEquals(APPLICATION_NAME, actualClient.getApplicationName()); assertEquals(APPLICATION_DESCRIPTION, actualClient.getApplicationDescription()); @@ -198,8 +200,7 @@ public class JdbcJaxRsOAuthStorageTest { assertEquals(applicationProperties, actualClient.getProperties()); actualClient = storage.getClientByClientKey(CLIENT_KEY); - assertEquals(CLIENT_GUID, actualClient.getGuid()); - assertEquals(CLIENT_ID, actualClient.getClientUuid()); + assertEquals(createdClientUuid, actualClient.getClientUuid()); assertEquals(SUBJECT_ID, actualClient.getSubjectId()); assertEquals(APPLICATION_NAME, actualClient.getApplicationName()); assertEquals(APPLICATION_DESCRIPTION, actualClient.getApplicationDescription()); @@ -220,7 +221,7 @@ public class JdbcJaxRsOAuthStorageTest { clientUuid = storage.getClientUuidByKey(CLIENT_KEY); assertEquals(-1L, clientUuid); - actualClient = storage.getClientByClientGuid(CLIENT_GUID); + actualClient = storage.getClientByClientUuid(createdClientUuid); assertNull(actualClient); actualClient = storage.getClientByClientKey(CLIENT_KEY); @@ -229,21 +230,26 @@ public class JdbcJaxRsOAuthStorageTest { @Test public void testCascadeClientToTokenDeletion() { - storage.storeClient(principal, client); + ArtifactId createdClientArtId = storage.storeClient(principal, client); + long createdClientUuid = Long.valueOf(createdClientArtId.getUuid()); + when(client.getClientUuid()).thenReturn(createdClientUuid); + when(authCode.getClientId()).thenReturn(createdClientUuid); + when(accessToken.getClientId()).thenReturn(createdClientUuid); + when(refreshToken.getClientId()).thenReturn(createdClientUuid); storage.storeCodeGrant(authCode); storage.storeToken(accessToken, refreshToken); storage.relateTokens(refreshToken, accessToken); long clientUuid = storage.getClientUuidByKey(CLIENT_KEY); - assertEquals(CLIENT_ID, clientUuid); + assertEquals(createdClientArtId.getUuid(), Long.valueOf(clientUuid)); - OAuthClient actualClient = storage.getClientByClientGuid(CLIENT_GUID); + OAuthClient actualClient = storage.getClientByClientUuid(createdClientUuid); assertNotNull(actualClient); - OAuthToken accessToken = storage.getPreauthorizedToken(CLIENT_ID, SUBJECT_ID, AT_GRANT_TYPE_1); + OAuthToken accessToken = storage.getPreauthorizedToken(createdClientUuid, SUBJECT_ID, AT_GRANT_TYPE_1); assertNotNull(accessToken); - OAuthToken refresh = storage.getPreauthorizedToken(CLIENT_ID, SUBJECT_ID, RT_GRANT_TYPE_1); + OAuthToken refresh = storage.getPreauthorizedToken(createdClientUuid, SUBJECT_ID, RT_GRANT_TYPE_1); assertNotNull(refresh); storage.removeClient(principal, client); @@ -251,19 +257,24 @@ public class JdbcJaxRsOAuthStorageTest { clientUuid = storage.getClientUuidByKey(CLIENT_KEY); assertEquals(-1L, clientUuid); - actualClient = storage.getClientByClientGuid(CLIENT_GUID); + actualClient = storage.getClientByClientUuid(createdClientUuid); assertNull(actualClient); - accessToken = storage.getPreauthorizedToken(CLIENT_ID, SUBJECT_ID, AT_GRANT_TYPE_1); + accessToken = storage.getPreauthorizedToken(createdClientUuid, SUBJECT_ID, AT_GRANT_TYPE_1); assertNull(accessToken); - refresh = storage.getPreauthorizedToken(CLIENT_ID, SUBJECT_ID, RT_GRANT_TYPE_1); + refresh = storage.getPreauthorizedToken(createdClientUuid, SUBJECT_ID, RT_GRANT_TYPE_1); assertNull(refresh); } @Test public void testAuthCode() { - storage.storeClient(principal, client); + ArtifactId createdClientId = storage.storeClient(principal, client); + long createdClientUuid = Long.valueOf(createdClientId.getUuid()); + when(client.getClientUuid()).thenReturn(createdClientUuid); + when(authCode.getClientId()).thenReturn(createdClientUuid); + when(accessToken.getClientId()).thenReturn(createdClientUuid); + when(refreshToken.getClientId()).thenReturn(createdClientUuid); OAuthCodeGrant actual = storage.getCodeGrant(AUTH_CODE_1); assertNull(actual); @@ -273,7 +284,7 @@ public class JdbcJaxRsOAuthStorageTest { actual = storage.getCodeGrant(AUTH_CODE_1); assertEquals(CODE_UUID, actual.getUuid()); - assertEquals(CLIENT_ID, actual.getClientId()); + assertEquals(createdClientUuid, actual.getClientId()); assertEquals(SUBJECT_ID, actual.getSubjectId()); assertEquals(ISSUED_AT, actual.getIssuedAt()); assertEquals(EXPIRES_IN, actual.getExpiresIn()); @@ -289,19 +300,24 @@ public class JdbcJaxRsOAuthStorageTest { assertNull(actual); long clientUuid = storage.getClientUuidByKey(CLIENT_KEY); - assertEquals(CLIENT_ID, clientUuid); + assertEquals(createdClientUuid, clientUuid); } @Test public void testAccessToken() { - storage.storeClient(principal, client); + ArtifactId createdClientId = storage.storeClient(principal, client); + long createdClientUuid = Long.valueOf(createdClientId.getUuid()); + when(client.getClientUuid()).thenReturn(createdClientUuid); + when(authCode.getClientId()).thenReturn(createdClientUuid); + when(accessToken.getClientId()).thenReturn(createdClientUuid); + when(refreshToken.getClientId()).thenReturn(createdClientUuid); storage.storeToken(accessToken); - OAuthToken actual = storage.getPreauthorizedToken(CLIENT_ID, SUBJECT_ID, AT_GRANT_TYPE_1); + OAuthToken actual = storage.getPreauthorizedToken(createdClientUuid, SUBJECT_ID, AT_GRANT_TYPE_1); assertEquals(AT_UUID, actual.getUuid()); - assertEquals(CLIENT_ID, actual.getClientId()); + assertEquals(createdClientUuid, actual.getClientId()); assertEquals(SUBJECT_ID, actual.getSubjectId()); assertEquals(ISSUED_AT, actual.getIssuedAt()); assertEquals(EXPIRES_IN, actual.getExpiresIn()); @@ -314,24 +330,29 @@ public class JdbcJaxRsOAuthStorageTest { storage.removeTokenByKey(AT_KEY_1); - actual = storage.getPreauthorizedToken(CLIENT_ID, SUBJECT_ID, AT_GRANT_TYPE_1); + actual = storage.getPreauthorizedToken(createdClientUuid, SUBJECT_ID, AT_GRANT_TYPE_1); assertNull(actual); long clientUuid = storage.getClientUuidByKey(CLIENT_KEY); - assertEquals(CLIENT_ID, clientUuid); + assertEquals(createdClientUuid, clientUuid); } @Test public void testAccessTokenWithRefreshToken() { - storage.storeClient(principal, client); + ArtifactId createdClientId = storage.storeClient(principal, client); + long createdClientUuid = Long.valueOf(createdClientId.getUuid()); + when(client.getClientUuid()).thenReturn(createdClientUuid); + when(authCode.getClientId()).thenReturn(createdClientUuid); + when(accessToken.getClientId()).thenReturn(createdClientUuid); + when(refreshToken.getClientId()).thenReturn(createdClientUuid); storage.storeToken(accessToken, refreshToken); storage.relateTokens(refreshToken, accessToken); - OAuthToken token1 = storage.getPreauthorizedToken(CLIENT_ID, SUBJECT_ID, AT_GRANT_TYPE_1); + OAuthToken token1 = storage.getPreauthorizedToken(createdClientUuid, SUBJECT_ID, AT_GRANT_TYPE_1); assertEquals(AT_UUID, token1.getUuid()); - assertEquals(CLIENT_ID, token1.getClientId()); + assertEquals(createdClientUuid, token1.getClientId()); assertEquals(SUBJECT_ID, token1.getSubjectId()); assertEquals(ISSUED_AT, token1.getIssuedAt()); assertEquals(EXPIRES_IN, token1.getExpiresIn()); @@ -342,10 +363,10 @@ public class JdbcJaxRsOAuthStorageTest { assertEquals(AUDIENCE, token1.getAudience()); assertEquals(RT_KEY_1, token1.getRefreshToken()); - OAuthToken refresh = storage.getPreauthorizedToken(CLIENT_ID, SUBJECT_ID, RT_GRANT_TYPE_1); + OAuthToken refresh = storage.getPreauthorizedToken(createdClientUuid, SUBJECT_ID, RT_GRANT_TYPE_1); assertEquals(RT_UUID, refresh.getUuid()); - assertEquals(CLIENT_ID, refresh.getClientId()); + assertEquals(createdClientUuid, refresh.getClientId()); assertEquals(SUBJECT_ID, refresh.getSubjectId()); assertEquals(ISSUED_AT, refresh.getIssuedAt()); assertEquals(EXPIRES_IN, refresh.getExpiresIn()); @@ -360,7 +381,7 @@ public class JdbcJaxRsOAuthStorageTest { OAuthToken token2 = tokens.iterator().next(); assertEquals(AT_UUID, token2.getUuid()); - assertEquals(CLIENT_ID, token2.getClientId()); + assertEquals(createdClientUuid, token2.getClientId()); assertEquals(SUBJECT_ID, token2.getSubjectId()); assertEquals(ISSUED_AT, token2.getIssuedAt()); assertEquals(EXPIRES_IN, token2.getExpiresIn()); @@ -373,15 +394,15 @@ public class JdbcJaxRsOAuthStorageTest { storage.removeToken(tokens); - token1 = storage.getPreauthorizedToken(CLIENT_ID, SUBJECT_ID, AT_GRANT_TYPE_1); + token1 = storage.getPreauthorizedToken(createdClientUuid, SUBJECT_ID, AT_GRANT_TYPE_1); assertNull(token1); storage.removeTokenByKey(RT_KEY_1); - refresh = storage.getPreauthorizedToken(CLIENT_ID, SUBJECT_ID, RT_GRANT_TYPE_1); + refresh = storage.getPreauthorizedToken(createdClientUuid, SUBJECT_ID, RT_GRANT_TYPE_1); assertNull(refresh); long clientUuid = storage.getClientUuidByKey(CLIENT_KEY); - assertEquals(CLIENT_ID, clientUuid); + assertEquals(createdClientUuid, clientUuid); } } diff --git a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsAccountStorageTest.java b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsAccountStorageTest.java index 5d2c8449907..3eb03c2a66d 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsAccountStorageTest.java +++ b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsAccountStorageTest.java @@ -23,7 +23,8 @@ import org.eclipse.osee.account.admin.AccountPreferences; import org.eclipse.osee.account.admin.AccountSession; import org.eclipse.osee.account.admin.CreateAccountRequest; import org.eclipse.osee.account.admin.ds.AccountStorage; -import org.eclipse.osee.framework.jdk.core.type.Identifiable; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.jdk.core.type.ResultSet; import org.eclipse.osee.framework.jdk.core.util.Compare; import org.eclipse.osee.orcs.account.admin.internal.OrcsAccountStorage; @@ -67,7 +68,7 @@ public class OrcsAccountStorageTest { private boolean active; private Map prefs; - private Identifiable newAccount; + private ArtifactId newAccountId; @Before public void testSetup() { @@ -91,7 +92,7 @@ public class OrcsAccountStorageTest { when(request.getPreferences()).thenReturn(prefs); when(request.isActive()).thenReturn(active); - newAccount = storage.createAccount(request); + newAccountId = storage.createAccount(request); } @Test @@ -102,85 +103,48 @@ public class OrcsAccountStorageTest { @Test public void testGetById() { - ResultSet result = storage.getAccountByGuid(newAccount.getGuid()); + ResultSet result = storage.getAccountById(newAccountId); Account account1 = result.getExactlyOne(); - assertAccount(account1, newAccount.getGuid(), name, email, username, active, prefs); - } + assertAccount(account1, newAccountId, name, email, username, active, prefs); - @Test - public void testGetByUuiId() { - ResultSet result = storage.getAccountByGuid(newAccount.getGuid()); - Account account1 = result.getExactlyOne(); - assertAccount(account1, newAccount.getGuid(), name, email, username, active, prefs); - - ResultSet result2 = storage.getAccountByLocalId(account1.getId()); + ArtifactId artId = TokenFactory.createArtifactId(account1.getId()); + ResultSet result2 = storage.getAccountById(artId); Account account2 = result2.getExactlyOne(); assertEquals(account1, account2); - assertAccount(account2, newAccount.getGuid(), name, email, username, active, prefs); - } - - @Test - public void testGetByName() { - ResultSet result = storage.getAccountByName(name); - Account account = result.getExactlyOne(); - assertAccount(account, newAccount.getGuid(), name, email, username, active, prefs); + assertAccount(account2, newAccountId, name, email, username, active, prefs); } @Test public void testGetByEmail() { ResultSet result = storage.getAccountByEmail(email); Account account = result.getExactlyOne(); - assertAccount(account, newAccount.getGuid(), name, email, username, active, prefs); - } - - @Test - public void testGetByUserName() { - ResultSet result = storage.getAccountByUserName(username); - Account account = result.getExactlyOne(); - assertAccount(account, newAccount.getGuid(), name, email, username, active, prefs); - } - - @Test - public void testGetAccountPrefsByUuid() { - AccountPreferences actual = storage.getAccountPreferencesByGuid(newAccount.getGuid()).getExactlyOne(); - assertPrefs(actual, newAccount.getGuid(), prefs); - - AccountPreferences actual2 = storage.getAccountPreferencesById(actual.getId()).getExactlyOne(); - assertPrefs(actual2, newAccount.getGuid(), prefs); - } - - @Test - public void testGetAccountPrefsByLocalId() { - Account account = storage.getAccountByGuid(newAccount.getGuid()).getExactlyOne(); - - AccountPreferences actual = storage.getAccountPreferencesById(account.getId()).getExactlyOne(); - assertPrefs(actual, account.getGuid(), account.getId(), prefs); + assertAccount(account, newAccountId, name, email, username, active, prefs); } @Test public void testSetActive() { - Account account = storage.getAccountByGuid(newAccount.getGuid()).getExactlyOne(); - assertAccount(account, newAccount.getGuid(), name, email, username, active, prefs); + Account account = storage.getAccountById(newAccountId).getExactlyOne(); + assertAccount(account, newAccountId, name, email, username, active, prefs); - storage.setActive(newAccount, false); + storage.setActive(newAccountId, false); - account = storage.getAccountByGuid(newAccount.getGuid()).getExactlyOne(); + account = storage.getAccountById(newAccountId).getExactlyOne(); assertFalse(account.isActive()); - storage.setActive(newAccount, true); + storage.setActive(newAccountId, true); - account = storage.getAccountByGuid(newAccount.getGuid()).getExactlyOne(); + account = storage.getAccountById(newAccountId).getExactlyOne(); assertTrue(account.isActive()); } @Test public void testDeleteAccount() { - ResultSet result = storage.getAccountByGuid(newAccount.getGuid()); + ResultSet result = storage.getAccountById(newAccountId); assertEquals(1, result.size()); - storage.deleteAccount(newAccount); + storage.deleteAccount(newAccountId); - result = storage.getAccountByGuid(newAccount.getGuid()); + result = storage.getAccountById(newAccountId); assertTrue(result.isEmpty()); } @@ -192,11 +156,11 @@ public class OrcsAccountStorageTest { expected.put("c", "z"); expected.put("d", "false"); - storage.setAccountPreferences(newAccount, expected); + storage.setAccountPreferences(newAccountId, expected); - Account account = storage.getAccountByGuid(newAccount.getGuid()).getExactlyOne(); + Account account = storage.getAccountById(newAccountId).getExactlyOne(); AccountPreferences actual = account.getPreferences(); - assertPrefs(actual, newAccount.getGuid(), account.getId(), expected); + assertPrefs(actual, newAccountId, account.getId(), expected); } @Test @@ -205,7 +169,7 @@ public class OrcsAccountStorageTest { String address = "myAddress"; String details = "myDetails"; - Account account = storage.getAccountByGuid(newAccount.getGuid()).getExactlyOne(); + Account account = storage.getAccountById(newAccountId).getExactlyOne(); AccountSession actual = storage.createAccountSession(token, account, address, details); assertEquals(details, actual.getAccessDetails()); @@ -223,15 +187,15 @@ public class OrcsAccountStorageTest { assertEquals(true, storage.getAccountSessionBySessionToken(token).isEmpty()); } - private static void assertPrefs(AccountPreferences expected, String uuid, long accountId, Map prefs) { + private static void assertPrefs(AccountPreferences expected, ArtifactId artId, Long accountId, Map prefs) { assertEquals(accountId, expected.getId()); - assertPrefs(expected, uuid, prefs); + assertPrefs(expected, artId, prefs); } - private static void assertPrefs(AccountPreferences expected, String uuid, Map prefs) { + private static void assertPrefs(AccountPreferences expected, ArtifactId artId, Map prefs) { assertTrue(expected.getId() > 0L); - assertEquals(uuid, expected.getGuid()); + assertEquals(artId.getUuid(), expected.getId()); Map actual = expected.asMap(); if (prefs != null) { @@ -247,15 +211,15 @@ public class OrcsAccountStorageTest { assertEquals(false, Compare.isDifferent(expected, actual)); } - private static void assertAccount(Account account, String uuid, String name, String email, String username, boolean isActive, Map prefs) { + private static void assertAccount(Account account, ArtifactId artId, String name, String email, String username, boolean isActive, Map prefs) { assertTrue(account.getId() > 0L); - assertEquals(uuid, account.getGuid()); + assertEquals(artId.getUuid(), account.getId()); assertEquals(name, account.getName()); assertEquals(email, account.getEmail()); assertEquals(username, account.getUserName()); assertEquals(isActive, account.isActive()); - assertPrefs(account.getPreferences(), uuid, prefs); + assertPrefs(account.getPreferences(), artId, prefs); } } diff --git a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsSubscriptionStorageTest.java b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsSubscriptionStorageTest.java index 1b5ed52a659..d4de22921b1 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsSubscriptionStorageTest.java +++ b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsSubscriptionStorageTest.java @@ -11,7 +11,6 @@ package org.eclipse.osee.orcs.account.admin.integration; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; import java.util.HashMap; @@ -23,7 +22,9 @@ import org.eclipse.osee.account.admin.Subscription; import org.eclipse.osee.account.admin.SubscriptionGroup; import org.eclipse.osee.account.admin.ds.AccountStorage; import org.eclipse.osee.account.admin.ds.SubscriptionStorage; -import org.eclipse.osee.framework.jdk.core.type.Identifiable; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.jdk.core.type.ResultSet; import org.eclipse.osee.orcs.account.admin.internal.OrcsSubscriptionStorage; import org.eclipse.osee.orcs.db.mock.OsgiService; @@ -42,7 +43,7 @@ import org.mockito.Mock; */ public class OrcsSubscriptionStorageTest { - private static final String SUBSCRIPTION_GROUP = "Subscription-Group1"; + private static final String SUBSCRIPTION_GROUP_NAME = "Subscription-Group1"; @Rule public TestRule osgi = OrcsIntegrationRule.integrationRule(this); @@ -70,7 +71,7 @@ public class OrcsSubscriptionStorageTest { private boolean active; private Map prefs; - private Identifiable newAccount; + private ArtifactId newAccountId; @Before public void testSetup() { @@ -94,61 +95,59 @@ public class OrcsSubscriptionStorageTest { when(request.getPreferences()).thenReturn(prefs); when(request.isActive()).thenReturn(active); - newAccount = accountStorage.createAccount(request); + newAccountId = accountStorage.createAccount(request); } @Test public void testSubscriptionAPI() { - Account account = accountStorage.getAccountByGuid(newAccount.getGuid()).getExactlyOne(); + Account account = accountStorage.getAccountById(newAccountId).getExactlyOne(); - long accountId = account.getId(); - ResultSet results = storage.getSubscriptionsByAccountLocalId(accountId); + ResultSet results = storage.getSubscriptionsByAccountId(newAccountId); assertEquals(true, results.isEmpty()); - assertEquals(false, storage.subscriptionGroupNameExists(SUBSCRIPTION_GROUP)); + assertEquals(false, storage.subscriptionGroupNameExists(SUBSCRIPTION_GROUP_NAME)); - SubscriptionGroup group = storage.createSubscriptionGroup(SUBSCRIPTION_GROUP); - assertNotNull(group); + SubscriptionGroupId groupId = storage.createSubscriptionGroup(SUBSCRIPTION_GROUP_NAME); + assertEquals(true, groupId.getUuid() > 0); - assertEquals(true, storage.subscriptionGroupNameExists(SUBSCRIPTION_GROUP)); + assertEquals(true, storage.subscriptionGroupNameExists(SUBSCRIPTION_GROUP_NAME)); - SubscriptionGroup group1 = storage.getSubscriptionGroups().getExactlyOne(); - assertEquals(group, group1); + SubscriptionGroup group1Id = storage.getSubscriptionGroups().getExactlyOne(); + assertEquals(groupId, group1Id.getId()); - ResultSet members = storage.getSubscriptionGroupMembersByLocalId(group.getId()); + ResultSet members = storage.getMembersOfSubscriptionGroupById(groupId); assertEquals(true, members.isEmpty()); - Subscription subscription = storage.getSubscriptionsByAccountLocalId(account.getId()).getExactlyOne(); - assertEquals(group.getId(), subscription.getGroupId()); - assertEquals(group.getName(), subscription.getName()); - assertEquals(account.getId(), subscription.getAccountId()); + ArtifactId artId = TokenFactory.createArtifactId(account.getId()); + Subscription subscription = storage.getSubscriptionsByAccountId(artId).getExactlyOne(); + assertEquals(groupId, subscription.getGroupId()); + assertEquals(account.getId(), subscription.getAccountId().getUuid()); assertEquals(account.getName(), subscription.getAccountName()); assertEquals(false, subscription.isActive()); // Activate Subscription - storage.updateSubscription(subscription.getAccountId(), subscription.getGroupId(), true); + storage.updateSubscription(subscription, true); - String subscriptionUuid = subscription.getGuid(); - subscription = storage.getSubscription(subscriptionUuid); + subscription = storage.getSubscriptionsByAccountId(artId).getExactlyOne(); assertEquals(true, subscription.isActive()); - members = storage.getSubscriptionGroupMembersByLocalId(group.getId()); + members = storage.getMembersOfSubscriptionGroupById(groupId); assertEquals(1, members.size()); Account member = members.getExactlyOne(); assertEquals(account, member); // De-Activate Subscription - storage.updateSubscription(subscription.getAccountId(), subscription.getGroupId(), false); + storage.updateSubscription(subscription, false); - subscription = storage.getSubscription(subscriptionUuid); + subscription = storage.getSubscriptionsByAccountId(artId).getExactlyOne(); assertEquals(false, subscription.isActive()); - members = storage.getSubscriptionGroupMembersByLocalId(group.getId()); + members = storage.getMembersOfSubscriptionGroupById(groupId); assertEquals(true, members.isEmpty()); - storage.deleteSubscriptionGroup(group); - assertEquals(false, storage.subscriptionGroupNameExists(SUBSCRIPTION_GROUP)); + storage.deleteSubscriptionGroup(groupId); + assertEquals(false, storage.subscriptionGroupNameExists(SUBSCRIPTION_GROUP_NAME)); } } diff --git a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/internal/SubscriptionUtilTest.java b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/internal/SubscriptionUtilTest.java index 1eaa2d4046a..fc0e904ba4f 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/internal/SubscriptionUtilTest.java +++ b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/internal/SubscriptionUtilTest.java @@ -14,6 +14,9 @@ import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.eclipse.osee.account.admin.Subscription; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.orcs.account.admin.internal.SubscriptionUtil.ActiveDelegate; import org.eclipse.osee.orcs.data.ArtifactReadable; import org.junit.Test; @@ -26,10 +29,10 @@ import org.mockito.Mockito; */ public class SubscriptionUtilTest { - private static final long ACCOUNT_ID = 3242L; + private static final ArtifactId ACCOUNT_ID = TokenFactory.createArtifactId(3242L); private static final String ACCOUNT_NAME = "account-name"; - private static final long GROUP_ID = 97012L; + private static final SubscriptionGroupId GROUP_ID = new SubscriptionGroupId(97012L); private static final String SUBSCRIPTION_NAME = "subscription-name"; @Test @@ -79,11 +82,11 @@ public class SubscriptionUtilTest { String encodedUuid = SubscriptionUtil.toEncodedUuid(ACCOUNT_ID, ACCOUNT_NAME, GROUP_ID, SUBSCRIPTION_NAME); ArtifactReadable accountArt = Mockito.mock(ArtifactReadable.class); - when(accountArt.getUuid()).thenReturn(ACCOUNT_ID); + when(accountArt.getUuid()).thenReturn(ACCOUNT_ID.getUuid()); when(accountArt.getName()).thenReturn(ACCOUNT_NAME); ArtifactReadable subscriptionArt = Mockito.mock(ArtifactReadable.class); - when(subscriptionArt.getUuid()).thenReturn(GROUP_ID); + when(subscriptionArt.getUuid()).thenReturn(GROUP_ID.getUuid()); when(subscriptionArt.getName()).thenReturn(SUBSCRIPTION_NAME); Subscription actual = SubscriptionUtil.fromArtifactData(accountArt, subscriptionArt, true); diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountArtifact.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountArtifact.java index b1d2608b723..efd4b620896 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountArtifact.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountArtifact.java @@ -36,7 +36,7 @@ public class AccountArtifact extends BaseIdentityimplements Account { } @Override - public long getId() { + public Long getId() { return artifact.getUuid(); } diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountFactory.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountFactory.java index 0f1f35e0b78..fe89592c15f 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountFactory.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountFactory.java @@ -16,6 +16,7 @@ import org.eclipse.osee.account.admin.AccountPreferences; import org.eclipse.osee.account.admin.AccountSession; import org.eclipse.osee.account.admin.SubscriptionGroup; import org.eclipse.osee.account.rest.model.AccountWebPreferences; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.jdk.core.type.ResultSet; import org.eclipse.osee.framework.jdk.core.type.ResultSetTransform.Function; @@ -72,14 +73,14 @@ public class AccountFactory { } } - public AccountSession newAccountSession(long accountId, String sessionToken, String accessedFrom, String accessDetails) { + public AccountSession newAccountSession(ArtifactId accountId, String sessionToken, String accessedFrom, String accessDetails) { Date currentDate = new Date(); return newAccountSession(accountId, sessionToken, currentDate, currentDate, accessedFrom, accessDetails); } - public AccountSession newAccountSession(long accountId, String sessionToken, Date createdOn, Date lastAccessedOn, String accessedFrom, String accessDetails) { + public AccountSession newAccountSession(ArtifactId accountId, String sessionToken, Date createdOn, Date lastAccessedOn, String accessedFrom, String accessDetails) { AccountSessionImpl session = new AccountSessionImpl(); - session.setAccountId(accountId); + session.setAccountId(accountId.getUuid()); session.setSessionToken(sessionToken); session.setCreatedOn(createdOn); session.setLastAccessedOn(lastAccessedOn); @@ -89,7 +90,7 @@ public class AccountFactory { } public SubscriptionGroup newAccountSubscriptionGroup(ArtifactReadable source) { - return new AccountSubscriptionGroupImpl(source.getGuid(), source); + return new AccountSubscriptionGroupImpl(source); } public ResultSet newAccountSubscriptionGroupResultSet(ResultSet results) { diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountPreferencesArtifact.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountPreferencesArtifact.java index b57f99f1cf5..050409a8b80 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountPreferencesArtifact.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountPreferencesArtifact.java @@ -39,7 +39,7 @@ public class AccountPreferencesArtifact extends BaseIdentityimplements A } @Override - public long getId() { + public Long getId() { return artifact.getUuid(); } diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionDatabaseStore.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionDatabaseStore.java index ad3834901be..556ef823439 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionDatabaseStore.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionDatabaseStore.java @@ -17,6 +17,8 @@ import java.util.List; import java.util.concurrent.Callable; import org.eclipse.osee.account.admin.AccountSession; import org.eclipse.osee.executor.admin.CancellableCallable; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.jdk.core.type.ResultSet; import org.eclipse.osee.framework.jdk.core.type.ResultSets; import org.eclipse.osee.framework.jdk.core.util.Lib; @@ -71,7 +73,7 @@ public class AccountSessionDatabaseStore implements AccountSessionStorage { } @Override - public Callable> getAccountSessionByAccountId(long accountId) { + public Callable> getAccountSessionByAccountId(ArtifactId accountId) { return selectAccess(SELECT_BY_ACCOUNT_ID, accountId); } @@ -96,7 +98,8 @@ public class AccountSessionDatabaseStore implements AccountSessionStorage { Date lastAccessedOn = chStmt.getTimestamp("last_accessed_on"); String accessedFrom = chStmt.getString("accessed_from"); String accessDetails = chStmt.getString("access_details"); - AccountSession session = factory.newAccountSession(accountId, sessionToken, createdOn, lastAccessedOn, + ArtifactId artId = TokenFactory.createArtifactId(accountId); + AccountSession session = factory.newAccountSession(artId, sessionToken, createdOn, lastAccessedOn, accessedFrom, accessDetails); list.add(session); } diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionImpl.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionImpl.java index 052ee3759c7..502558fb171 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionImpl.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionImpl.java @@ -18,7 +18,7 @@ import org.eclipse.osee.account.admin.AccountSession; */ public class AccountSessionImpl implements AccountSession { - private long accountId; + private Long accountId; private String sessionToken; private Date createdOn; private Date lastAccessedOn; @@ -26,7 +26,7 @@ public class AccountSessionImpl implements AccountSession { private String accessDetails; @Override - public long getAccountId() { + public Long getAccountId() { return accountId; } @@ -55,7 +55,7 @@ public class AccountSessionImpl implements AccountSession { return accessDetails; } - public void setAccountId(long accountId) { + public void setAccountId(Long accountId) { this.accountId = accountId; } @@ -107,7 +107,7 @@ public class AccountSessionImpl implements AccountSession { } else if (!sessionToken.equals(other.sessionToken)) { return false; } - if (accountId != other.accountId) { + if (!accountId.equals(other.accountId)) { return false; } return true; diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionStorage.java index 8d2f7872bc1..b02dbfd1f96 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionStorage.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionStorage.java @@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.account.admin.internal; import java.util.concurrent.Callable; import org.eclipse.osee.account.admin.AccountSession; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.ResultSet; /** @@ -19,7 +20,7 @@ import org.eclipse.osee.framework.jdk.core.type.ResultSet; */ public interface AccountSessionStorage { - Callable> getAccountSessionByAccountId(long accountId); + Callable> getAccountSessionByAccountId(ArtifactId accountId); Callable> getAccountSessionBySessionToken(String sessionToken); diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSubscriptionGroupImpl.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSubscriptionGroupImpl.java index 1f2a0a893d9..b32e89353f6 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSubscriptionGroupImpl.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSubscriptionGroupImpl.java @@ -11,6 +11,7 @@ package org.eclipse.osee.orcs.account.admin.internal; import org.eclipse.osee.account.admin.SubscriptionGroup; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.jdk.core.type.BaseIdentity; import org.eclipse.osee.orcs.data.ArtifactReadable; @@ -18,19 +19,21 @@ import org.eclipse.osee.orcs.data.ArtifactReadable; /** * @author Roberto E. Escobar */ -public class AccountSubscriptionGroupImpl extends BaseIdentityimplements SubscriptionGroup { +public class AccountSubscriptionGroupImpl extends BaseIdentity implements SubscriptionGroup { private static final String NOT_AVAILABLE = "N/A"; private final ArtifactReadable artifact; + private final SubscriptionGroupId id; - public AccountSubscriptionGroupImpl(String uuid, ArtifactReadable artifact) { + public AccountSubscriptionGroupImpl(ArtifactReadable artifact) { super(artifact.getGuid()); this.artifact = artifact; + this.id = new SubscriptionGroupId(artifact.getUuid()); } @Override - public long getId() { - return artifact.getUuid(); + public SubscriptionGroupId getId() { + return id; } @Override diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/BootstrapAccount.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/BootstrapAccount.java index d0ee1764e41..291291d9f16 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/BootstrapAccount.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/BootstrapAccount.java @@ -29,7 +29,7 @@ public class BootstrapAccount extends BaseIdentityimplements Account, Ac } @Override - public long getId() { + public Long getId() { return -1L; } diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java index f6fa30981c0..901f7292f72 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java @@ -10,8 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.orcs.account.admin.internal; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; import java.io.StringWriter; import java.util.Collections; import java.util.Map; @@ -23,21 +21,20 @@ import org.eclipse.osee.account.admin.CreateAccountRequest; import org.eclipse.osee.account.admin.ds.AccountStorage; import org.eclipse.osee.account.rest.model.AccountWebPreferences; import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.core.enums.SystemUser; -import org.eclipse.osee.framework.jdk.core.type.Identifiable; -import org.eclipse.osee.framework.jdk.core.type.Identity; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.type.PropertyStore; import org.eclipse.osee.framework.jdk.core.type.ResultSet; import org.eclipse.osee.framework.jdk.core.type.ResultSets; -import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.jdbc.JdbcClient; import org.eclipse.osee.jdbc.JdbcService; import org.eclipse.osee.orcs.data.ArtifactReadable; import org.eclipse.osee.orcs.transaction.TransactionBuilder; -import org.eclipse.osee.orcs.utility.OrcsUtil; +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; /** * @author Roberto E. Escobar @@ -92,29 +89,9 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt } @Override - public ResultSet getAccountByUserName(String username) { + public ResultSet getAccountById(ArtifactId accountId) { ResultSet results = - newQuery().andIsOfType(CoreArtifactTypes.User).and(CoreAttributeTypes.UserId, username).getResults(); - return getFactory().newAccountResultSet(results); - } - - @Override - public ResultSet getAccountByGuid(String guid) { - ResultSet results = newQuery().andIsOfType(CoreArtifactTypes.User).andGuid(guid).getResults(); - return getFactory().newAccountResultSet(results); - } - - @Override - public ResultSet getAccountByUuid(String accountUuid) { - ResultSet results = - newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(Long.parseLong(accountUuid)).getResults(); - return getFactory().newAccountResultSet(results); - } - - @Override - public ResultSet getAccountByLocalId(long accountId) { - int id = Long.valueOf(accountId).intValue(); - ResultSet results = newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(id).getResults(); + newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(accountId.getUuid()).getResults(); return getFactory().newAccountResultSet(results); } @@ -126,27 +103,14 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt } @Override - public ResultSet getAccountByName(String name) { - ResultSet results = - newQuery().andIsOfType(CoreArtifactTypes.User).andNameEquals(name).getResults(); - return getFactory().newAccountResultSet(results); - } - - @Override - public ResultSet getAccountPreferencesById(long accountId) { - int id = Long.valueOf(accountId).intValue(); + public ResultSet getAccountPreferencesById(ArtifactId accountId) { + int id = Long.valueOf(accountId.getUuid()).intValue(); ResultSet results = newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(id).getResults(); return getFactory().newAccountPreferencesResultSet(results); } @Override - public ResultSet getAccountPreferencesByGuid(String guid) { - ResultSet results = newQuery().andIsOfType(CoreArtifactTypes.User).andGuid(guid).getResults(); - return getFactory().newAccountPreferencesResultSet(results); - } - - @Override - public Identifiable createAccount(CreateAccountRequest request) { + public ArtifactId createAccount(CreateAccountRequest request) { TransactionBuilder tx = newTransaction("Create Account"); ArtifactId artId = tx.createArtifact(CoreArtifactTypes.User, request.getDisplayName()); tx.setSoleAttributeFromString(artId, CoreAttributeTypes.Email, request.getEmail()); @@ -155,7 +119,7 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt Map preferences = request.getPreferences(); if (preferences != null && !preferences.isEmpty()) { - String prefValue = asString(artId.getGuid(), preferences); + String prefValue = asString(artId, preferences); tx.createAttribute(artId, CoreAttributeTypes.UserSettings, prefValue); } tx.commit(); @@ -163,16 +127,14 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt } @Override - public void setActive(Identifiable account, boolean active) { - ArtifactId artId = OrcsUtil.newArtifactId(Lib.generateArtifactIdAsInt(), account.getGuid(), account.getName()); - + public void setActive(ArtifactId accountId, boolean active) { TransactionBuilder tx = newTransaction("Update Account Active"); - tx.setSoleAttributeValue(artId, CoreAttributeTypes.Active, active); + tx.setSoleAttributeValue(accountId, CoreAttributeTypes.Active, active); tx.commit(); } - private String asString(String uuid, Map preferences) { - PropertyStore settings = new PropertyStore(uuid); + private String asString(ArtifactId artId, Map preferences) { + PropertyStore settings = new PropertyStore(Long.toString(artId.getUuid())); for (Entry entry : preferences.entrySet()) { settings.put(entry.getKey(), entry.getValue()); } @@ -187,26 +149,23 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt } @Override - public void setAccountPreferences(Identity account, Map preferences) { - String prefValue = asString(account.getGuid(), preferences); + public void setAccountPreferences(ArtifactId accountId, Map preferences) { + String prefValue = asString(accountId, preferences); - ArtifactId artId = OrcsUtil.newArtifactId(Lib.generateArtifactIdAsInt(), account.getGuid(), "N/A"); TransactionBuilder tx = newTransaction("User - Save Settings"); - tx.setSoleAttributeFromString(artId, CoreAttributeTypes.UserSettings, prefValue); + tx.setSoleAttributeFromString(accountId, CoreAttributeTypes.UserSettings, prefValue); tx.commit(); } @Override - public void deleteAccount(Identifiable account) { - ArtifactId artId = OrcsUtil.newArtifactId(Lib.generateArtifactIdAsInt(), account.getGuid(), account.getName()); - + public void deleteAccount(ArtifactId accountId) { TransactionBuilder tx = newTransaction("Delete User"); - tx.deleteArtifact(artId); + tx.deleteArtifact(accountId); tx.commit(); } @Override - public ResultSet getAccountSessionById(long accountId) { + public ResultSet getAccountSessionById(ArtifactId accountId) { try { return sessionStore.getAccountSessionByAccountId(accountId).call(); } catch (Exception ex) { @@ -225,8 +184,8 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt @Override public AccountSession createAccountSession(String sessionToken, Account account, String remoteAddress, String accessDetails) { - AccountSession session = - getFactory().newAccountSession(account.getId(), sessionToken, remoteAddress, accessDetails); + ArtifactId artId = TokenFactory.createArtifactId(account.getId()); + AccountSession session = getFactory().newAccountSession(artId, sessionToken, remoteAddress, accessDetails); try { sessionStore.createAccountSession(Collections.singleton(session)).call(); return session; @@ -260,30 +219,23 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt @Override public ResultSet get() { ResultSet results = - newQuery().andIsOfType(CoreArtifactTypes.User).andGuid(SystemUser.Anonymous.getGuid()).getResults(); + newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(SystemUser.Anonymous.getUuid()).getResults(); return getFactory().newAccountResultSet(results); } }; } @Override - public void setAccountWebPreferences(String guid, String preferences) { - ArtifactId artId = OrcsUtil.newArtifactId(1, guid, "name"); + public void setAccountWebPreferences(ArtifactId artifactId, String preferences) { TransactionBuilder tx = newTransaction("User - Save Web Preferences"); - tx.setSoleAttributeFromString(artId, CoreAttributeTypes.WebPreferences, preferences); + tx.setSoleAttributeFromString(artifactId, CoreAttributeTypes.WebPreferences, preferences); tx.commit(); } @Override - public AccountWebPreferences getAccountWebPreferencesByGuid(String guid) { - ResultSet results = newQuery().andIsOfType(CoreArtifactTypes.User).andGuid(guid).getResults(); - return getFactory().newAccountWebPreferences(results.getExactlyOne()); - } - - @Override - public AccountWebPreferences getAccountWebPreferencesById(int accountId) { + public AccountWebPreferences getAccountWebPreferencesById(ArtifactId accountId) { ResultSet results = - newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(accountId).getResults(); + newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(accountId.getUuid()).getResults(); return getFactory().newAccountWebPreferences(results.getExactlyOne()); } diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsSubscriptionStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsSubscriptionStorage.java index 0fe166860e3..10a07aadd37 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsSubscriptionStorage.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsSubscriptionStorage.java @@ -17,16 +17,16 @@ import org.eclipse.osee.account.admin.Account; import org.eclipse.osee.account.admin.Subscription; import org.eclipse.osee.account.admin.SubscriptionGroup; import org.eclipse.osee.account.admin.ds.SubscriptionStorage; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreRelationTypes; import org.eclipse.osee.framework.jdk.core.type.ResultSet; import org.eclipse.osee.framework.jdk.core.type.ResultSets; -import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.orcs.account.admin.internal.SubscriptionUtil.ActiveDelegate; import org.eclipse.osee.orcs.data.ArtifactReadable; import org.eclipse.osee.orcs.transaction.TransactionBuilder; -import org.eclipse.osee.orcs.utility.OrcsUtil; /** * @author Roberto E. Escobar @@ -34,10 +34,9 @@ import org.eclipse.osee.orcs.utility.OrcsUtil; public class OrcsSubscriptionStorage extends AbstractOrcsStorage implements SubscriptionStorage { @Override - public ResultSet getSubscriptionsByAccountLocalId(long accountId) { - int intAccountId = Long.valueOf(accountId).intValue(); + public ResultSet getSubscriptionsByAccountId(ArtifactId accountId) { ResultSet accountResults = - newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(intAccountId).getResults(); + newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(accountId.getUuid()).getResults(); ArtifactReadable account = accountResults.getExactlyOne(); ResultSet allGroups = newQuery().andIsOfType(CoreArtifactTypes.SubscriptionGroup).getResults(); @@ -50,9 +49,9 @@ public class OrcsSubscriptionStorage extends AbstractOrcsStorage implements Subs } @Override - public void updateSubscription(long accountId, long groupId, boolean activate) { - int intAccountId = Long.valueOf(accountId).intValue(); - int intGroupId = Long.valueOf(groupId).intValue(); + public void updateSubscription(Subscription subscription, boolean activate) { + Long intAccountId = subscription.getAccountId().getUuid(); + Long intGroupId = subscription.getGroupId().getUuid(); ArtifactReadable account = newQuery().andUuid(intAccountId).getResults().getExactlyOne(); ArtifactReadable group = @@ -71,8 +70,8 @@ public class OrcsSubscriptionStorage extends AbstractOrcsStorage implements Subs } @Override - public Subscription getSubscription(String subscriptionUuid) { - return SubscriptionUtil.fromEncodedUuid(subscriptionUuid, new LazyActiveDelegate()); + public Subscription getSubscriptionByEncodedId(String encodedId) { + return SubscriptionUtil.fromEncodedUuid(encodedId, new LazyActiveDelegate()); } private class LazyActiveDelegate implements ActiveDelegate { @@ -81,10 +80,10 @@ public class OrcsSubscriptionStorage extends AbstractOrcsStorage implements Subs private volatile boolean isActive; @Override - public boolean isActive(long accountId, long groupId) { + public boolean isActive(ArtifactId accountId, SubscriptionGroupId groupId) { if (wasRun.compareAndSet(false, true)) { - int intAccountId = Long.valueOf(accountId).intValue(); - int intGroupId = Long.valueOf(groupId).intValue(); + int intAccountId = Long.valueOf(accountId.getUuid()).intValue(); + int intGroupId = Long.valueOf(groupId.getUuid()).intValue(); ArtifactReadable account = newQuery().andUuid(intAccountId).getResults().getExactlyOne(); ArtifactReadable group = newQuery().andUuid(intGroupId).getResults().getExactlyOne(); @@ -100,31 +99,9 @@ public class OrcsSubscriptionStorage extends AbstractOrcsStorage implements Subs return getFactory().newAccountSubscriptionGroupResultSet(results); } - @Override - public ResultSet getSubscriptionGroupByLocalId(long groupId) { - int intGroupId = Long.valueOf(groupId).intValue(); - ResultSet results = - newQuery().andUuid(intGroupId).andIsOfType(CoreArtifactTypes.SubscriptionGroup).getResults(); - return getFactory().newAccountSubscriptionGroupResultSet(results); - } - - @Override - public ResultSet getSubscriptionGroupByName(String name) { - ResultSet results = - newQuery().andIsOfType(CoreArtifactTypes.SubscriptionGroup).andNameEquals(name).getResults(); - return getFactory().newAccountSubscriptionGroupResultSet(results); - } - - @Override - public ResultSet getSubscriptionGroupByGuid(String guid) { - ResultSet results = - newQuery().andGuid(guid).andIsOfType(CoreArtifactTypes.SubscriptionGroup).getResults(); - return getFactory().newAccountSubscriptionGroupResultSet(results); - } - @SuppressWarnings("unchecked") @Override - public SubscriptionGroup createSubscriptionGroup(String name) { + public SubscriptionGroupId createSubscriptionGroup(String name) { String comment = String.format("Create subscription group [%s]", name); TransactionBuilder tx = newTransaction(comment); @@ -132,40 +109,52 @@ public class OrcsSubscriptionStorage extends AbstractOrcsStorage implements Subs tx.commit(); ArtifactReadable groupArt = newQuery().andIds(artId).getResults().getExactlyOne(); - return getFactory().newAccountSubscriptionGroup(groupArt); + return new SubscriptionGroupId(groupArt.getUuid()); } @Override - public void deleteSubscriptionGroup(SubscriptionGroup group) { - ArtifactId artId = OrcsUtil.newArtifactId(Lib.generateArtifactIdAsInt(), group.getGuid(), group.getName()); - - String comment = String.format("Delete subscription group [%s]", group.getName()); - TransactionBuilder tx = newTransaction(comment); - tx.deleteArtifact(artId); - tx.commit(); + public boolean deleteSubscriptionGroup(SubscriptionGroupId subscriptionId) { + boolean toReturn = false; + + SubscriptionGroup subscriptionGroup = getSubscriptionGroupById(subscriptionId); + + if (subscriptionGroup != null) { + ArtifactId subscriptionAsArtId = TokenFactory.createArtifactId(subscriptionId.getUuid()); + String comment = String.format("Delete subscription group [%s]", subscriptionGroup.getName()); + TransactionBuilder tx = newTransaction(comment); + tx.deleteArtifact(subscriptionAsArtId); + tx.commit(); + toReturn = true; + } + return toReturn; } @Override - public ResultSet getSubscriptionGroupMembersByLocalId(long groupId) { - int intGroupId = Long.valueOf(groupId).intValue(); + public SubscriptionGroup getSubscriptionGroupById(SubscriptionGroupId groupId) { ResultSet results = - newQuery().andIsOfType(CoreArtifactTypes.User).andRelatedToLocalIds(CoreRelationTypes.Users_Artifact, - intGroupId).getResults(); - return getFactory().newAccountResultSet(results); + newQuery().andUuid(groupId.getUuid()).andIsOfType(CoreArtifactTypes.SubscriptionGroup).getResults(); + return getFactory().newAccountSubscriptionGroupResultSet(results).getExactlyOne(); + } + + @Override + public boolean subscriptionGroupNameExists(String groupName) { + int count = newQuery().andIsOfType(CoreArtifactTypes.SubscriptionGroup).andNameEquals(groupName).getCount(); + return count > 0; } @Override - public ResultSet getSubscriptionGroupMembersByName(String name) { + public ResultSet getSubscriptionMembersById(SubscriptionGroupId groupId) { + int intGroupId = Long.valueOf(groupId.getUuid()).intValue(); ResultSet results = - newQuery().andIsOfType(CoreArtifactTypes.SubscriptionGroup).andNameEquals(name).getResults(); - ArtifactReadable group = results.getOneOrNull(); - return getMembers(group); + newQuery().andIsOfType(CoreArtifactTypes.User).andRelatedToLocalIds(CoreRelationTypes.Users_Artifact, + intGroupId).getResults(); + return getFactory().newAccountResultSet(results); } @Override - public ResultSet getSubscriptionGroupMembersByGuid(String guid) { + public ResultSet getMembersOfSubscriptionGroupById(SubscriptionGroupId subscriptionId) { ResultSet results = - newQuery().andIsOfType(CoreArtifactTypes.SubscriptionGroup).andGuid(guid).getResults(); + newQuery().andIsOfType(CoreArtifactTypes.SubscriptionGroup).andUuid(subscriptionId.getUuid()).getResults(); ArtifactReadable group = results.getOneOrNull(); return getMembers(group); } @@ -180,10 +169,4 @@ public class OrcsSubscriptionStorage extends AbstractOrcsStorage implements Subs } return toReturn; } - - @Override - public boolean subscriptionGroupNameExists(String groupName) { - int count = newQuery().andIsOfType(CoreArtifactTypes.SubscriptionGroup).andNameEquals(groupName).getCount(); - return count > 0; - } } diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/SubscriptionUtil.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/SubscriptionUtil.java index 10f4ea06f32..395e230a428 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/SubscriptionUtil.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/SubscriptionUtil.java @@ -11,6 +11,9 @@ package org.eclipse.osee.orcs.account.admin.internal; import org.eclipse.osee.account.admin.Subscription; +import org.eclipse.osee.account.rest.model.SubscriptionGroupId; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.jdk.core.type.NamedIdentity; import org.eclipse.osee.framework.jdk.core.util.EncryptUtility; import org.eclipse.osee.orcs.data.ArtifactReadable; @@ -24,11 +27,11 @@ public final class SubscriptionUtil { public static interface ActiveDelegate { - boolean isActive(long accountId, long groupId); + boolean isActive(ArtifactId accountId, SubscriptionGroupId groupId); } - public static String toEncodedUuid(long accountId, String accountDisplayName, long groupId, String subscriptionName) { - String rawData = String.format("%s:%s:%s:%s", accountId, accountDisplayName, groupId, subscriptionName); + public static String toEncodedUuid(ArtifactId accountId, String accountDisplayName, SubscriptionGroupId groupId, String subscriptionName) { + String rawData = String.format("%s:%s:%s:%s", accountId.getUuid(), accountDisplayName, groupId, subscriptionName); return EncryptUtility.encrypt(rawData, SUBSCRIPTION_SECRET); } @@ -37,31 +40,36 @@ public final class SubscriptionUtil { String[] data = decrypted.split(":"); int index = 0; int accountId = Integer.parseInt(data[index++]); + ArtifactId artId = TokenFactory.createArtifactId(Long.valueOf(accountId)); + String accountDisplayName = data[index++]; int groupId = Integer.parseInt(data[index++]); + SubscriptionGroupId subscriptionId = new SubscriptionGroupId((long) groupId); String subscriptionName = data[index++]; - return new DelegatingActiveSubscriptionImpl(subscriptionUuid, accountId, accountDisplayName, groupId, + return new DelegatingActiveSubscriptionImpl(subscriptionUuid, artId, accountDisplayName, subscriptionId, subscriptionName, delegate); } - public static Subscription fromData(long accountId, String accountDisplayName, long groupId, String subscriptionName, boolean isActive) { + public static Subscription fromData(ArtifactId accountId, String accountDisplayName, SubscriptionGroupId groupId, String subscriptionName, boolean isActive) { String encodedUuid = toEncodedUuid(accountId, accountDisplayName, groupId, subscriptionName); return new SubscriptionImpl(encodedUuid, accountId, accountDisplayName, groupId, subscriptionName, isActive); } public static Subscription fromArtifactData(ArtifactReadable account, ArtifactReadable subscription, boolean isActive) { int accountId = account.getLocalId(); + ArtifactId artId = TokenFactory.createArtifactId(Long.valueOf(accountId)); String accountName = account.getName(); int groupId = subscription.getLocalId(); + SubscriptionGroupId subcriptionId = new SubscriptionGroupId((long) groupId); String subscriptionName = subscription.getName(); - return fromData(accountId, accountName, groupId, subscriptionName, isActive); + return fromData(artId, accountName, subcriptionId, subscriptionName, isActive); } private static final class DelegatingActiveSubscriptionImpl extends SubscriptionImpl { private final ActiveDelegate provider; - private DelegatingActiveSubscriptionImpl(String encodedUuid, long accountId, String accountDisplayName, long groupId, String subscriptionName, ActiveDelegate provider) { + private DelegatingActiveSubscriptionImpl(String encodedUuid, ArtifactId accountId, String accountDisplayName, SubscriptionGroupId groupId, String subscriptionName, ActiveDelegate provider) { super(encodedUuid, accountId, accountDisplayName, groupId, subscriptionName, false); this.provider = provider; } @@ -72,14 +80,14 @@ public final class SubscriptionUtil { } } - private static class SubscriptionImpl extends NamedIdentityimplements Subscription { + private static class SubscriptionImpl extends NamedIdentity implements Subscription { - private final long accountId; + private final ArtifactId accountId; private final String accountDisplayName; - private final long groupId; + private final SubscriptionGroupId groupId; private final boolean active; - private SubscriptionImpl(String encodedUuid, long accountId, String accountDisplayName, long groupId, String subscriptionName, boolean active) { + private SubscriptionImpl(String encodedUuid, ArtifactId accountId, String accountDisplayName, SubscriptionGroupId groupId, String subscriptionName, boolean active) { super(encodedUuid, subscriptionName); this.accountId = accountId; this.accountDisplayName = accountDisplayName; @@ -88,7 +96,7 @@ public final class SubscriptionUtil { } @Override - public long getAccountId() { + public ArtifactId getAccountId() { return accountId; } @@ -98,7 +106,7 @@ public final class SubscriptionUtil { } @Override - public long getGroupId() { + public SubscriptionGroupId getGroupId() { return groupId; } diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientArtifact.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientArtifact.java index 566030af7c4..12eb1f75ee3 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientArtifact.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientArtifact.java @@ -10,10 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.orcs.account.admin.internal.oauth; -import com.google.common.io.InputSupplier; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; import java.io.InputStream; import java.lang.reflect.Type; import java.util.Collections; @@ -24,11 +20,15 @@ import org.eclipse.osee.framework.jdk.core.type.BaseIdentity; import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.jaxrs.server.security.OAuthClient; import org.eclipse.osee.orcs.data.ArtifactReadable; +import com.google.common.io.InputSupplier; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; /** * @author Roberto E. Escobar */ -public class ClientArtifact extends BaseIdentityimplements OAuthClient, InputSupplier { +public class ClientArtifact extends BaseIdentity implements OAuthClient, InputSupplier { private final GsonBuilder builder; private final ArtifactReadable artifact; diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientStorage.java index 947abf1584a..385a2517b46 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientStorage.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientStorage.java @@ -19,16 +19,13 @@ import static org.eclipse.osee.orcs.account.admin.internal.oauth.OAuthTypes.OAUT import static org.eclipse.osee.orcs.account.admin.internal.oauth.OAuthTypes.OAUTH_CLIENT_LOGO_URI; import static org.eclipse.osee.orcs.account.admin.internal.oauth.OAuthTypes.OAUTH_CLIENT_PROPERTIES; import static org.eclipse.osee.orcs.account.admin.internal.oauth.OAuthTypes.OAUTH_CLIENT_WEBSITE_URI; -import static org.eclipse.osee.orcs.account.admin.internal.oauth.OAuthTypes.OAUTH_TYPES_ARTIFACT; -import com.google.common.io.InputSupplier; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; +import static org.eclipse.osee.orcs.account.admin.internal.oauth.OAuthTypes.OAUTH_TYPES; import java.io.IOException; import java.io.InputStream; import java.util.Map; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.IOseeBranch; -import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.core.enums.SystemUser; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -43,7 +40,9 @@ import org.eclipse.osee.orcs.search.QueryBuilder; import org.eclipse.osee.orcs.search.QueryFactory; import org.eclipse.osee.orcs.transaction.TransactionBuilder; import org.eclipse.osee.orcs.transaction.TransactionFactory; -import org.eclipse.osee.orcs.utility.OrcsUtil; +import com.google.common.io.InputSupplier; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; /** * @author Roberto E. Escobar @@ -109,19 +108,24 @@ public class ClientStorage { return newQuery().andIsOfType(OAUTH_CLIENT).andGuid(guid).getResults(); } - public boolean exists(String guid) { - return newQuery().andIsOfType(OAUTH_CLIENT).andGuid(guid).getCount() > 0; + public ResultSet getClientByClientUuid(Long uuid) { + return newQuery().andIsOfType(OAUTH_CLIENT).andUuid(uuid).getResults(); + } + + public boolean exists(Long uuid) { + return newQuery().andIsOfType(OAUTH_CLIENT).andUuid(uuid).getCount() > 0; } - public void insert(OseePrincipal principal, OAuthClient data) { + public ArtifactId insert(OseePrincipal principal, OAuthClient data) { TransactionBuilder tx = newTransaction(principal, "Create OAuth Client"); ArtifactId artId = tx.createArtifact(OAUTH_CLIENT, data.getApplicationName(), data.getGuid()); txSetClient(tx, artId, data); tx.commit(); + return artId; } public void update(OseePrincipal principal, OAuthClient data) { - ArtifactId artId = OrcsUtil.newArtifactId(data.getClientUuid(), data.getGuid(), data.getApplicationName()); + ArtifactId artId = TokenFactory.createArtifactId(data.getClientUuid()); TransactionBuilder tx = newTransaction(principal, "Update OAuth Client"); tx.setName(artId, data.getApplicationName()); @@ -134,9 +138,9 @@ public class ClientStorage { tx.setSoleAttributeFromString(artId, CoreAttributeTypes.Description, data.getApplicationDescription()); tx.setSoleAttributeFromString(artId, OAUTH_CLIENT_WEBSITE_URI, data.getApplicationWebUri()); tx.setSoleAttributeFromString(artId, OAUTH_CLIENT_LOGO_URI, data.getApplicationLogoUri()); - + tx.setSoleAttributeValue(artId, OAUTH_CLIENT_IS_CONFIDENTIAL, data.isConfidential()); - + tx.setAttributesFromStrings(artId, OAUTH_CLIENT_AUTHORIZED_AUDIENCE, data.getRegisteredAudiences()); tx.setAttributesFromStrings(artId, OAUTH_CLIENT_AUTHORIZED_GRANT_TYPE, data.getAllowedGrantTypes()); tx.setAttributesFromStrings(artId, OAUTH_CLIENT_AUTHORIZED_REDIRECT_URI, data.getRedirectUris()); @@ -159,25 +163,20 @@ public class ClientStorage { } public void delete(OseePrincipal principal, OAuthClient data) { - ArtifactId artId = OrcsUtil.newArtifactId(data.getClientUuid(), data.getGuid(), data.getApplicationName()); + ArtifactId artId = TokenFactory.createArtifactId(data.getClientUuid()); TransactionBuilder tx = newTransaction(principal, "Delete OAuth Client"); tx.deleteArtifact(artId); tx.commit(); } - @SuppressWarnings("unchecked") private ResultSet getOAuthTypesDefinition() throws OseeCoreException { - return newQuery().andIds(OAUTH_TYPES_ARTIFACT).getResults(); + return newQuery().andUuid(OAUTH_TYPES.getUuid()).andTypeEquals(OAUTH_TYPES.getArtifactType()).getResults(); } public void storeTypes(InputSupplier resource) { TransactionBuilder tx = newTransaction(null, "Initialize OAuth Type Definitions"); - - ArtifactId artifactId = OAUTH_TYPES_ARTIFACT; - if (!typesExist()) { - tx.createArtifact(CoreArtifactTypes.OseeTypeDefinition, artifactId.getName(), artifactId.getGuid()); - } + ArtifactId artifactId = tx.createArtifact(OAUTH_TYPES); InputStream stream = null; try { stream = resource.getInput(); @@ -188,6 +187,7 @@ public class ClientStorage { Lib.close(stream); } tx.commit(); + reloadTypes(); } diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/JdbcJaxRsOAuthStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/JdbcJaxRsOAuthStorage.java index 92330e5c58a..5a9c95faec6 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/JdbcJaxRsOAuthStorage.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/JdbcJaxRsOAuthStorage.java @@ -11,6 +11,8 @@ package org.eclipse.osee.orcs.account.admin.internal.oauth; import java.util.List; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.jdk.core.type.OseePrincipal; import org.eclipse.osee.jaxrs.server.security.JaxRsOAuthStorage; import org.eclipse.osee.jaxrs.server.security.OAuthClient; @@ -107,45 +109,47 @@ public class JdbcJaxRsOAuthStorage implements JaxRsOAuthStorage { } @Override - public void storeClient(OseePrincipal principal, OAuthClient client) { + public ArtifactId storeClient(OseePrincipal principal, OAuthClient client) { + ArtifactId clientArtId; ClientStorage clientStorage = getClientStorage(); - boolean exists = clientStorage.exists(client.getGuid()); + boolean exists = clientStorage.exists(client.getClientUuid()); if (exists) { clientStorage.update(principal, client); + clientArtId = TokenFactory.createArtifactId(client.getClientUuid()); } else { - clientStorage.insert(principal, client); + clientArtId = clientStorage.insert(principal, client); } - ArtifactReadable artifact = clientStorage.getClientByClientGuid(client.getGuid()).getExactlyOne(); - - long clientId = client.getClientUuid(); + long clientId = clientArtId.getUuid(); + ArtifactReadable artifact = clientStorage.getClientByClientUuid(clientId).getExactlyOne(); long applicationId = artifact.getLocalId(); - OAuthClientCredential credential = asCredential(client, applicationId); + OAuthClientCredential credential = asCredential(clientId, client, applicationId); if (credentialStorage.getByClientIdAndApplicationId(clientId, applicationId) != null) { credentialStorage.update(credential); } else { credentialStorage.insert(credential); } + return clientArtId; } - OAuthClientCredential asCredential(OAuthClient client, long applicationId) { - long clientId = client.getClientUuid(); + OAuthClientCredential asCredential(Long clientUuid, OAuthClient client, Long applicationId) { long subjectId = client.getSubjectId(); String clientKey = client.getClientId(); String clientSecret = client.getClientSecret(); List clientCerts = client.getApplicationCertificates(); - return credentialStorage.newCredential(clientId, applicationId, subjectId, clientKey, clientSecret, clientCerts); + return credentialStorage.newCredential(clientUuid, applicationId, subjectId, clientKey, clientSecret, + clientCerts); } @Override public void removeClient(OseePrincipal principal, OAuthClient client) { getClientStorage().delete(principal, client); - OAuthClientCredential credential = asCredential(client, -1L); + OAuthClientCredential credential = asCredential(client.getClientUuid(), client, -1L); credentialStorage.delete(credential); } @@ -169,6 +173,20 @@ public class JdbcJaxRsOAuthStorage implements JaxRsOAuthStorage { return client; } + @Override + public OAuthClient getClientByClientUuid(Long uuid) { + OAuthClient client = null; + ClientStorage clientStorage = getClientStorage(); + ArtifactReadable artifact = clientStorage.getClientByClientUuid(uuid).getOneOrNull(); + if (artifact != null) { + Integer applicationId = artifact.getLocalId(); + + OAuthClientCredential credential = credentialStorage.getByApplicationId(applicationId); + client = clientStorage.newClient(artifact, credential); + } + return client; + } + @Override public OAuthClient getClientByClientKey(String clientKey) { OAuthClientCredential credential = credentialStorage.getByClientKey(clientKey); diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/OAuthTypes.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/OAuthTypes.java index 33384075171..88e30e83aca 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/OAuthTypes.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/OAuthTypes.java @@ -10,11 +10,11 @@ *******************************************************************************/ package org.eclipse.osee.orcs.account.admin.internal.oauth; -import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.IArtifactToken; import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.data.IAttributeType; import org.eclipse.osee.framework.core.data.TokenFactory; -import org.eclipse.osee.orcs.utility.OrcsUtil; +import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; /** * @author Roberto E. Escobar @@ -30,17 +30,17 @@ public final class OAuthTypes { public static final IAttributeType OAUTH_CLIENT_WEBSITE_URI = TokenFactory.createAttributeType(0x6C96C4E7AA77D058L, "Website URL"); public static final IAttributeType OAUTH_CLIENT_LOGO_URI = TokenFactory.createAttributeType(0x6CDB5B52A133AFB1L, "Logo URL"); - + public static final IAttributeType OAUTH_CLIENT_IS_CONFIDENTIAL = TokenFactory.createAttributeType(0x0774F815D1F9E731L, "Is Confidential"); public static final IAttributeType OAUTH_CLIENT_PROPERTIES = TokenFactory.createAttributeType(0x4E2EA052F480510AL, "Properties"); - + public static final IAttributeType OAUTH_CLIENT_AUTHORIZED_GRANT_TYPE = TokenFactory.createAttributeType(0x1ADA826121357000L, "Authorized Grant Type"); public static final IAttributeType OAUTH_CLIENT_AUTHORIZED_REDIRECT_URI = TokenFactory.createAttributeType(0x4B4665B8E1002F28L, "Authorized Redirect URI"); public static final IAttributeType OAUTH_CLIENT_AUTHORIZED_SCOPE = TokenFactory.createAttributeType(0x315964489A850F7AL, "Authorized Scope"); public static final IAttributeType OAUTH_CLIENT_AUTHORIZED_AUDIENCE = TokenFactory.createAttributeType(0x635EBFA0D4A82E22L, "Authorized Audience"); - // @formatter:on - public static final ArtifactId OAUTH_TYPES_ARTIFACT = - OrcsUtil.newArtifactId(77964317L, "AmgrOMuL6U7uL9hBWCAA", "OAuthTypes"); + public static final IArtifactToken OAUTH_TYPES = TokenFactory.createArtifactToken(7067755L, "OAuthTypes", CoreArtifactTypes.OseeTypeDefinition); + + // @formatter:on } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactImpl.java index 333cb515020..ce809a2fb8e 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactImpl.java @@ -11,7 +11,6 @@ package org.eclipse.osee.orcs.core.internal.artifact; import java.util.Collection; -import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.data.IAttributeType; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; @@ -220,15 +219,4 @@ public class ArtifactImpl extends AttributeManagerImpl implements Artifact { public Long getUuid() { return Long.valueOf(getLocalId()); } - - @Override - public String toStringWithId() { - return String.format("[%s][%s]", getName(), getUuid()); - } - - @Override - public ArtifactId getStoreObject() { - return this; - } - } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ArtifactReadOnlyImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ArtifactReadOnlyImpl.java index 6e7e906be4c..b36497be263 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ArtifactReadOnlyImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ArtifactReadOnlyImpl.java @@ -15,7 +15,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; import java.util.List; -import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.data.IAttributeType; import org.eclipse.osee.framework.core.data.IRelationType; @@ -39,7 +38,7 @@ import org.eclipse.osee.orcs.data.AttributeReadable; /** * @author Megumi Telles */ -public class ArtifactReadOnlyImpl extends AbstractProxiedimplements ArtifactReadable { +public class ArtifactReadOnlyImpl extends AbstractProxied implements ArtifactReadable { private final RelationManager relationManager; @@ -283,18 +282,4 @@ public class ArtifactReadOnlyImpl extends AbstractProxiedimplements Ar public Long getUuid() { return Long.valueOf(getLocalId()); } - - /* - * Provide easy way to display/report [name][uuid] - */ - @Override - public final String toStringWithId() { - return String.format("[%s][%s]", getName(), getUuid()); - } - - @Override - public ArtifactId getStoreObject() { - return this; - } - } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataLoaderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataLoaderImpl.java index f5e8d4808b3..9f3d2473121 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataLoaderImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataLoaderImpl.java @@ -55,11 +55,11 @@ public class TxDataLoaderImpl implements TxDataLoader { } private DataLoader createLoader(OrcsSession session, Long branchId, Collection artifactIds) throws OseeCoreException { - Set ids = new LinkedHashSet<>(); + Set ids = new LinkedHashSet<>(); for (ArtifactId artifactId : artifactIds) { - ids.add(artifactId.getGuid()); + ids.add(artifactId.getUuid().intValue()); } - DataLoader loader = dataLoaderFactory.newDataLoaderFromGuids(session, branchId, ids); + DataLoader loader = dataLoaderFactory.newDataLoaderFromIds(session, branchId, ids); loader.withLoadLevel(LoadLevel.ALL); loader.includeDeletedAttributes(); loader.includeDeletedRelations(); diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java index de8dffac9ea..d892c056ddc 100644 --- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java +++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java @@ -60,18 +60,18 @@ public class LoaderTest { public TestRule db = integrationRule(this); // @formatter:off -// @OsgiService private JdbcClient jdbcClient; - @OsgiService private OrcsDataStore dataStore; +// @OsgiService private JdbcClient jdbcClient; + @OsgiService private OrcsDataStore dataStore; @Mock private LoadDataHandler builder; @Captor private ArgumentCaptor descriptorCaptor; - @Captor private ArgumentCaptor artifactCaptor; - @Captor private ArgumentCaptor attributeCaptor; - @Captor private ArgumentCaptor relationCaptor; - @Mock private OrcsTypes types; - @Mock private ArtifactTypes artTypes; + @Captor private ArgumentCaptor artifactCaptor; + @Captor private ArgumentCaptor attributeCaptor; + @Captor private ArgumentCaptor relationCaptor; + @Mock private OrcsTypes types; + @Mock private ArtifactTypes artTypes; @Mock private OrcsSession session; - @Mock private AttributeTypes attrTypes; - // @formatter:on + @Mock private AttributeTypes attrTypes; + // @formatter:on private HasCancellation cancellation; private DataLoaderFactory loaderFactory; @@ -122,33 +122,33 @@ public class LoaderTest { Iterator arts = artifactCaptor.getAllValues().iterator(); // @formatter:off - verifyData(arts.next(), 5, "AkA10I4aUSDLuFNIaegA", NEW, OseeTypeDefinition.getGuid(), 570L,5, -1, 15L); - verifyData(arts.next(), 6, "AkA10LiAPEZLR4+jdFQA", NEW, OseeTypeDefinition.getGuid(), 570L,5, -1, 16L); - verifyData(arts.next(), 7, "AkA2AcT6AXe6ivMFRhAA", NEW, Folder.getGuid(), 570L,6, -1, 43L); - // @formatter:on + verifyData(arts.next(), 5, "AkA10I4aUSDLuFNIaegA", NEW, OseeTypeDefinition.getGuid(), 570L,5, -1, 15L); + verifyData(arts.next(), 6, "AkA10LiAPEZLR4+jdFQA", NEW, OseeTypeDefinition.getGuid(), 570L,5, -1, 16L); + verifyData(arts.next(), 7, "AkA2AcT6AXe6ivMFRhAA", NEW, Folder.getGuid(), 570L,6, -1, 43L); + // @formatter:on sort(attributeCaptor.getAllValues()); Iterator attrs = attributeCaptor.getAllValues().iterator(); // @formatter:off - verifyData(attrs.next(), 9, 5, NEW, Name.getGuid(), 570L,5, -1, 5L, "org.eclipse.osee.framework.skynet.core.OseeTypes_Framework", ""); - verifyData(attrs.next(), 10, 5, NEW, UriGeneralStringData.getGuid(), 570L,5, -1, 6L, "", "attr://6/AkA10I4aUSDLuFNIaegA.zip"); - verifyData(attrs.next(), 11, 5, NEW, Active.getGuid(), 570L,5, -1, 7L, "true", ""); + verifyData(attrs.next(), 9, 5, NEW, Name.getGuid(), 570L,5, -1, 5L, "org.eclipse.osee.framework.skynet.core.OseeTypes_Framework", ""); + verifyData(attrs.next(), 10, 5, NEW, UriGeneralStringData.getGuid(), 570L,5, -1, 6L, "", "attr://6/AkA10I4aUSDLuFNIaegA.zip"); + verifyData(attrs.next(), 11, 5, NEW, Active.getGuid(), 570L,5, -1, 7L, "true", ""); - verifyData(attrs.next(), 12, 6, NEW, Name.getGuid(), 570L,5, -1, 8L, "org.eclipse.osee.coverage.OseeTypes_Coverage", ""); - verifyData(attrs.next(), 13, 6, NEW, UriGeneralStringData.getGuid(), 570L,5, -1, 9L, "", "attr://9/AkA10LiAPEZLR4+jdFQA.zip"); - verifyData(attrs.next(), 14, 6, NEW, Active.getGuid(), 570L,5, -1, 10L, "true", ""); - verifyData(attrs.next(), 17, 7, NEW, Name.getGuid(), 570L,6, -1, 33L, "User Groups", ""); - // @formatter:on + verifyData(attrs.next(), 12, 6, NEW, Name.getGuid(), 570L,5, -1, 8L, "org.eclipse.osee.coverage.OseeTypes_Coverage", ""); + verifyData(attrs.next(), 13, 6, NEW, UriGeneralStringData.getGuid(), 570L,5, -1, 9L, "", "attr://9/AkA10LiAPEZLR4+jdFQA.zip"); + verifyData(attrs.next(), 14, 6, NEW, Active.getGuid(), 570L,5, -1, 10L, "true", ""); + verifyData(attrs.next(), 17, 7, NEW, Name.getGuid(), 570L,6, -1, 33L, "User Groups", ""); + // @formatter:on sort(relationCaptor.getAllValues()); Iterator rels = relationCaptor.getAllValues().iterator(); // @formatter:off - verifyData(rels.next(), 1, 7, 8, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 53L); - verifyData(rels.next(), 2, 1, 7, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 52L); - verifyData(rels.next(), 3, 7, 15, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 54L); - // @formatter:on + verifyData(rels.next(), 1, 7, 8, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 53L); + verifyData(rels.next(), 2, 1, 7, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 52L); + verifyData(rels.next(), 3, 7, 15, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 54L); + // @formatter:on } @org.junit.Test @@ -176,28 +176,28 @@ public class LoaderTest { Iterator arts = artifactCaptor.getAllValues().iterator(); // @formatter:off - verifyData(arts.next(), 5, "AkA10I4aUSDLuFNIaegA", NEW, OseeTypeDefinition.getGuid(), 570L,5, -1, 15L); - verifyData(arts.next(), 6, "AkA10LiAPEZLR4+jdFQA", NEW, OseeTypeDefinition.getGuid(), 570L,5, -1, 16L); - verifyData(arts.next(), 7, "AkA2AcT6AXe6ivMFRhAA", NEW, Folder.getGuid(), 570L,6, -1, 43L); - // @formatter:on + verifyData(arts.next(), 5, "AkA10I4aUSDLuFNIaegA", NEW, OseeTypeDefinition.getGuid(), 570L,5, -1, 15L); + verifyData(arts.next(), 6, "AkA10LiAPEZLR4+jdFQA", NEW, OseeTypeDefinition.getGuid(), 570L,5, -1, 16L); + verifyData(arts.next(), 7, "AkA2AcT6AXe6ivMFRhAA", NEW, Folder.getGuid(), 570L,6, -1, 43L); + // @formatter:on sort(attributeCaptor.getAllValues()); Iterator attrs = attributeCaptor.getAllValues().iterator(); // @formatter:off - verifyData(attrs.next(), 9, 5, NEW, Name.getGuid(), 570L,5, -1, 5L, "org.eclipse.osee.framework.skynet.core.OseeTypes_Framework", ""); - verifyData(attrs.next(), 12, 6, NEW, Name.getGuid(), 570L,5, -1, 8L, "org.eclipse.osee.coverage.OseeTypes_Coverage", ""); - verifyData(attrs.next(), 17, 7, NEW, Name.getGuid(), 570L,6, -1, 33L, "User Groups", ""); - // @formatter:on + verifyData(attrs.next(), 9, 5, NEW, Name.getGuid(), 570L,5, -1, 5L, "org.eclipse.osee.framework.skynet.core.OseeTypes_Framework", ""); + verifyData(attrs.next(), 12, 6, NEW, Name.getGuid(), 570L,5, -1, 8L, "org.eclipse.osee.coverage.OseeTypes_Coverage", ""); + verifyData(attrs.next(), 17, 7, NEW, Name.getGuid(), 570L,6, -1, 33L, "User Groups", ""); + // @formatter:on sort(relationCaptor.getAllValues()); Iterator rels = relationCaptor.getAllValues().iterator(); // @formatter:off - verifyData(rels.next(), 1, 7, 8, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 53L); - verifyData(rels.next(), 2, 1, 7, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 52L); - verifyData(rels.next(), 3, 7, 15, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 54L); - // @formatter:on + verifyData(rels.next(), 1, 7, 8, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 53L); + verifyData(rels.next(), 2, 1, 7, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 52L); + verifyData(rels.next(), 3, 7, 15, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 54L); + // @formatter:on } @org.junit.Test @@ -225,26 +225,26 @@ public class LoaderTest { Iterator arts = artifactCaptor.getAllValues().iterator(); // @formatter:off - verifyData(arts.next(), 5, "AkA10I4aUSDLuFNIaegA", NEW, OseeTypeDefinition.getGuid(), 570L,5, -1, 15L); - verifyData(arts.next(), 6, "AkA10LiAPEZLR4+jdFQA", NEW, OseeTypeDefinition.getGuid(), 570L,5, -1, 16L); - verifyData(arts.next(), 7, "AkA2AcT6AXe6ivMFRhAA", NEW, Folder.getGuid(), 570L,6, -1, 43L); - // @formatter:on + verifyData(arts.next(), 5, "AkA10I4aUSDLuFNIaegA", NEW, OseeTypeDefinition.getGuid(), 570L,5, -1, 15L); + verifyData(arts.next(), 6, "AkA10LiAPEZLR4+jdFQA", NEW, OseeTypeDefinition.getGuid(), 570L,5, -1, 16L); + verifyData(arts.next(), 7, "AkA2AcT6AXe6ivMFRhAA", NEW, Folder.getGuid(), 570L,6, -1, 43L); + // @formatter:on sort(attributeCaptor.getAllValues()); Iterator attrs = attributeCaptor.getAllValues().iterator(); // @formatter:off - verifyData(attrs.next(), 11, 5, NEW, Active.getGuid(), 570L,5, -1, 7L, "true", ""); - verifyData(attrs.next(), 14, 6, NEW, Active.getGuid(), 570L,5, -1, 10L, "true", ""); - // @formatter:on + verifyData(attrs.next(), 11, 5, NEW, Active.getGuid(), 570L,5, -1, 7L, "true", ""); + verifyData(attrs.next(), 14, 6, NEW, Active.getGuid(), 570L,5, -1, 10L, "true", ""); + // @formatter:on sort(relationCaptor.getAllValues()); Iterator rels = relationCaptor.getAllValues().iterator(); // @formatter:off - verifyData(rels.next(), 2, 1, 7, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 52L); - verifyData(rels.next(), 3, 7, 15, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 54L); - // @formatter:on + verifyData(rels.next(), 2, 1, 7, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 52L); + verifyData(rels.next(), 3, 7, 15, "", NEW, Default_Hierarchical__Parent.getGuid(), 570L,6, -1, 54L); + // @formatter:on } @org.junit.Test diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/utility/OrcsUtil.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/utility/OrcsUtil.java deleted file mode 100644 index d05ba587372..00000000000 --- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/utility/OrcsUtil.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * 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.orcs.utility; - -import org.eclipse.osee.framework.core.data.ArtifactId; -import org.eclipse.osee.framework.jdk.core.type.NamedIdentity; - -/** - * @author Angel Avila - */ -public final class OrcsUtil { - - private OrcsUtil() { - // Utility class - } - - public static ArtifactId newArtifactId(long uuid, String guid, String name) { - return new ArtifactToken(uuid, guid, name); - } - - public static ArtifactId newArtifactId(long uuid) { - return new ArtifactToken(uuid, null, null); - } - - private static class ArtifactToken extends NamedIdentityimplements ArtifactId { - private final long uuid; - - public ArtifactToken(long uuid, String guid, String name) { - super(guid, name); - this.uuid = uuid; - } - - @Override - public Long getUuid() { - return uuid; - } - - @Override - public String toStringWithId() { - return String.format("[%s][%s]", getName(), getUuid()); - } - - @Override - public ArtifactId getStoreObject() { - return this; - } - } - -} diff --git a/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/AccountClientTest.java b/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/AccountClientTest.java index bbfb6bb0874..43aeed08755 100644 --- a/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/AccountClientTest.java +++ b/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/AccountClientTest.java @@ -14,7 +14,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.commons.lang.math.RandomUtils; @@ -23,8 +22,6 @@ import org.eclipse.osee.account.rest.model.AccountDetailsData; import org.eclipse.osee.account.rest.model.AccountInfoData; import org.eclipse.osee.account.rest.model.AccountInput; import org.eclipse.osee.account.rest.model.AccountPreferencesData; -import org.eclipse.osee.account.rest.model.AccountSessionData; -import org.eclipse.osee.account.rest.model.AccountSessionDetailsData; import org.eclipse.osee.framework.jdk.core.type.ResultSet; import org.eclipse.osee.x.server.integration.tests.util.IntegrationUtil; import org.junit.Before; @@ -51,7 +48,7 @@ public class AccountClientTest { private String name; private String email; private boolean active; - private long accountId; + private Long accountId; private String guid; private Map prefs; @@ -94,45 +91,9 @@ public class AccountClientTest { } } - @Test - public void test_A_LogInOut() { - AccountSessionData session1 = client.login("none", email, "dummy"); - - assertEquals(accountId, session1.getAccountId()); - assertNotNull(session1.getToken()); - - AccountSessionDetailsData access = client.getAccountSessionDataByUniqueField(email).getExactlyOne(); - - assertEquals(accountId, access.getAccountId()); - assertNotNull(access.getAccessDetails()); - assertNotNull(access.getAccessedFrom()); - assertNotNull(access.getCreatedOn()); - assertNotNull(access.getLastAccessedOn()); - - AccountSessionData session2 = client.login("none", email, "dummy"); - assertEquals(accountId, session2.getAccountId()); - assertNotNull(session2.getToken()); - - assertEquals(false, session1.getToken().equals(session2.getToken())); - - ResultSet result = client.getAccountSessionDataByUniqueField(email); - assertEquals(2, result.size()); - Iterator iterator = result.iterator(); - AccountSessionDetailsData access1 = iterator.next(); - AccountSessionDetailsData access2 = iterator.next(); - assertEquals(accountId, access1.getAccountId()); - assertEquals(accountId, access2.getAccountId()); - - assertEquals(true, client.logout(session1)); - assertEquals(true, client.logout(session2)); - - ResultSet result2 = client.getAccountSessionDataByUniqueField(email); - assertEquals(true, result2.isEmpty()); - } - @Test public void test_B_GetAccountDetails() { - AccountDetailsData actual = client.getAccountDetailsByUniqueField(email); + AccountDetailsData actual = client.getAccountDetailsById(accountId); assertEquals(accountId, actual.getAccountId()); assertEquals(guid, actual.getGuid()); @@ -150,7 +111,7 @@ public class AccountClientTest { @Test public void test_D_GetAccountPreferences() { - AccountPreferencesData actual = client.getAccountPreferencesByUniqueField(email); + AccountPreferencesData actual = client.getAccountPreferencesById(accountId); assertEquals(accountId, actual.getId()); Map actualMap = actual.getMap(); @@ -162,22 +123,22 @@ public class AccountClientTest { @Test public void test_E_Active() { - boolean actual = client.isAccountActive(email); + boolean actual = client.isAccountActive(accountId); assertEquals(active, actual); - boolean modified = client.setAccountActive(email, active); + boolean modified = client.setAccountActive(accountId, active); assertEquals(false, modified); - modified = client.setAccountActive(email, !active); + modified = client.setAccountActive(accountId, !active); assertEquals(true, modified); - actual = client.isAccountActive(email); + actual = client.isAccountActive(accountId); assertEquals(!active, actual); - modified = client.setAccountActive(email, active); + modified = client.setAccountActive(accountId, active); assertEquals(true, modified); - actual = client.isAccountActive(email); + actual = client.isAccountActive(accountId); assertEquals(active, actual); } @@ -189,13 +150,13 @@ public class AccountClientTest { newPrefs.put("t", "9"); newPrefs.put("u", "10"); - boolean modified = client.setAccountPreferences(email, newPrefs); + boolean modified = client.setAccountPreferences(accountId, newPrefs); assertEquals(true, modified); - modified = client.setAccountPreferences(email, newPrefs); + modified = client.setAccountPreferences(accountId, newPrefs); assertEquals(false, modified); - AccountPreferencesData actual = client.getAccountPreferencesByUniqueField(email); + AccountPreferencesData actual = client.getAccountPreferencesById(accountId); assertEquals(accountId, actual.getId()); Map actualMap = actual.getMap(); @@ -210,10 +171,10 @@ public class AccountClientTest { public void test_G_DeleteAccount() { int beforeDelete = client.getAllAccounts().size(); - boolean modified = client.deleteAccount(email); + boolean modified = client.deleteAccount(accountId); assertEquals(true, modified); - modified = client.deleteAccount(email); + modified = client.deleteAccount(accountId); assertEquals(false, modified); int afterDelete = client.getAllAccounts().size(); -- cgit v1.2.3