diff options
author | donald.g.dunne | 2013-05-20 13:35:19 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2013-07-08 18:22:01 +0000 |
commit | 0ec5da5e58d84e50dabf04e13fa80195bb15e5aa (patch) | |
tree | bac624342f8a5e36ebe7b638405da8597f5b1ed0 /plugins/org.eclipse.osee.ats.client.integration.tests/src | |
parent | 21ef10c199d750d603937199b41ee766c70fdc6c (diff) | |
download | org.eclipse.osee-0ec5da5e58d84e50dabf04e13fa80195bb15e5aa.tar.gz org.eclipse.osee-0ec5da5e58d84e50dabf04e13fa80195bb15e5aa.tar.xz org.eclipse.osee-0ec5da5e58d84e50dabf04e13fa80195bb15e5aa.zip |
bug[ats_BNRF6]: "Subscribe by Team Definition" does not persist
Change-Id: I9e52120b19b2793a0f8ff489ebb3368c9b40891d
Diffstat (limited to 'plugins/org.eclipse.osee.ats.client.integration.tests/src')
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 564d82ba6a3..22178819efa 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 00000000000..7110b1211dc --- /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()); + } + +} |