Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngel Avila2016-03-02 09:58:11 +0000
committerRyan D. Brooks2016-03-02 09:58:11 +0000
commit640a48c2684153ac0cd054a785cbe136ade0dbab (patch)
tree876d7aea8dc9ec9e4bfbe4f28d39cf01415de563 /plugins/org.eclipse.osee.orcs.account.admin.test
parentb4a6440a00ba4adfe1bb26e7c35b1b59a2f31810 (diff)
downloadorg.eclipse.osee-640a48c2684153ac0cd054a785cbe136ade0dbab.tar.gz
org.eclipse.osee-640a48c2684153ac0cd054a785cbe136ade0dbab.tar.xz
org.eclipse.osee-640a48c2684153ac0cd054a785cbe136ade0dbab.zip
refactor[ats_ATS253925]: Change ids in Account from int to Long
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.account.admin.test')
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/JdbcJaxRsOAuthStorageTest.java97
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsAccountStorageTest.java96
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsSubscriptionStorageTest.java55
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/internal/SubscriptionUtilTest.java11
4 files changed, 123 insertions, 136 deletions
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<String> 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<String, String> prefs;
- private Identifiable<String> 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<Account> result = storage.getAccountByGuid(newAccount.getGuid());
+ ResultSet<Account> 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<Account> result = storage.getAccountByGuid(newAccount.getGuid());
- Account account1 = result.getExactlyOne();
- assertAccount(account1, newAccount.getGuid(), name, email, username, active, prefs);
-
- ResultSet<Account> result2 = storage.getAccountByLocalId(account1.getId());
+ ArtifactId artId = TokenFactory.createArtifactId(account1.getId());
+ ResultSet<Account> 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<Account> 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<Account> result = storage.getAccountByEmail(email);
Account account = result.getExactlyOne();
- assertAccount(account, newAccount.getGuid(), name, email, username, active, prefs);
- }
-
- @Test
- public void testGetByUserName() {
- ResultSet<Account> 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<Account> result = storage.getAccountByGuid(newAccount.getGuid());
+ ResultSet<Account> 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<String, String> prefs) {
+ private static void assertPrefs(AccountPreferences expected, ArtifactId artId, Long accountId, Map<String, String> prefs) {
assertEquals(accountId, expected.getId());
- assertPrefs(expected, uuid, prefs);
+ assertPrefs(expected, artId, prefs);
}
- private static void assertPrefs(AccountPreferences expected, String uuid, Map<String, String> prefs) {
+ private static void assertPrefs(AccountPreferences expected, ArtifactId artId, Map<String, String> prefs) {
assertTrue(expected.getId() > 0L);
- assertEquals(uuid, expected.getGuid());
+ assertEquals(artId.getUuid(), expected.getId());
Map<String, String> 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<String, String> prefs) {
+ private static void assertAccount(Account account, ArtifactId artId, String name, String email, String username, boolean isActive, Map<String, String> 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<String, String> prefs;
- private Identifiable<String> 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<Subscription> results = storage.getSubscriptionsByAccountLocalId(accountId);
+ ResultSet<Subscription> 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<Account> members = storage.getSubscriptionGroupMembersByLocalId(group.getId());
+ ResultSet<Account> 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);

Back to the top