diff options
Diffstat (limited to 'predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicatesTest.java')
-rw-r--r-- | predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicatesTest.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicatesTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicatesTest.java new file mode 100644 index 00000000000..22832eedeff --- /dev/null +++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicatesTest.java @@ -0,0 +1,38 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.document.predicate; + +import org.junit.Test; + +import static com.yahoo.document.predicate.Predicates.and; +import static com.yahoo.document.predicate.Predicates.feature; +import static com.yahoo.document.predicate.Predicates.not; +import static com.yahoo.document.predicate.Predicates.or; +import static com.yahoo.document.predicate.Predicates.value; +import static org.junit.Assert.assertEquals; + +/** + * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen Hult</a> + */ +public class PredicatesTest { + + @Test + public void requireThatApiIsUsable() { + assertEquals( + new Disjunction( + new Conjunction(new FeatureSet("country", "de", "no"), + new Negation(new FeatureSet("gender", "female")), + new FeatureRange("age", 6L, 9L)), + new Conjunction(new Negation(new FeatureSet("country", "se")), + new FeatureSet("gender", "female"), + new FeatureRange("age", 69L, null))), + or(and(feature("country").inSet("de", "no"), + feature("gender").notInSet("female"), + feature("age").inRange(6, 9)), + and(not(feature("country").inSet("se")), + feature("gender").inSet("female"), + feature("age").greaterThanOrEqualTo(69)))); + + assertEquals(new BooleanPredicate(true), value(true)); + assertEquals(new BooleanPredicate(false), value(false)); + } +} |