Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.ats.client.integration.tests')
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/navigate/AtsTest_Navigate_Suite.java1
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/navigate/SubscribeUtilityTest.java87
2 files changed, 88 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/navigate/AtsTest_Navigate_Suite.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/navigate/AtsTest_Navigate_Suite.java
index 564d82ba6a..22178819ef 100644
--- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/navigate/AtsTest_Navigate_Suite.java
+++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/navigate/AtsTest_Navigate_Suite.java
@@ -22,6 +22,7 @@ import org.junit.runners.Suite;
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
+ SubscribeUtilityTest.class,
AtsNavigateItemsToMassEditorTest.class,
AtsNavigateItemsToTaskEditorTest.class,
AtsNavigateItemsToWorldViewTest.class})
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/navigate/SubscribeUtilityTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/navigate/SubscribeUtilityTest.java
new file mode 100644
index 0000000000..7110b1211d
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/navigate/SubscribeUtilityTest.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.ats.client.integration.tests.ats.navigate;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
+import org.eclipse.osee.ats.client.demo.DemoArtifactToken;
+import org.eclipse.osee.ats.client.demo.DemoUsers;
+import org.eclipse.osee.ats.navigate.SubscribeUtility;
+import org.eclipse.osee.ats.util.AtsUtil;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test case for {@link SubscribeUtility}
+ *
+ * @author Donald G. Dunne
+ */
+public class SubscribeUtilityTest {
+
+ @BeforeClass
+ @AfterClass
+ public static void cleanup() throws OseeCoreException {
+ Artifact userArt = getAlexUserArtifact();
+ userArt.deleteRelations(CoreRelationTypes.Users_Artifact);
+ userArt.persist(SubscribeUtilityTest.class.getSimpleName() + " - cleanup");
+ }
+
+ @Test
+ public void test() throws OseeCoreException {
+ Artifact alexUserArt = getAlexUserArtifact();
+ Assert.assertEquals("Should be nothing subscribed by alex", 0,
+ alexUserArt.getRelatedArtifactsCount(CoreRelationTypes.Users_Artifact));
+
+ // Subscribe to 2 team definitions
+ Artifact cisCodeTeam =
+ ArtifactQuery.getArtifactFromToken(DemoArtifactToken.CIS_Code, AtsUtil.getAtsBranchToken());
+ Artifact cisSwTeam = ArtifactQuery.getArtifactFromToken(DemoArtifactToken.CIS_SW, AtsUtil.getAtsBranchToken());
+
+ SubscribeUtility.setSubcriptionsAndPersist(alexUserArt, CoreRelationTypes.Users_Artifact,
+ Arrays.asList(cisCodeTeam, cisSwTeam), AtsArtifactTypes.TeamDefinition, getClass().getSimpleName());
+ List<Artifact> subscribed = alexUserArt.getRelatedArtifacts(CoreRelationTypes.Users_Artifact);
+ Assert.assertTrue("CIS Code should be subscribed", subscribed.contains(cisCodeTeam));
+ Assert.assertTrue("CIS SW should be subscribed", subscribed.contains(cisSwTeam));
+ Assert.assertFalse("User artifact changes should be persisted", alexUserArt.isDirty());
+
+ // Remove one, add another
+ Artifact cisTestTeam =
+ ArtifactQuery.getArtifactFromToken(DemoArtifactToken.CIS_Test, AtsUtil.getAtsBranchToken());
+
+ SubscribeUtility.setSubcriptionsAndPersist(alexUserArt, CoreRelationTypes.Users_Artifact,
+ Arrays.asList(cisCodeTeam, cisTestTeam), AtsArtifactTypes.TeamDefinition, getClass().getSimpleName());
+ subscribed = alexUserArt.getRelatedArtifacts(CoreRelationTypes.Users_Artifact);
+ Assert.assertTrue("CIS Code should be subscribed", subscribed.contains(cisCodeTeam));
+ Assert.assertFalse("CIS SW should NOT be subscribed", subscribed.contains(cisSwTeam));
+ Assert.assertTrue("CIS Test should be subscribed", subscribed.contains(cisTestTeam));
+ Assert.assertFalse("User artifact changes should be persisted", alexUserArt.isDirty());
+
+ // Un-subscribe all
+ SubscribeUtility.setSubcriptionsAndPersist(alexUserArt, CoreRelationTypes.Users_Artifact,
+ new ArrayList<Artifact>(), AtsArtifactTypes.TeamDefinition, getClass().getSimpleName());
+ subscribed = alexUserArt.getRelatedArtifacts(CoreRelationTypes.Users_Artifact);
+ Assert.assertTrue("No subscriptions remain", subscribed.isEmpty());
+ Assert.assertFalse("User artifact changes should be persisted", alexUserArt.isDirty());
+ }
+
+ private static Artifact getAlexUserArtifact() throws OseeCoreException {
+ return ArtifactQuery.getArtifactFromToken(DemoUsers.Alex_Kay, AtsUtil.getAtsBranchToken());
+ }
+
+}

Back to the top