Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorddunne2010-10-06 17:04:41 +0000
committerRyan D. Brooks2010-10-06 17:04:41 +0000
commitd3023d85db18e429e881c5180daba0043dd02973 (patch)
tree94d519a6f58b7b102b1d33f7843af7d5ce2301ea /plugins/org.eclipse.osee.framework.skynet.core.test
parent710024f31226a9ccdd414514d66c939f5d3a9940 (diff)
downloadorg.eclipse.osee-d3023d85db18e429e881c5180daba0043dd02973.tar.gz
org.eclipse.osee-d3023d85db18e429e881c5180daba0043dd02973.tar.xz
org.eclipse.osee-d3023d85db18e429e881c5180daba0043dd02973.zip
feature: Add simple cross branch linking through attribute
Diffstat (limited to 'plugins/org.eclipse.osee.framework.skynet.core.test')
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/FrameworkCore_Demo_Suite.java2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/relation/CrossBranchLinkTest.java141
2 files changed, 143 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/FrameworkCore_Demo_Suite.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/FrameworkCore_Demo_Suite.java
index 151317b6a3..9fe5689b59 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/FrameworkCore_Demo_Suite.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/FrameworkCore_Demo_Suite.java
@@ -43,6 +43,7 @@ import org.eclipse.osee.framework.skynet.core.test.event.TransactionEventLoopbac
import org.eclipse.osee.framework.skynet.core.test.event.TransactionEventTest;
import org.eclipse.osee.framework.skynet.core.test.importing.ImportingSuite;
import org.eclipse.osee.framework.skynet.core.test.importing.parsers.ParsersSuite;
+import org.eclipse.osee.framework.skynet.core.test.relation.CrossBranchLinkTest;
import org.eclipse.osee.framework.skynet.core.test.relation.RelationTestSuite;
import org.eclipse.osee.framework.skynet.core.test.word.UpdateBookmarkIdTest;
import org.junit.BeforeClass;
@@ -51,6 +52,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
+ CrossBranchLinkTest.class,
UpdateBookmarkIdTest.class,
ArtifactEventFiltersTest.class,
BranchEventFiltersTest.class,
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/relation/CrossBranchLinkTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/relation/CrossBranchLinkTest.java
new file mode 100644
index 0000000000..0f2c70125e
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/relation/CrossBranchLinkTest.java
@@ -0,0 +1,141 @@
+/*
+ * Created on Oct 5, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.skynet.core.test.relation;
+
+import static org.eclipse.osee.framework.core.enums.DeletionFlag.EXCLUDE_DELETED;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
+import org.eclipse.osee.framework.skynet.core.artifact.PurgeArtifacts;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.relation.crossbranch.CrossBranchLink;
+import org.eclipse.osee.framework.skynet.core.relation.crossbranch.CrossBranchLinkManager;
+import org.eclipse.osee.support.test.util.DemoSawBuilds;
+import org.eclipse.osee.support.test.util.TestUtil;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CrossBranchLinkTest {
+
+ public static Artifact folderArt;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ tearDown();
+ folderArt =
+ ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, BranchManager.getCommonBranch(),
+ CrossBranchLinkTest.class.getSimpleName());
+ folderArt.persist("CrossBranchLinkTest");
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ List<Artifact> artifacts = new ArrayList<Artifact>();
+ artifacts.addAll(ArtifactQuery.getArtifactListFromName(CrossBranchLinkTest.class.getSimpleName() + "%",
+ BranchManager.getCommonBranch(), EXCLUDE_DELETED));
+ artifacts.addAll(ArtifactQuery.getArtifactListFromName(CrossBranchLinkTest.class.getSimpleName() + "%",
+ BranchManager.getBranchByGuid(DemoSawBuilds.SAW_Bld_1.getGuid()), EXCLUDE_DELETED));
+ new PurgeArtifacts(artifacts).execute();
+ TestUtil.sleep(4000);
+ }
+
+ @Test
+ public void testCrossBranchLink() throws OseeCoreException {
+ Branch sawBranch = BranchManager.getBranchByGuid(DemoSawBuilds.SAW_Bld_1.getGuid());
+ Assert.assertNotNull(sawBranch);
+
+ Artifact artifact1 =
+ ArtifactTypeManager.addArtifact(CoreArtifactTypes.GeneralDocument, sawBranch,
+ getClass().getSimpleName() + "-1");
+ artifact1.addAttribute(CoreAttributeTypes.StaticId, CrossBranchLinkTest.class.getSimpleName());
+ artifact1.persist();
+
+ // test equals
+ CrossBranchLink linkA = new CrossBranchLink(CoreRelationTypes.SupportingInfo_SupportingInfo, artifact1);
+ CrossBranchLink linkB = new CrossBranchLink(CoreRelationTypes.SupportingInfo_SupportingInfo, artifact1);
+ Assert.assertTrue(linkA.equals(linkB));
+ linkB = new CrossBranchLink(CoreRelationTypes.SupportingInfo_SupportedBy, artifact1);
+ Assert.assertFalse(linkA.equals(linkB));
+
+ // test addRelation
+ CrossBranchLinkManager.addRelation(folderArt, CoreRelationTypes.SupportingInfo_SupportingInfo, artifact1);
+
+ Collection<CrossBranchLink> links = CrossBranchLinkManager.getLinks(folderArt);
+ Assert.assertEquals(1, links.size());
+ CrossBranchLink link = links.iterator().next();
+ Assert.assertEquals(CoreRelationTypes.SupportingInfo_SupportingInfo, link.getRelationEnum());
+ Assert.assertEquals(artifact1, link.getArtifact());
+
+ Artifact artifact2 =
+ ArtifactTypeManager.addArtifact(CoreArtifactTypes.GeneralDocument, sawBranch,
+ getClass().getSimpleName() + "-2");
+ artifact2.addAttribute(CoreAttributeTypes.StaticId, CrossBranchLinkTest.class.getSimpleName());
+ artifact2.persist();
+
+ CrossBranchLinkManager.addRelation(folderArt, CoreRelationTypes.SupportingInfo_SupportingInfo, artifact2);
+
+ Artifact artifact3 =
+ ArtifactTypeManager.addArtifact(CoreArtifactTypes.GeneralDocument, sawBranch,
+ getClass().getSimpleName() + "-3");
+ artifact3.addAttribute(CoreAttributeTypes.StaticId, CrossBranchLinkTest.class.getSimpleName());
+ artifact3.persist();
+
+ CrossBranchLinkManager.addRelation(folderArt, CoreRelationTypes.Supercedes_Supercedes, artifact3);
+
+ // test getLinks
+ links = CrossBranchLinkManager.getLinks(folderArt);
+ Assert.assertEquals(3, links.size());
+
+ boolean found1 = false, found2 = false, found3 = false;
+ for (CrossBranchLink linkItem : links) {
+ if (linkItem.getArtifact().equals(artifact1)) {
+ Assert.assertEquals(CoreRelationTypes.SupportingInfo_SupportingInfo, linkItem.getRelationEnum());
+ found1 = true;
+ } else if (linkItem.getArtifact().equals(artifact2)) {
+ Assert.assertEquals(CoreRelationTypes.SupportingInfo_SupportingInfo, linkItem.getRelationEnum());
+ found2 = true;
+ } else if (linkItem.getArtifact().equals(artifact3)) {
+ Assert.assertEquals(CoreRelationTypes.Supercedes_Supercedes, linkItem.getRelationEnum());
+ found3 = true;
+ }
+ }
+ Assert.assertTrue(found1);
+ Assert.assertTrue(found2);
+ Assert.assertTrue(found3);
+
+ // test getRelatedArtifactCount
+ Assert.assertEquals(2,
+ CrossBranchLinkManager.getRelatedArtifactCount(folderArt, CoreRelationTypes.SupportingInfo_SupportingInfo));
+ Assert.assertEquals(0,
+ CrossBranchLinkManager.getRelatedArtifactCount(folderArt, CoreRelationTypes.SupportingInfo_SupportedBy));
+ Assert.assertEquals(1,
+ CrossBranchLinkManager.getRelatedArtifactCount(folderArt, CoreRelationTypes.Supercedes_Supercedes));
+
+ // test deleteRelation
+ CrossBranchLinkManager.deleteRelation(folderArt, CoreRelationTypes.SupportingInfo_SupportingInfo, artifact1);
+ Assert.assertEquals(1,
+ CrossBranchLinkManager.getRelatedArtifactCount(folderArt, CoreRelationTypes.SupportingInfo_SupportingInfo));
+
+ // test deleteRelations
+ CrossBranchLinkManager.addRelation(folderArt, CoreRelationTypes.SupportingInfo_SupportingInfo, artifact1);
+ Assert.assertEquals(2,
+ CrossBranchLinkManager.getRelatedArtifactCount(folderArt, CoreRelationTypes.SupportingInfo_SupportingInfo));
+ CrossBranchLinkManager.deleteRelations(folderArt, CoreRelationTypes.SupportingInfo_SupportingInfo);
+ Assert.assertEquals(0,
+ CrossBranchLinkManager.getRelatedArtifactCount(folderArt, CoreRelationTypes.SupportingInfo_SupportingInfo));
+ }
+
+}

Back to the top