Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2014-08-04 21:44:34 +0000
committerRoberto E. Escobar2014-09-29 22:55:05 +0000
commit118d50b87fab3db2615d2f23a5d9b7ff8642ecfc (patch)
tree89b10f5c9d507e063f3319410fd312ef8010ef34 /plugins/org.eclipse.osee.orcs.rest.test
parentdcb326ebb42d136dfcf2e550f2323dcfad7979ca (diff)
downloadorg.eclipse.osee-118d50b87fab3db2615d2f23a5d9b7ff8642ecfc.tar.gz
org.eclipse.osee-118d50b87fab3db2615d2f23a5d9b7ff8642ecfc.tar.xz
org.eclipse.osee-118d50b87fab3db2615d2f23a5d9b7ff8642ecfc.zip
refactor[ats_ATS56804]: Simplify artifact searching options
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.rest.test')
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/InternalTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImplTest.java180
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandlerTest.java52
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java43
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/GuidsPredicateHandlerTest.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IdsPredicateHandlerTest.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandlerTest.java12
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandlerTest.java14
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/TypeEqualsPredicateHandlerTest.java8
10 files changed, 40 insertions, 299 deletions
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/InternalTestSuite.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/InternalTestSuite.java
index fc4d951fb0f..4f6eeb91f0b 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/InternalTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/InternalTestSuite.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.internal;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.DslTranslatorImplTest;
import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchDslTest;
import org.eclipse.osee.orcs.rest.internal.search.predicate.AttributeTypePredicateHandlerTest;
import org.eclipse.osee.orcs.rest.internal.search.predicate.ExistsTypePredicateHandlerTest;
@@ -26,7 +25,6 @@ import org.junit.runners.Suite;
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
- DslTranslatorImplTest.class,
SearchDslTest.class,
AttributeTypePredicateHandlerTest.class,
ExistsTypePredicateHandlerTest.class,
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImplTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImplTest.java
deleted file mode 100644
index 74662c39881..00000000000
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImplTest.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.orcs.rest.internal.search.dsl;
-
-import java.util.List;
-import java.util.Random;
-import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
-import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.orcs.rest.internal.search.artifact.dsl.DslTranslatorImpl_V1;
-import org.eclipse.osee.orcs.rest.model.search.artifact.Predicate;
-import org.eclipse.osee.orcs.rest.model.search.artifact.SearchFlag;
-import org.eclipse.osee.orcs.rest.model.search.artifact.SearchMethod;
-import org.eclipse.osee.orcs.rest.model.search.artifact.SearchOp;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * @author John R. Misinco
- */
-public class DslTranslatorImplTest {
-
- @Test(expected = OseeArgumentException.class)
- public void testBadSearchType() throws OseeCoreException {
- DslTranslatorImpl_V1 translator = new DslTranslatorImpl_V1();
-
- //test bad search type
- String test = "[t:attrTypes&tp:1000000000000070&op:==&v:AtsAdmin]";
- translator.translate(test);
- }
-
- @Test(expected = OseeArgumentException.class)
- public void testBadOp() throws OseeCoreException {
- DslTranslatorImpl_V1 translator = new DslTranslatorImpl_V1();
-
- //test bad op
- String test = "[t:attrType&tp:1000000000000070&op:<=&v:AtsAdmin]";
- translator.translate(test);
- }
-
- @Test(expected = OseeArgumentException.class)
- public void testBadFlag() throws OseeCoreException {
- DslTranslatorImpl_V1 translator = new DslTranslatorImpl_V1();
-
- //test bad flags
- String test = "[t:attrType&tp:1000000000000070&op:==&f:ti&v:AtsAdmin]";
- translator.translate(test);
- }
-
- private int getNextInt(Random r) {
- return Math.abs(r.nextInt());
- }
-
- private String getSearchMethod(Random r) {
- int len = SearchMethod.values().length;
- return SearchMethod.values()[getNextInt(r) % len].getToken();
- }
-
- private String getOp(Random r) {
- int len = SearchOp.values().length;
- return SearchOp.values()[getNextInt(r) % len].getToken();
- }
-
- private String getFlags(Random r, int num) {
- if (num == 0) {
- return "";
- }
- StringBuilder toReturn = new StringBuilder();
- for (int i = 0; i < num; i++) {
- int len = SearchFlag.values().length;
- toReturn.append(SearchFlag.values()[getNextInt(r) % len].getToken());
- toReturn.append(",");
- }
- int last = toReturn.length();
- return toReturn.substring(0, last - 1);
- }
-
- private String getTestQuery(int num) {
- Random r = new Random();
- StringBuilder toReturn = new StringBuilder();
- for (int i = 0; i < num; i++) {
- toReturn.append("[t:");
- toReturn.append(getSearchMethod(r));
- toReturn.append("&tp:");
- toReturn.append(r.nextLong());
- toReturn.append("&op:");
- toReturn.append(getOp(r));
- toReturn.append("&f:");
- toReturn.append(getFlags(r, getNextInt(r) % 3));
- toReturn.append("&v:value1,value2]&");
- }
- int last = toReturn.length();
- return toReturn.substring(0, last - 1);
- }
-
- private boolean compareStringToPredicate(String query, Predicate predicate) {
- if (!query.contains(predicate.getType().getToken())) {
- return false;
- }
- if (!query.contains(predicate.getOp().getToken())) {
- return false;
- }
- for (SearchFlag flag : predicate.getFlags()) {
- if (!query.contains(flag.getToken())) {
- return false;
- }
- }
- for (String typeParam : predicate.getTypeParameters()) {
- if (!query.contains(typeParam)) {
- return false;
- }
- }
- for (String value : predicate.getValues()) {
- if (!query.contains(value)) {
- return false;
- }
- }
- return true;
- }
-
- @Test
- public void testMultiplePredicates() throws OseeCoreException {
- DslTranslatorImpl_V1 translator = new DslTranslatorImpl_V1();
- int size = 5;
-
- String test = getTestQuery(size);
- List<Predicate> translated = translator.translate(test);
- Assert.assertEquals(size, translated.size());
- String[] predicates = test.split("\\]&\\[");
-
- for (int i = 0; i < size; i++) {
- Assert.assertTrue(compareStringToPredicate(predicates[i], translated.get(i)));
- }
- }
-
- @Test
- public void testAttrTypeSearches() throws OseeCoreException {
- DslTranslatorImpl_V1 translator = new DslTranslatorImpl_V1();
- List<Predicate> predicates;
-
- String test = "[t:attrType&tp:0x1000000000000070&op:==&v:AtsAdmin]";
- predicates = translator.translate(test);
- Assert.assertEquals(1, predicates.size());
- Predicate predicate = predicates.iterator().next();
- Assert.assertEquals(SearchMethod.ATTRIBUTE_TYPE, predicate.getType());
- Assert.assertEquals(SearchOp.EQUALS, predicate.getOp());
- Assert.assertTrue(predicate.getValues().contains("AtsAdmin"));
-
- test = "[t:isOfType&tp:1000000000000070&op:>&v:AtsAdmin]";
- predicates = translator.translate(test);
- Assert.assertEquals(1, predicates.size());
- predicate = predicates.iterator().next();
- Assert.assertEquals(SearchMethod.IS_OF_TYPE, predicate.getType());
- Assert.assertEquals(SearchOp.GREATER_THAN, predicate.getOp());
- Assert.assertTrue(predicate.getValues().contains("AtsAdmin"));
-
- test = "[t:ids&tp:1000000000000070&op:<&v:AtsAdmin&d:ANY']";
- test += "&[t:attrType&tp:1000000000000070&op:==&v:TestAdmin&d:ANY']";
- predicates = translator.translate(test);
- Assert.assertEquals(2, predicates.size());
- predicate = predicates.get(0);
- Assert.assertEquals(SearchMethod.IDS, predicate.getType());
- Assert.assertEquals(SearchOp.LESS_THAN, predicate.getOp());
- Assert.assertTrue(predicate.getValues().contains("AtsAdmin"));
- Assert.assertEquals(TokenDelimiterMatch.ANY, predicate.getDelimiter());
- predicate = predicates.get(1);
- Assert.assertEquals(SearchMethod.ATTRIBUTE_TYPE, predicate.getType());
- Assert.assertEquals(SearchOp.EQUALS, predicate.getOp());
- Assert.assertTrue(predicate.getValues().contains("TestAdmin"));
- Assert.assertEquals(TokenDelimiterMatch.ANY, predicate.getDelimiter());
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java
index 0a9573028a9..7369a2092bf 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java
@@ -19,12 +19,11 @@ import java.util.Map;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.orcs.rest.internal.search.artifact.PredicateHandler;
import org.eclipse.osee.orcs.rest.internal.search.artifact.dsl.SearchQueryBuilder;
import org.eclipse.osee.orcs.rest.model.search.artifact.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.artifact.RequestType;
import org.eclipse.osee.orcs.rest.model.search.artifact.SearchMethod;
-import org.eclipse.osee.orcs.rest.model.search.artifact.SearchOp;
import org.eclipse.osee.orcs.rest.model.search.artifact.SearchRequest;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
@@ -66,11 +65,8 @@ public class SearchDslTest {
when(queryFactory.fromBranch(any(IOseeBranch.class))).thenReturn(builder);
Predicate predicate =
- new Predicate(SearchMethod.ATTRIBUTE_TYPE, Arrays.asList("1000000000000070"), SearchOp.EQUALS, null, null,
- Arrays.asList("AtsAdmin"));
- SearchRequest params =
- new SearchRequest(BRANCH.getUuid(), Arrays.asList(predicate), Strings.EMPTY_STRING, Strings.EMPTY_STRING, 0,
- false);
+ new Predicate(SearchMethod.ATTRIBUTE_TYPE, Arrays.asList("1000000000000070"), Arrays.asList("AtsAdmin"));
+ SearchRequest params = new SearchRequest(BRANCH.getUuid(), Arrays.asList(predicate), RequestType.IDS, 0, false);
dsl.build(queryFactory, params);
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandlerTest.java
index 6478b843c22..959a6ba14cd 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandlerTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandlerTest.java
@@ -10,29 +10,19 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.internal.search.predicate;
-import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyCollectionOf;
import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.eclipse.osee.framework.core.data.IAttributeType;
-import org.eclipse.osee.framework.core.enums.CaseType;
-import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
-import org.eclipse.osee.framework.core.enums.Operator;
-import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
-import org.eclipse.osee.framework.core.enums.TokenOrderType;
+import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.rest.internal.search.artifact.predicate.AttributeTypePredicateHandler;
import org.eclipse.osee.orcs.rest.model.search.artifact.Predicate;
-import org.eclipse.osee.orcs.rest.model.search.artifact.SearchFlag;
import org.eclipse.osee.orcs.rest.model.search.artifact.SearchMethod;
-import org.eclipse.osee.orcs.rest.model.search.artifact.SearchOp;
import org.eclipse.osee.orcs.search.QueryBuilder;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -48,7 +38,7 @@ public class AttributeTypePredicateHandlerTest {
@Mock
private QueryBuilder builder;
@Captor
- private ArgumentCaptor<TokenDelimiterMatch> delimiter;
+ private ArgumentCaptor<QueryOption> delimiter;
@Captor
private ArgumentCaptor<Collection<String>> valueCaptor;
@@ -61,44 +51,10 @@ public class AttributeTypePredicateHandlerTest {
public void testStringSearchOptions() throws OseeCoreException {
AttributeTypePredicateHandler handler = new AttributeTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("0x0123");
- List<SearchFlag> flags = Collections.emptyList();
List<String> values = Collections.singletonList("value");
- Predicate testPredicate =
- new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, TokenDelimiterMatch.ANY,
- values);
+ Predicate testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, values, QueryOption.TOKEN_DELIMITER__ANY);
handler.handle(builder, testPredicate);
- verify(builder).and(anyCollectionOf(IAttributeType.class), eq("value"), delimiter.capture(),
- eq(CaseType.IGNORE_CASE), eq(TokenOrderType.ANY_ORDER), eq(MatchTokenCountType.IGNORE_TOKEN_COUNT));
-
- reset(builder);
- flags = Arrays.asList(SearchFlag.values());
- testPredicate =
- new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, TokenDelimiterMatch.ANY,
- values);
- handler.handle(builder, testPredicate);
- verify(builder).and(anyCollectionOf(IAttributeType.class), eq("value"), delimiter.capture(),
- eq(CaseType.MATCH_CASE), eq(TokenOrderType.MATCH_ORDER), eq(MatchTokenCountType.MATCH_TOKEN_COUNT));
+ verify(builder).and(anyCollectionOf(IAttributeType.class), eq("value"), eq(QueryOption.TOKEN_DELIMITER__ANY));
}
- @Test
- public void testOperatorSelection() throws OseeCoreException {
- AttributeTypePredicateHandler handler = new AttributeTypePredicateHandler();
- List<String> typeParameters = Collections.singletonList("0x0123");
- List<SearchFlag> flags = Arrays.asList(SearchFlag.MATCH_CASE);
- List<String> values = Collections.singletonList("value");
- Predicate testPredicate =
- new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.GREATER_THAN, flags,
- TokenDelimiterMatch.ANY, values);
- handler.handle(builder, testPredicate);
- verify(builder).and(any(IAttributeType.class), eq(Operator.GREATER_THAN), valueCaptor.capture());
- Assert.assertEquals(values, valueCaptor.getValue());
-
- reset(builder);
- testPredicate =
- new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.LESS_THAN, flags, TokenDelimiterMatch.ANY,
- values);
- handler.handle(builder, testPredicate);
- verify(builder).and(any(IAttributeType.class), eq(Operator.LESS_THAN), valueCaptor.capture());
- Assert.assertEquals(values, valueCaptor.getValue());
- }
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java
index 4e0a6b34532..cf776cf0987 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java
@@ -23,13 +23,11 @@ import java.util.List;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.data.IRelationTypeSide;
-import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
+import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.rest.internal.search.artifact.predicate.ExistsTypePredicateHandler;
import org.eclipse.osee.orcs.rest.model.search.artifact.Predicate;
-import org.eclipse.osee.orcs.rest.model.search.artifact.SearchFlag;
import org.eclipse.osee.orcs.rest.model.search.artifact.SearchMethod;
-import org.eclipse.osee.orcs.rest.model.search.artifact.SearchOp;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.junit.Assert;
import org.junit.Before;
@@ -61,13 +59,10 @@ public class ExistsTypePredicateHandlerTest {
public void testHandleRelationTypeSideA() throws OseeCoreException {
ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("relType");
- //no flags for exists type
- List<SearchFlag> flags = Collections.emptyList();
//for relation type sides, first char must be A or B denoting side, followed by relation type uuid
String relationValue = "12345";
List<String> values = Collections.singletonList(relationValue);
- Predicate testPredicate =
- new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, values);
handler.handle(builder, testPredicate);
verify(builder).andExists(relationTypeCaptor.capture());
Assert.assertEquals(1, relationTypeCaptor.getAllValues().size());
@@ -79,11 +74,9 @@ public class ExistsTypePredicateHandlerTest {
ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("relType");
//no flags for exists type
- List<SearchFlag> flags = Collections.emptyList();
String relationValue = "12345";
List<String> values = Collections.singletonList(relationValue);
- Predicate testPredicate =
- new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, values);
handler.handle(builder, testPredicate);
verify(builder).andExists(relationTypeCaptor.capture());
@@ -95,14 +88,11 @@ public class ExistsTypePredicateHandlerTest {
public void testHandleRelationTypeSideMultiples() throws OseeCoreException {
ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("relType");
- //no flags for exists type
- List<SearchFlag> flags = Collections.emptyList();
//test multiples
String relationValue1 = "12345";
String relationValue2 = "34567";
List<String> values = Arrays.asList(relationValue1, relationValue2);
- Predicate testPredicate =
- new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, values);
handler.handle(builder, testPredicate);
verify(builder, times(2)).andExists(relationTypeCaptor.capture());
@@ -119,13 +109,10 @@ public class ExistsTypePredicateHandlerTest {
public void testHandleAttrTypeSingle() throws OseeCoreException {
ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("attrType");
- //no flags for exists type
- List<SearchFlag> flags = Collections.emptyList();
//for relation type sides, first char must be A or B denoting side, followed by relation type uuid
String attrUuid = "12345";
List<String> values = Collections.singletonList(attrUuid);
- Predicate testPredicate =
- new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, values);
handler.handle(builder, testPredicate);
verify(builder).andExists(attrTypeSideCaptor.capture());
Assert.assertEquals(1, attrTypeSideCaptor.getAllValues().size());
@@ -137,14 +124,10 @@ public class ExistsTypePredicateHandlerTest {
public void testHandleAttrTypeMultiple() throws OseeCoreException {
ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("attrType");
- //no flags for exists type
- List<SearchFlag> flags = Collections.emptyList();
String attrType1 = "12345";
String attrType2 = "34567";
List<String> values = Arrays.asList(attrType1, attrType2);
- Predicate testPredicate =
- new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, TokenDelimiterMatch.ANY,
- values);
+ Predicate testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, values, QueryOption.TOKEN_DELIMITER__ANY);
handler.handle(builder, testPredicate);
verify(builder).andExists(attrTypeSideCaptor.capture());
@@ -158,22 +141,16 @@ public class ExistsTypePredicateHandlerTest {
public void testHandleBadValues() throws OseeCoreException {
ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("attrType");
- //no flags for exists type
- List<SearchFlag> flags = Collections.emptyList();
String value = "12A4G";
List<String> values = Collections.singletonList(value);
- Predicate testPredicate =
- new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, TokenDelimiterMatch.ANY,
- values);
+ Predicate testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, values, QueryOption.TOKEN_DELIMITER__ANY);
handler.handle(builder, testPredicate);
verify(builder, never()).andExists(anyCollectionOf(IAttributeType.class));
value = "12A4G";
typeParameters = Collections.singletonList("relType");
values = Collections.singletonList(value);
- testPredicate =
- new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, TokenDelimiterMatch.ANY,
- values);
+ testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, values, QueryOption.TOKEN_DELIMITER__ANY);
handler.handle(builder, testPredicate);
verify(builder, never()).andExists(any(IRelationTypeSide.class));
}
@@ -182,8 +159,8 @@ public class ExistsTypePredicateHandlerTest {
public void testBadValuesThrowException() throws OseeCoreException {
ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
Predicate testPredicate =
- new Predicate(SearchMethod.ATTRIBUTE_TYPE, Collections.singletonList("relType"), SearchOp.EQUALS, null,
- TokenDelimiterMatch.ANY, Collections.singletonList("A12A4G"));
+ new Predicate(SearchMethod.ATTRIBUTE_TYPE, Collections.singletonList("relType"),
+ Collections.singletonList("A12A4G"), QueryOption.TOKEN_DELIMITER__ANY);
handler.handle(builder, testPredicate);
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/GuidsPredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/GuidsPredicateHandlerTest.java
index ec80527834e..974409a0c2d 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/GuidsPredicateHandlerTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/GuidsPredicateHandlerTest.java
@@ -47,11 +47,11 @@ public class GuidsPredicateHandlerTest {
@Test
public void testHandleGuids() throws OseeCoreException {
GuidsPredicateHandler handler = new GuidsPredicateHandler();
- // no type params, op, or flags for ids - any passed are ignored
+ // no type params for ids - any passed are ignored
// if not all digits, treated as guid
String id2 = "AGUID234";
List<String> values = Collections.singletonList(id2);
- Predicate testPredicate = new Predicate(SearchMethod.GUIDS, null, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.GUIDS, null, values);
handler.handle(builder, testPredicate);
verify(builder).andGuids(guidsCaptor.capture());
Assert.assertEquals(1, guidsCaptor.getValue().size());
@@ -61,7 +61,7 @@ public class GuidsPredicateHandlerTest {
@Test(expected = OseeArgumentException.class)
public void testHandleBadValues() throws OseeCoreException {
GuidsPredicateHandler handler = new GuidsPredicateHandler();
- Predicate testPredicate = new Predicate(SearchMethod.GUIDS, null, null, null, null, null);
+ Predicate testPredicate = new Predicate(SearchMethod.GUIDS, null, null);
handler.handle(builder, testPredicate);
}
@@ -70,7 +70,7 @@ public class GuidsPredicateHandlerTest {
GuidsPredicateHandler handler = new GuidsPredicateHandler();
String id1 = "12345";
List<String> values = Collections.singletonList(id1);
- Predicate testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, null, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, null, values);
handler.handle(builder, testPredicate);
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IdsPredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IdsPredicateHandlerTest.java
index 6218001a951..d640ffa84cc 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IdsPredicateHandlerTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IdsPredicateHandlerTest.java
@@ -14,7 +14,6 @@ import static org.mockito.Mockito.verify;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import org.junit.Assert;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.GUID;
@@ -22,6 +21,7 @@ import org.eclipse.osee.orcs.rest.internal.search.artifact.predicate.IdsPredicat
import org.eclipse.osee.orcs.rest.model.search.artifact.Predicate;
import org.eclipse.osee.orcs.rest.model.search.artifact.SearchMethod;
import org.eclipse.osee.orcs.search.QueryBuilder;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -55,7 +55,7 @@ public class IdsPredicateHandlerTest {
//all digits get treated as artId
String id1 = "12345";
List<String> values = Collections.singletonList(id1);
- Predicate testPredicate = new Predicate(SearchMethod.IDS, null, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.IDS, null, values);
handler.handle(builder, testPredicate);
verify(builder).andLocalIds(localIdsCaptor.capture());
Assert.assertEquals(1, localIdsCaptor.getValue().size());
@@ -70,14 +70,14 @@ public class IdsPredicateHandlerTest {
//all digits get treated as artId
String id1 = GUID.create();
List<String> values = Collections.singletonList(id1);
- Predicate testPredicate = new Predicate(SearchMethod.IDS, null, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.IDS, null, values);
handler.handle(builder, testPredicate);
}
@Test(expected = OseeArgumentException.class)
public void testHandleBadValues() throws OseeCoreException {
IdsPredicateHandler handler = new IdsPredicateHandler();
- Predicate testPredicate = new Predicate(SearchMethod.IDS, null, null, null, null, null);
+ Predicate testPredicate = new Predicate(SearchMethod.IDS, null, null);
handler.handle(builder, testPredicate);
}
@@ -86,7 +86,7 @@ public class IdsPredicateHandlerTest {
IdsPredicateHandler handler = new IdsPredicateHandler();
String id1 = "12345";
List<String> values = Collections.singletonList(id1);
- Predicate testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, null, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, null, values);
handler.handle(builder, testPredicate);
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandlerTest.java
index b215736be6a..9d31bf521d4 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandlerTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandlerTest.java
@@ -10,13 +10,12 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.internal.search.predicate;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.verify;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-import org.junit.Assert;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -24,6 +23,7 @@ import org.eclipse.osee.orcs.rest.internal.search.artifact.predicate.IsOfTypePre
import org.eclipse.osee.orcs.rest.model.search.artifact.Predicate;
import org.eclipse.osee.orcs.rest.model.search.artifact.SearchMethod;
import org.eclipse.osee.orcs.search.QueryBuilder;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -54,7 +54,7 @@ public class IsOfTypePredicateHandlerTest {
String id1 = "12345";
List<String> values = Collections.singletonList(id1);
- Predicate testPredicate = new Predicate(SearchMethod.IS_OF_TYPE, null, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.IS_OF_TYPE, null, values);
handler.handle(builder, testPredicate);
verify(builder).andIsOfType(artifactTypesCaptor.capture());
Assert.assertEquals(1, artifactTypesCaptor.getValue().size());
@@ -69,7 +69,7 @@ public class IsOfTypePredicateHandlerTest {
String id2 = "45678";
List<String> values = Arrays.asList(id1, id2);
- Predicate testPredicate = new Predicate(SearchMethod.IS_OF_TYPE, null, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.IS_OF_TYPE, null, values);
handler.handle(builder, testPredicate);
verify(builder).andIsOfType(artifactTypesCaptor.capture());
Assert.assertEquals(2, artifactTypesCaptor.getValue().size());
@@ -81,7 +81,7 @@ public class IsOfTypePredicateHandlerTest {
@Test(expected = OseeArgumentException.class)
public void testHandleBadValues() throws OseeCoreException {
IsOfTypePredicateHandler handler = new IsOfTypePredicateHandler();
- Predicate testPredicate = new Predicate(SearchMethod.IS_OF_TYPE, null, null, null, null, null);
+ Predicate testPredicate = new Predicate(SearchMethod.IS_OF_TYPE, null, null);
handler.handle(builder, testPredicate);
}
@@ -90,7 +90,7 @@ public class IsOfTypePredicateHandlerTest {
IsOfTypePredicateHandler handler = new IsOfTypePredicateHandler();
String id1 = "12345";
List<String> values = Collections.singletonList(id1);
- Predicate testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, null, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, null, values);
handler.handle(builder, testPredicate);
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandlerTest.java
index 1ecc7c023bb..e1e2238408c 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandlerTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandlerTest.java
@@ -14,18 +14,15 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import org.eclipse.osee.framework.core.data.IRelationTypeSide;
+import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.core.enums.RelationSide;
-import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.orcs.rest.internal.search.artifact.predicate.RelatedToPredicateHandler;
import org.eclipse.osee.orcs.rest.model.search.artifact.Predicate;
-import org.eclipse.osee.orcs.rest.model.search.artifact.SearchFlag;
import org.eclipse.osee.orcs.rest.model.search.artifact.SearchMethod;
-import org.eclipse.osee.orcs.rest.model.search.artifact.SearchOp;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.junit.Assert;
import org.junit.Before;
@@ -55,10 +52,8 @@ public class RelatedToPredicateHandlerTest {
@Test
public void testRelatedToLocalIds() throws OseeCoreException {
RelatedToPredicateHandler handler = new RelatedToPredicateHandler();
- List<SearchFlag> emptySearchFlags = Collections.emptyList();
Predicate testPredicate =
- new Predicate(SearchMethod.RELATED_TO, Arrays.asList("A1", "B2"), SearchOp.EQUALS, emptySearchFlags,
- TokenDelimiterMatch.ANY, Arrays.asList("4", "5"));
+ new Predicate(SearchMethod.RELATED_TO, Arrays.asList("A1", "B2"), Arrays.asList("4", "5"), QueryOption.TOKEN_DELIMITER__ANY);
handler.handle(builder, testPredicate);
verify(builder, times(2)).andRelatedToLocalIds(rtsCaptor.capture(), idsCaptor.capture());
List<IRelationTypeSide> rts = rtsCaptor.getAllValues();
@@ -74,10 +69,9 @@ public class RelatedToPredicateHandlerTest {
@Test(expected = UnsupportedOperationException.class)
public void testUnsupportedOperation() throws OseeCoreException {
RelatedToPredicateHandler handler = new RelatedToPredicateHandler();
- List<SearchFlag> emptySearchFlags = Collections.emptyList();
Predicate testPredicate =
- new Predicate(SearchMethod.RELATED_TO, Arrays.asList("A1", "B2"), SearchOp.EQUALS, emptySearchFlags,
- TokenDelimiterMatch.ANY, Arrays.asList(GUID.create()));
+ new Predicate(SearchMethod.RELATED_TO, Arrays.asList("A1", "B2"), Arrays.asList(GUID.create()),
+ QueryOption.TOKEN_DELIMITER__ANY);
handler.handle(builder, testPredicate);
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/TypeEqualsPredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/TypeEqualsPredicateHandlerTest.java
index 4916cd51e6b..2091eb67781 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/TypeEqualsPredicateHandlerTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/TypeEqualsPredicateHandlerTest.java
@@ -59,7 +59,7 @@ public class TypeEqualsPredicateHandlerTest {
String id1 = "12345";
List<String> values = Collections.singletonList(id1);
- Predicate testPredicate = new Predicate(SearchMethod.TYPE_EQUALS, null, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.TYPE_EQUALS, null, values);
handler.handle(builder, testPredicate);
verify(builder).andTypeEquals(artifactTypesCaptor.capture());
@@ -74,7 +74,7 @@ public class TypeEqualsPredicateHandlerTest {
String id2 = "45678";
List<String> values = Arrays.asList(id1, id2);
- Predicate testPredicate = new Predicate(SearchMethod.TYPE_EQUALS, null, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.TYPE_EQUALS, null, values);
handler.handle(builder, testPredicate);
verify(builder).andTypeEquals(artifactTypesCaptor.capture());
@@ -89,7 +89,7 @@ public class TypeEqualsPredicateHandlerTest {
@Test(expected = OseeArgumentException.class)
public void testHandleBadValues() throws OseeCoreException {
- Predicate testPredicate = new Predicate(SearchMethod.TYPE_EQUALS, null, null, null, null, null);
+ Predicate testPredicate = new Predicate(SearchMethod.TYPE_EQUALS, null, null);
handler.handle(builder, testPredicate);
}
@@ -97,7 +97,7 @@ public class TypeEqualsPredicateHandlerTest {
public void testBadSearchMethod() throws OseeCoreException {
String id1 = "12345";
List<String> values = Collections.singletonList(id1);
- Predicate testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, null, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, null, values);
handler.handle(builder, testPredicate);
}
}

Back to the top