Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2012-10-30 01:36:02 +0000
committerRoberto E. Escobar2012-10-30 01:36:02 +0000
commit388011345853a7785561798ae6f743d8e2f3293d (patch)
tree0b6d5747b7d543e249efad543d5020c3fdd41d4f
parentc3673da8ce6273eb23f933f7f41da609e626d4fa (diff)
downloadorg.eclipse.osee-388011345853a7785561798ae6f743d8e2f3293d.tar.gz
org.eclipse.osee-388011345853a7785561798ae6f743d8e2f3293d.tar.xz
org.eclipse.osee-388011345853a7785561798ae6f743d8e2f3293d.zip
refactor: Separate query tests from single method
-rw-r--r--plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsAttributeSearchTest.java30
-rw-r--r--plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java42
2 files changed, 37 insertions, 35 deletions
diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsAttributeSearchTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsAttributeSearchTest.java
index 2ee3312715f..8475da692d9 100644
--- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsAttributeSearchTest.java
+++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsAttributeSearchTest.java
@@ -31,7 +31,9 @@ import org.eclipse.osee.orcs.search.Operator;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
import org.eclipse.osee.orcs.search.StringOperator;
+import org.junit.Before;
import org.junit.Rule;
+import org.junit.Test;
/**
* @author Jeff C. Phillips
@@ -47,18 +49,16 @@ public class OrcsAttributeSearchTest {
@OsgiService
private OrcsApi orcsApi;
- @org.junit.Test
- public void runGodMethod() throws OseeCoreException {
- ApplicationContext context = null; // TODO use real application context
- QueryFactory queryFactory = orcsApi.getQueryFactory(context);
+ private QueryFactory queryFactory;
- testNameAttributeNotEqualSearch(queryFactory);
- testNameAttributeEqualSearch(queryFactory);
- testBooleanAttributeSearch(queryFactory);
- testWTCAttributeEqualSearch(queryFactory, orcsApi.getBranchCache());
+ @Before
+ public void setup() {
+ ApplicationContext context = null; // TODO use real application context
+ queryFactory = orcsApi.getQueryFactory(context);
}
- public void testNameAttributeNotEqualSearch(QueryFactory queryFactory) throws OseeCoreException {
+ @Test
+ public void testNameAttributeNotEqualSearch() throws OseeCoreException {
QueryBuilder builder =
queryFactory.fromBranch(CoreBranches.COMMON).and(CoreAttributeTypes.Name, Operator.NOT_EQUAL, "User Groups");
@@ -70,7 +70,8 @@ public class OrcsAttributeSearchTest {
}
}
- public void testNameAttributeEqualSearch(QueryFactory queryFactory) throws OseeCoreException {
+ @Test
+ public void testNameAttributeEqualSearch() throws OseeCoreException {
QueryBuilder builder =
queryFactory.fromBranch(CoreBranches.COMMON).and(CoreAttributeTypes.Name, Operator.EQUAL, "User Groups");
@@ -87,7 +88,9 @@ public class OrcsAttributeSearchTest {
Assert.assertEquals(art8.getSoleAttributeAsString(CoreAttributeTypes.Name), "User Groups");
}
- public void testWTCAttributeEqualSearch(QueryFactory queryFactory, BranchCache branchCache) throws OseeCoreException {
+ @Test
+ public void testWTCAttributeEqualSearch() throws OseeCoreException {
+ BranchCache branchCache = orcsApi.getBranchCache();
Branch branch = branchCache.getBySoleName("SAW_Bld_1");
QueryBuilder builder =
queryFactory.fromBranch(branch).and(CoreAttributeTypes.WordTemplateContent,
@@ -101,7 +104,8 @@ public class OrcsAttributeSearchTest {
Assert.assertEquals(3, builder.getCount());
}
- public void testBooleanAttributeSearch(QueryFactory queryFactory) throws OseeCoreException {
+ @Test
+ public void testBooleanAttributeSearch() throws OseeCoreException {
QueryBuilder builder =
queryFactory.fromBranch(CoreBranches.COMMON).and(CoreAttributeTypes.DefaultGroup, Operator.EQUAL, "yes");
ResultSet<ArtifactReadable> resultSet = builder.getResults();
@@ -115,7 +119,7 @@ public class OrcsAttributeSearchTest {
Assert.assertEquals(art9.getSoleAttributeAsString(CoreAttributeTypes.Name), "Everyone");
}
- Map<Integer, ArtifactReadable> creatLookup(List<ArtifactReadable> arts) {
+ private Map<Integer, ArtifactReadable> creatLookup(List<ArtifactReadable> arts) {
Map<Integer, ArtifactReadable> lookup = new HashMap<Integer, ArtifactReadable>();
for (ArtifactReadable artifact : arts) {
lookup.put(artifact.getLocalId(), artifact);
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 52ab46614d5..07f05deedd5 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
@@ -39,6 +39,7 @@ import org.eclipse.osee.orcs.search.StringOperator;
import org.eclipse.osee.orcs.utility.MatchComparator;
import org.eclipse.osee.orcs.utility.NameComparator;
import org.eclipse.osee.orcs.utility.SortOrder;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -58,24 +59,16 @@ public class OrcsQueryTest {
@OsgiService
private OrcsApi orcsApi;
- @Test
- public void testQueries() throws OseeCoreException {
- ApplicationContext context = null; // TODO use real application context
- QueryFactory factory = orcsApi.getQueryFactory(context);
-
- checkQueryByIds(factory);
-
- checkQueryArtifactType(factory);
- checkQueryArtifactTypeInheritance(factory);
- checkQueryArtifactTypesNoInheritance(factory);
+ private QueryFactory factory;
- checkQueryAttributeValue(factory);
- checkQueryArtifactTypeAndNameValue(factory);
-
- checkQueryAttributeKeyword(factory);
+ @Before
+ public void setup() {
+ ApplicationContext context = null; // TODO use real application context
+ factory = orcsApi.getQueryFactory(context);
}
- private void checkQueryByIds(QueryFactory factory) throws OseeCoreException {
+ @Test
+ public void testQueryByIds() throws OseeCoreException {
QueryBuilder builder = factory.fromBranch(CoreBranches.COMMON).andGuidsOrHrids("AEmLGXnw0WaGLxcK5qwA");
Assert.assertEquals(1, builder.getCount());
@@ -83,7 +76,8 @@ public class OrcsQueryTest {
Assert.assertEquals("AEmLGXnw0WaGLxcK5qwA", artifact.getGuid());
}
- private void checkQueryArtifactType(QueryFactory factory) throws OseeCoreException {
+ @Test
+ public void testQueryArtifactType() throws OseeCoreException {
QueryBuilder builder = factory.fromBranch(CoreBranches.COMMON).andIsOfType(CoreArtifactTypes.Folder);
Assert.assertEquals(5, builder.getCount());
@@ -115,7 +109,8 @@ public class OrcsQueryTest {
}
}
- private void checkQueryArtifactTypeInheritance(QueryFactory factory) throws OseeCoreException {
+ @Test
+ public void testQueryArtifactTypeInheritance() throws OseeCoreException {
QueryBuilder builder =
factory.fromBranch(TestBranches.SAW_Bld_1).andIsOfType(CoreArtifactTypes.AbstractSoftwareRequirement);//
@@ -134,7 +129,8 @@ public class OrcsQueryTest {
checkContainsTypes(artifacts, CoreArtifactTypes.SoftwareRequirement);
}
- private void checkQueryArtifactTypesNoInheritance(QueryFactory factory) throws OseeCoreException {
+ @Test
+ public void testQueryArtifactTypesNoInheritance() throws OseeCoreException {
QueryBuilder builder = factory.fromBranch(CoreBranches.COMMON);
builder.excludeTypeInheritance();
builder.andIsOfType(CoreArtifactTypes.OseeTypeDefinition, CoreArtifactTypes.Folder);
@@ -162,7 +158,8 @@ public class OrcsQueryTest {
Assert.assertEquals("org.eclipse.osee.ote.define.OseeTypesOTE", iterator.next().getName());
}
- private void checkQueryAttributeValue(QueryFactory factory) throws OseeCoreException {
+ @Test
+ public void testQueryAttributeValue() throws OseeCoreException {
QueryBuilder builder = factory.fromBranch(CoreBranches.COMMON);
builder.and(CoreAttributeTypes.Name, Operator.EQUAL, "Action Tracking System");
@@ -189,8 +186,8 @@ public class OrcsQueryTest {
}
}
- private void checkQueryArtifactTypeAndNameValue(QueryFactory factory) throws OseeCoreException {
- //////////////////////
+ @Test
+ public void testQueryArtifactTypeAndNameValue() throws OseeCoreException {
QueryBuilder builder = factory.fromBranch(TestBranches.SAW_Bld_1);
builder.and(CoreAttributeTypes.Name, Operator.EQUAL, "%Requirement%");
@@ -240,7 +237,8 @@ public class OrcsQueryTest {
checkContainsTypes(subSystemReqs, CoreArtifactTypes.SubsystemRequirement, CoreArtifactTypes.SystemRequirement);
}
- private void checkQueryAttributeKeyword(QueryFactory factory) throws OseeCoreException {
+ @Test
+ public void testQueryAttributeKeyword() throws OseeCoreException {
QueryBuilder builder = factory.fromBranch(TestBranches.SAW_Bld_1);
builder.and(CoreAttributeTypes.Name, StringOperator.TOKENIZED_ANY_ORDER, CaseType.IGNORE_CASE, "REQUIREMENTS");

Back to the top