QueryFilter { static List<Conjunction> createDisjunctiveNormalForm(Query q) { ArrayList<Conjunction> prefixes = new ArrayList<>(); createDisjunctiveNormalForm(q, prefixes, false); return prefixes; } private  QueryFilter(Evaluator evaluator); static QueryFilter create(Query q); boolean evaluate(ServiceDocument document, ServiceDocumentDescription description); static final QueryFilter TRUE; static final QueryFilter FALSE; }
@Test public void simpleDisjunction() { Set<String> dnf = createDisjunctiveNormalForm(createSimpleDisjunctionQuery()); assertEquals(2, dnf.size()); assertTrue(dnf.contains("c1=v1")); assertTrue(dnf.contains("c2=v2")); }
@Test public void simpleConjunction() { Set<String> dnf = createDisjunctiveNormalForm(createSimpleConjunctionQuery()); assertEquals(1, dnf.size()); assertTrue(dnf.contains("c1=v1 AND c2=v2")); }
@Test public void withNegation() { Set<String> dnf = createDisjunctiveNormalForm(createWithNegationQuery()); assertEquals(1, dnf.size()); assertTrue(dnf.contains("c1=v1 AND NOT(c2=v2)")); }
@Test public void mustOccurMixedWithShouldOccur() { Set<String> dnf = createDisjunctiveNormalForm(createMustOccurMixedWithShouldOccurQuery()); assertEquals(1, dnf.size()); assertTrue(dnf.contains("c1=v1 AND c3=v3")); }
@Test public void simpleDisjunctionOfConjunctions() { Set<String> dnf = createDisjunctiveNormalForm(createSimpleDisjunctionOfConjunctionsQuery()); assertEquals(2, dnf.size()); assertTrue(dnf.contains("c1=v1 AND c2=v2")); assertTrue(dnf.contains("c3=v3 AND c4=v4")); }
@Test public void simpleConjunctionOfDisjunctions() { Set<String> dnf = createDisjunctiveNormalForm(createSimpleConjunctionOfDisjunctionsQuery()); assertEquals(4, dnf.size()); assertTrue(dnf.contains("c1=v1 AND c3=v3")); assertTrue(dnf.contains("c1=v1 AND c4=v4")); assertTrue(dnf.contains("c2=v2 AND c3=v3")); assertTrue(dnf.contains("c2=v2 AND c4=v4")); }
@Test public void simpleCompositeField() { Set<String> dnf = createDisjunctiveNormalForm(createWithCompositeField()); assertEquals(1, dnf.size()); assertTrue(dnf.contains("nc1.ns1=v1")); }
@Test public void simpleComposedNegation() { Set<String> dnf = createDisjunctiveNormalForm(createComposedNegationQuery()); assertEquals(2, dnf.size()); assertTrue(dnf.contains("c1=match AND NOT(c2=match)")); assertTrue(dnf.contains("c1=match AND c3=match")); }