diff options
author | jmisinco | 2015-01-13 16:48:57 +0000 |
---|---|---|
committer | Angel Avila | 2015-01-13 16:48:57 +0000 |
commit | 9c57c8d1cb6a1a07fa4f572a77cbc4a7a138425c (patch) | |
tree | 5d5cb17ddd57b829e693bee69b153cd498a90f02 /plugins/org.eclipse.osee.orcs.test | |
parent | 730936841161631edbbdaaaff60fe31354a2aee7 (diff) | |
download | org.eclipse.osee-9c57c8d1cb6a1a07fa4f572a77cbc4a7a138425c.tar.gz org.eclipse.osee-9c57c8d1cb6a1a07fa4f572a77cbc4a7a138425c.tar.xz org.eclipse.osee-9c57c8d1cb6a1a07fa4f572a77cbc4a7a138425c.zip |
bug[ats_ATS146966]: Allow relation checks on different txs
Change-Id: I1bc83ba921e31607dc87464ab09699b13882d4bc
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.test')
-rw-r--r-- | plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java index ed2c3d00d08..b2247e24301 100644 --- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java +++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java @@ -51,6 +51,7 @@ import org.eclipse.osee.orcs.transaction.TransactionFactory; import org.eclipse.osee.orcs.utility.MatchComparator; import org.eclipse.osee.orcs.utility.NameComparator; import org.eclipse.osee.orcs.utility.SortOrder; +import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -419,6 +420,59 @@ public class OrcsQueryTest { assertEquals("Robot collaboration", iterator.next()); } + @Test + public void testRelatedTo() { + // do a query on branch + ArtifactReadable robotApi = factory.fromBranch(TestBranches.SAW_Bld_2) // + .andNameEquals("Robot API") // + .andIsOfType(CoreArtifactTypes.SoftwareRequirement).getResults().getExactlyOne(); + + // create a tx on branch + ArtifactReadable author = + factory.fromBranch(CoreBranches.COMMON).andIds(SystemUser.OseeSystem).getResults().getExactlyOne(); + TransactionBuilder tx = txFactory.createTransaction(TestBranches.SAW_Bld_2, author, "Simple Tx"); + tx.createArtifact(CoreArtifactTypes.Folder, "Just a Folder"); + tx.commit(); + + // do another query on branch + ArtifactReadable robotInt = factory.fromBranch(TestBranches.SAW_Bld_2) // + .andNameEquals("Robot Interfaces").getResults().getExactlyOne(); + + // see if artifact from query 1 is related to artifact from query 2 + Assert.assertTrue(robotApi.areRelated(CoreRelationTypes.Default_Hierarchical__Child, robotInt)); + } + + @Test + public void testMultipleTxs() { + // do a query on branch + ArtifactReadable robotApi = factory.fromBranch(TestBranches.SAW_Bld_2) // + .andNameEquals("Robot API") // + .andIsOfType(CoreArtifactTypes.SoftwareRequirement).getResults().getExactlyOne(); + + ArtifactReadable author = + factory.fromBranch(CoreBranches.COMMON).andIds(SystemUser.OseeSystem).getResults().getExactlyOne(); + + // create a tx on branch + TransactionBuilder tx1 = txFactory.createTransaction(TestBranches.SAW_Bld_2, author, "Simple Tx1"); + TransactionBuilder tx2 = txFactory.createTransaction(TestBranches.SAW_Bld_2, author, "Simple Tx2"); + + ArtifactId folder = tx1.createArtifact(CoreArtifactTypes.Folder, "Just a Folder"); + tx1.commit(); + + tx2.addChildren(robotApi, folder); + + tx2.commit(); + + // do another query on branch + ArtifactReadable robotInt = factory.fromBranch(TestBranches.SAW_Bld_2) // + .andNameEquals("Robot Interfaces").getResults().getExactlyOne(); + + ArtifactReadable folderArt = factory.fromBranch(TestBranches.SAW_Bld_2) // + .andIds(folder).getResults().getExactlyOne(); + // robotApi should be related to folder + Assert.assertTrue(robotApi.areRelated(CoreRelationTypes.Default_Hierarchical__Child, folderArt)); + } + private Set<String> getNames(ResultSet<ArtifactReadable> results) { Set<String> names = new TreeSet<String>(); for (ArtifactReadable art : results) { |