aboutsummaryrefslogtreecommitdiffstats
path: root/predicate-search-core/src/test/java/com/yahoo/document/predicate
diff options
context:
space:
mode:
Diffstat (limited to 'predicate-search-core/src/test/java/com/yahoo/document/predicate')
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/BinaryFormatTest.java28
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/BooleanPredicateTest.java23
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/ConjunctionTest.java53
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/DisjunctionTest.java53
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureConjunctionTest.java53
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureRangeTest.java78
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureSetTest.java73
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/NegationTest.java33
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateHashTest.java8
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateOperatorTest.java6
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateParserTest.java54
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateTest.java62
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateValueTest.java6
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicatesTest.java24
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/RangeEdgePartitionTest.java33
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/document/predicate/RangePartitionTest.java25
16 files changed, 300 insertions, 312 deletions
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/BinaryFormatTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/BinaryFormatTest.java
index c37d6b246a5..0f15fcd656a 100644
--- a/predicate-search-core/src/test/java/com/yahoo/document/predicate/BinaryFormatTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/BinaryFormatTest.java
@@ -3,10 +3,10 @@ package com.yahoo.document.predicate;
import com.yahoo.slime.Inspector;
import com.yahoo.slime.Slime;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -14,7 +14,7 @@ import static org.junit.Assert.fail;
public class BinaryFormatTest {
@Test
- public void requireThatEncodeNullThrows() {
+ void requireThatEncodeNullThrows() {
try {
BinaryFormat.encode(null);
fail();
@@ -24,7 +24,7 @@ public class BinaryFormatTest {
}
@Test
- public void requireThatDecodeNullThrows() {
+ void requireThatDecodeNullThrows() {
try {
BinaryFormat.decode(null);
fail();
@@ -34,7 +34,7 @@ public class BinaryFormatTest {
}
@Test
- public void requireThatDecodeEmptyThrows() {
+ void requireThatDecodeEmptyThrows() {
try {
BinaryFormat.decode(new byte[0]);
fail();
@@ -44,17 +44,17 @@ public class BinaryFormatTest {
}
@Test
- public void requireThatConjunctionCanBeSerialized() {
+ void requireThatConjunctionCanBeSerialized() {
assertSerialize(new Conjunction(new FeatureSet("foo", "bar"), new FeatureSet("baz", "cox")));
}
@Test
- public void requireThatDisjunctionCanBeSerialized() {
+ void requireThatDisjunctionCanBeSerialized() {
assertSerialize(new Disjunction(new FeatureSet("foo", "bar"), new FeatureSet("baz", "cox")));
}
@Test
- public void requireThatFeatureRangeCanBeSerialized() {
+ void requireThatFeatureRangeCanBeSerialized() {
assertSerialize(new FeatureRange("foo", null, null));
assertSerialize(new FeatureRange("foo", null, 9L));
assertSerialize(new FeatureRange("foo", 6L, null));
@@ -62,7 +62,7 @@ public class BinaryFormatTest {
}
@Test
- public void requireThatPartitionedFeatureRangeCanBeSerialized() {
+ void requireThatPartitionedFeatureRangeCanBeSerialized() {
FeatureRange expected = new FeatureRange("foo", 8L, 20L);
FeatureRange f = new FeatureRange("foo", 8L, 20L);
f.addPartition(new RangeEdgePartition("foo=0", 0, 8, -1));
@@ -87,25 +87,25 @@ public class BinaryFormatTest {
}
@Test
- public void requireThatFeatureSetCanBeSerialized() {
+ void requireThatFeatureSetCanBeSerialized() {
assertSerialize(new FeatureSet("foo"));
assertSerialize(new FeatureSet("foo", "bar"));
assertSerialize(new FeatureSet("foo", "bar", "baz"));
}
@Test
- public void requireThatNegationCanBeSerialized() {
+ void requireThatNegationCanBeSerialized() {
assertSerialize(new Negation(new FeatureSet("foo", "bar")));
}
@Test
- public void requireThatBooleanCanBeSerialized() {
+ void requireThatBooleanCanBeSerialized() {
assertSerialize(new BooleanPredicate(true));
assertSerialize(new BooleanPredicate(false));
}
@Test
- public void requireThatUnknownNodeThrows() {
+ void requireThatUnknownNodeThrows() {
try {
BinaryFormat.encode(SimplePredicates.newString("foo"));
fail();
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/BooleanPredicateTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/BooleanPredicateTest.java
index 92c45520504..0dbfdb2559d 100644
--- a/predicate-search-core/src/test/java/com/yahoo/document/predicate/BooleanPredicateTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/BooleanPredicateTest.java
@@ -1,12 +1,9 @@
// Copyright Yahoo. 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 org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -14,12 +11,12 @@ import static org.junit.Assert.assertTrue;
public class BooleanPredicateTest {
@Test
- public void requireThatFalseIsAValue() {
+ void requireThatFalseIsAValue() {
assertTrue(PredicateValue.class.isAssignableFrom(BooleanPredicate.class));
}
@Test
- public void requireThatCloneIsImplemented() throws CloneNotSupportedException {
+ void requireThatCloneIsImplemented() throws CloneNotSupportedException {
BooleanPredicate node1 = new BooleanPredicate(true);
BooleanPredicate node2 = node1.clone();
assertEquals(node1, node2);
@@ -27,21 +24,21 @@ public class BooleanPredicateTest {
}
@Test
- public void requireThatHashCodeIsImplemented() {
+ void requireThatHashCodeIsImplemented() {
assertEquals(new BooleanPredicate(true).hashCode(), new BooleanPredicate(true).hashCode());
assertEquals(new BooleanPredicate(false).hashCode(), new BooleanPredicate(false).hashCode());
}
@Test
- public void requireThatEqualsIsImplemented() {
+ void requireThatEqualsIsImplemented() {
BooleanPredicate lhs = new BooleanPredicate(true);
- assertTrue(lhs.equals(lhs));
- assertFalse(lhs.equals(new Object()));
+ assertEquals(lhs, lhs);
+ assertNotEquals(lhs, new Object());
BooleanPredicate rhs = new BooleanPredicate(false);
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs.setValue(true);
- assertTrue(lhs.equals(rhs));
+ assertEquals(lhs, rhs);
}
}
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/ConjunctionTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/ConjunctionTest.java
index cbcab2917e5..fa4872715f6 100644
--- a/predicate-search-core/src/test/java/com/yahoo/document/predicate/ConjunctionTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/ConjunctionTest.java
@@ -1,14 +1,11 @@
// Copyright Yahoo. 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 org.junit.jupiter.api.Test;
import java.util.Arrays;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -16,12 +13,12 @@ import static org.junit.Assert.assertTrue;
public class ConjunctionTest {
@Test
- public void requireThatConjunctionIsAnOperator() {
+ void requireThatConjunctionIsAnOperator() {
assertTrue(PredicateOperator.class.isAssignableFrom(Conjunction.class));
}
@Test
- public void requireThatAccessorsWork() {
+ void requireThatAccessorsWork() {
Conjunction node = new Conjunction();
Predicate a = SimplePredicates.newString("a");
node.addOperand(a);
@@ -40,7 +37,7 @@ public class ConjunctionTest {
}
@Test
- public void requireThatConstructorsWork() {
+ void requireThatConstructorsWork() {
Predicate foo = SimplePredicates.newString("foo");
Predicate bar = SimplePredicates.newString("bar");
Conjunction node = new Conjunction(foo, bar);
@@ -51,7 +48,7 @@ public class ConjunctionTest {
}
@Test
- public void requireThatCloneIsImplemented() throws CloneNotSupportedException {
+ void requireThatCloneIsImplemented() throws CloneNotSupportedException {
Conjunction node1 = new Conjunction(SimplePredicates.newString("a"), SimplePredicates.newString("b"));
Conjunction node2 = node1.clone();
assertEquals(node1, node2);
@@ -60,27 +57,27 @@ public class ConjunctionTest {
}
@Test
- public void requireThatHashCodeIsImplemented() {
+ void requireThatHashCodeIsImplemented() {
assertEquals(new Conjunction().hashCode(), new Conjunction().hashCode());
}
@Test
- public void requireThatEqualsIsImplemented() {
+ void requireThatEqualsIsImplemented() {
Conjunction lhs = new Conjunction(SimplePredicates.newString("foo"),
- SimplePredicates.newString("bar"));
- assertTrue(lhs.equals(lhs));
- assertFalse(lhs.equals(new Object()));
+ SimplePredicates.newString("bar"));
+ assertEquals(lhs, lhs);
+ assertNotEquals(lhs, new Object());
Conjunction rhs = new Conjunction();
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs.addOperand(SimplePredicates.newString("foo"));
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs.addOperand(SimplePredicates.newString("bar"));
- assertTrue(lhs.equals(rhs));
+ assertEquals(lhs, rhs);
}
@Test
- public void requireThatNodeDelimiterIsAND() {
+ void requireThatNodeDelimiterIsAND() {
assertEquals("", newConjunction().toString());
assertEquals("foo", newConjunction("foo").toString());
assertEquals("foo and bar", newConjunction("foo", "bar").toString());
@@ -88,22 +85,22 @@ public class ConjunctionTest {
}
@Test
- public void requireThatSimpleConjunctionsArePrettyPrinted() {
+ void requireThatSimpleConjunctionsArePrettyPrinted() {
assertEquals("foo and bar",
- new Conjunction(SimplePredicates.newString("foo"),
- SimplePredicates.newString("bar")).toString());
+ new Conjunction(SimplePredicates.newString("foo"),
+ SimplePredicates.newString("bar")).toString());
}
@Test
- public void requireThatComplexConjunctionsArePrintedAsGroup() {
+ void requireThatComplexConjunctionsArePrintedAsGroup() {
assertEquals("foo and bar and baz",
- new Conjunction(SimplePredicates.newString("foo"),
- new Conjunction(SimplePredicates.newString("bar"),
- SimplePredicates.newString("baz"))).toString());
+ new Conjunction(SimplePredicates.newString("foo"),
+ new Conjunction(SimplePredicates.newString("bar"),
+ SimplePredicates.newString("baz"))).toString());
assertEquals("foo and (bar or baz)",
- new Conjunction(SimplePredicates.newString("foo"),
- new Disjunction(SimplePredicates.newString("bar"),
- SimplePredicates.newString("baz"))).toString());
+ new Conjunction(SimplePredicates.newString("foo"),
+ new Disjunction(SimplePredicates.newString("bar"),
+ SimplePredicates.newString("baz"))).toString());
}
private static Conjunction newConjunction(String... operands) {
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/DisjunctionTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/DisjunctionTest.java
index 1dab0dd80a2..d5640c7f0a2 100644
--- a/predicate-search-core/src/test/java/com/yahoo/document/predicate/DisjunctionTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/DisjunctionTest.java
@@ -1,14 +1,11 @@
// Copyright Yahoo. 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 org.junit.jupiter.api.Test;
import java.util.Arrays;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -16,12 +13,12 @@ import static org.junit.Assert.assertTrue;
public class DisjunctionTest {
@Test
- public void requireThatDisjunctionIsAnOperator() {
+ void requireThatDisjunctionIsAnOperator() {
assertTrue(PredicateOperator.class.isAssignableFrom(Disjunction.class));
}
@Test
- public void requireThatAccessorsWork() {
+ void requireThatAccessorsWork() {
Disjunction node = new Disjunction();
Predicate a = SimplePredicates.newString("a");
node.addOperand(a);
@@ -40,7 +37,7 @@ public class DisjunctionTest {
}
@Test
- public void requireThatConstructorsWork() {
+ void requireThatConstructorsWork() {
Predicate foo = SimplePredicates.newString("foo");
Predicate bar = SimplePredicates.newString("bar");
Disjunction node = new Disjunction(foo, bar);
@@ -51,7 +48,7 @@ public class DisjunctionTest {
}
@Test
- public void requireThatCloneIsImplemented() throws CloneNotSupportedException {
+ void requireThatCloneIsImplemented() throws CloneNotSupportedException {
Disjunction node1 = new Disjunction(SimplePredicates.newString("a"), SimplePredicates.newString("b"));
Disjunction node2 = node1.clone();
assertEquals(node1, node2);
@@ -60,27 +57,27 @@ public class DisjunctionTest {
}
@Test
- public void requireThatHashCodeIsImplemented() {
+ void requireThatHashCodeIsImplemented() {
assertEquals(new Disjunction().hashCode(), new Disjunction().hashCode());
}
@Test
- public void requireThatEqualsIsImplemented() {
+ void requireThatEqualsIsImplemented() {
Disjunction lhs = new Disjunction(SimplePredicates.newString("foo"),
- SimplePredicates.newString("bar"));
- assertTrue(lhs.equals(lhs));
- assertFalse(lhs.equals(new Object()));
+ SimplePredicates.newString("bar"));
+ assertEquals(lhs, lhs);
+ assertNotEquals(lhs, new Object());
Disjunction rhs = new Disjunction();
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs.addOperand(SimplePredicates.newString("foo"));
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs.addOperand(SimplePredicates.newString("bar"));
- assertTrue(lhs.equals(rhs));
+ assertEquals(lhs, rhs);
}
@Test
- public void requireThatNodeDelimiterIsOR() {
+ void requireThatNodeDelimiterIsOR() {
assertEquals("", newDisjunction().toString());
assertEquals("foo", newDisjunction("foo").toString());
assertEquals("foo or bar", newDisjunction("foo", "bar").toString());
@@ -88,22 +85,22 @@ public class DisjunctionTest {
}
@Test
- public void requireThatSimpleDisjunctionsArePrettyPrinted() {
+ void requireThatSimpleDisjunctionsArePrettyPrinted() {
assertEquals("foo or bar",
- new Disjunction(SimplePredicates.newString("foo"),
- SimplePredicates.newString("bar")).toString());
+ new Disjunction(SimplePredicates.newString("foo"),
+ SimplePredicates.newString("bar")).toString());
}
@Test
- public void requireThatComplexDisjunctionsArePrintedAsGroup() {
+ void requireThatComplexDisjunctionsArePrintedAsGroup() {
assertEquals("foo or bar or baz",
- new Disjunction(SimplePredicates.newString("foo"),
- new Disjunction(SimplePredicates.newString("bar"),
- SimplePredicates.newString("baz"))).toString());
+ new Disjunction(SimplePredicates.newString("foo"),
+ new Disjunction(SimplePredicates.newString("bar"),
+ SimplePredicates.newString("baz"))).toString());
assertEquals("foo or (bar and baz)",
- new Disjunction(SimplePredicates.newString("foo"),
- new Conjunction(SimplePredicates.newString("bar"),
- SimplePredicates.newString("baz"))).toString());
+ new Disjunction(SimplePredicates.newString("foo"),
+ new Conjunction(SimplePredicates.newString("bar"),
+ SimplePredicates.newString("baz"))).toString());
}
private static Disjunction newDisjunction(String... operands) {
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureConjunctionTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureConjunctionTest.java
index 059022f87e8..e44fd0e0a78 100644
--- a/predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureConjunctionTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureConjunctionTest.java
@@ -1,13 +1,14 @@
// Copyright Yahoo. 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 org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
import static com.yahoo.document.predicate.Predicates.feature;
import static com.yahoo.document.predicate.Predicates.not;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author bjorncs
@@ -15,38 +16,48 @@ import static com.yahoo.document.predicate.Predicates.not;
public class FeatureConjunctionTest {
@Test
- public void require_that_featureconjunction_with_valid_operands_can_be_constructed() {
+ void require_that_featureconjunction_with_valid_operands_can_be_constructed() {
new FeatureConjunction(Arrays.asList(
not(feature("a").inSet("1")),
feature("b").inSet("1")));
}
- @Test(expected = IllegalArgumentException.class)
- public void require_that_constructor_throws_exception_if_all_operands_are_not_featuresets() {
- new FeatureConjunction(Arrays.asList(
- not(feature("a").inSet("1")),
- feature("b").inRange(1, 2)));
+ @Test
+ void require_that_constructor_throws_exception_if_all_operands_are_not_featuresets() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ new FeatureConjunction(Arrays.asList(
+ not(feature("a").inSet("1")),
+ feature("b").inRange(1, 2)));
+ });
}
- @Test(expected = IllegalArgumentException.class)
- public void require_that_constructor_throws_exception_if_single_operand() {
- new FeatureConjunction(Arrays.asList(feature("a").inSet("1")));
+ @Test
+ void require_that_constructor_throws_exception_if_single_operand() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ new FeatureConjunction(Arrays.asList(feature("a").inSet("1")));
+ });
}
- @Test(expected = IllegalArgumentException.class)
- public void require_that_constructor_throws_exception_if_no_operands() {
- new FeatureConjunction(Collections.emptyList());
+ @Test
+ void require_that_constructor_throws_exception_if_no_operands() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ new FeatureConjunction(Collections.emptyList());
+ });
}
- @Test(expected = IllegalArgumentException.class)
- public void require_that_contructor_throws_exception_if_featuresets_contain_multiple_values() {
- new FeatureConjunction(Arrays.asList(feature("a").inSet("1"), feature("b").inSet("2", "3")));
+ @Test
+ void require_that_contructor_throws_exception_if_featuresets_contain_multiple_values() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ new FeatureConjunction(Arrays.asList(feature("a").inSet("1"), feature("b").inSet("2", "3")));
+ });
}
- @Test(expected = IllegalArgumentException.class)
- public void require_that_constructor_throws_exception_if_featureset_keys_are_not_unique() {
- new FeatureConjunction(Arrays.asList(
- not(feature("a").inSet("1")),
- feature("a").inSet("2")));
+ @Test
+ void require_that_constructor_throws_exception_if_featureset_keys_are_not_unique() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ new FeatureConjunction(Arrays.asList(
+ not(feature("a").inSet("1")),
+ feature("a").inSet("2")));
+ });
}
}
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureRangeTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureRangeTest.java
index 0951ae3bbc6..8d31765cf1b 100644
--- a/predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureRangeTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureRangeTest.java
@@ -1,11 +1,11 @@
// Copyright Yahoo. 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 org.junit.jupiter.api.Test;
import java.util.Arrays;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -13,12 +13,12 @@ import static org.junit.Assert.*;
public class FeatureRangeTest {
@Test
- public void requireThatFeatureRangeIsAValue() {
+ void requireThatFeatureRangeIsAValue() {
assertTrue(PredicateValue.class.isAssignableFrom(FeatureRange.class));
}
@Test
- public void requireThatAccessorsWork() {
+ void requireThatAccessorsWork() {
FeatureRange node = new FeatureRange("foo");
assertEquals("foo", node.getKey());
node.setKey("bar");
@@ -36,7 +36,7 @@ public class FeatureRangeTest {
}
@Test
- public void requireThatConstructorsWork() {
+ void requireThatConstructorsWork() {
FeatureRange node = new FeatureRange("foo");
assertEquals("foo", node.getKey());
assertNull(node.getFromInclusive());
@@ -64,7 +64,7 @@ public class FeatureRangeTest {
}
@Test
- public void requireThatCloneIsImplemented() throws CloneNotSupportedException {
+ void requireThatCloneIsImplemented() throws CloneNotSupportedException {
FeatureRange node1 = new FeatureRange("foo", 6L, 9L);
FeatureRange node2 = node1.clone();
assertEquals(node1, node2);
@@ -72,36 +72,36 @@ public class FeatureRangeTest {
}
@Test
- public void requireThatHashCodeIsImplemented() {
+ void requireThatHashCodeIsImplemented() {
assertEquals(new FeatureRange("key").hashCode(), new FeatureRange("key").hashCode());
}
@Test
- public void requireThatEqualsIsImplemented() {
+ void requireThatEqualsIsImplemented() {
FeatureRange lhs = new FeatureRange("foo", 6L, 9L);
- assertTrue(lhs.equals(lhs));
- assertFalse(lhs.equals(new Object()));
+ assertEquals(lhs, lhs);
+ assertNotEquals(lhs, new Object());
FeatureRange rhs = new FeatureRange("bar");
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs.setKey("foo");
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs.setFromInclusive(6L);
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs.setToInclusive(9L);
- assertTrue(lhs.equals(rhs));
+ assertEquals(lhs, rhs);
rhs.addPartition(new RangePartition("foo"));
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
lhs.addPartition(new RangePartition("foo"));
- assertTrue(lhs.equals(rhs));
+ assertEquals(lhs, rhs);
rhs.addPartition(new RangeEdgePartition("foo", 10, 0, 2));
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
lhs.addPartition(new RangeEdgePartition("foo", 10, 0, 2));
- assertTrue(lhs.equals(rhs));
+ assertEquals(lhs, rhs);
}
@Test
- public void requireThatFeatureKeyIsMandatoryInConstructor() {
+ void requireThatFeatureKeyIsMandatoryInConstructor() {
try {
new FeatureRange(null);
fail();
@@ -111,7 +111,7 @@ public class FeatureRangeTest {
}
@Test
- public void requireThatFeatureKeyIsMandatoryInSetter() {
+ void requireThatFeatureKeyIsMandatoryInSetter() {
FeatureRange node = new FeatureRange("foo");
try {
node.setKey(null);
@@ -123,7 +123,7 @@ public class FeatureRangeTest {
}
@Test
- public void requireThatRangeCanBeSingleValue() {
+ void requireThatRangeCanBeSingleValue() {
FeatureRange node = new FeatureRange("key", 6L, 6L);
assertEquals(6, node.getFromInclusive().intValue());
assertEquals(6, node.getToInclusive().intValue());
@@ -134,7 +134,7 @@ public class FeatureRangeTest {
}
@Test
- public void requireThatFromCanNotBeConstructedGreaterThanTo() {
+ void requireThatFromCanNotBeConstructedGreaterThanTo() {
try {
new FeatureRange("key", 9L, 6L);
fail();
@@ -144,7 +144,7 @@ public class FeatureRangeTest {
}
@Test
- public void requireThatFromCanNotBeSetGreaterThanTo() {
+ void requireThatFromCanNotBeSetGreaterThanTo() {
FeatureRange node = new FeatureRange("key", null, 6L);
try {
node.setFromInclusive(9L);
@@ -165,7 +165,7 @@ public class FeatureRangeTest {
}
@Test
- public void requireThatToCanNotBeSetLessThanFrom() {
+ void requireThatToCanNotBeSetLessThanFrom() {
FeatureRange node = new FeatureRange("key", 9L, null);
try {
node.setToInclusive(6L);
@@ -186,49 +186,49 @@ public class FeatureRangeTest {
}
@Test
- public void requireThatKeyIsEscapedInToString() {
+ void requireThatKeyIsEscapedInToString() {
assertEquals("foo in [6..9]",
- new FeatureRange("foo", 6L, 9L).toString());
+ new FeatureRange("foo", 6L, 9L).toString());
assertEquals("'\\foo' in [6..9]",
- new FeatureRange("\foo", 6L, 9L).toString());
+ new FeatureRange("\foo", 6L, 9L).toString());
assertEquals("'\\x27foo\\x27' in [6..9]",
- new FeatureRange("'foo'", 6L, 9L).toString());
+ new FeatureRange("'foo'", 6L, 9L).toString());
}
@Test
- public void requireThatToStringIncludesLimits() {
+ void requireThatToStringIncludesLimits() {
assertEquals("foo in [6..9]", new FeatureRange("foo", 6L, 9L).toString());
}
@Test
- public void requireThatToStringAllowsNullLimits() {
+ void requireThatToStringAllowsNullLimits() {
assertEquals("foo in [..]", new FeatureRange("foo").toString());
}
@Test
- public void requireThatToStringAllowsNullFromLimit() {
+ void requireThatToStringAllowsNullFromLimit() {
assertEquals("foo in [..69]", new FeatureRange("foo", null, 69L).toString());
}
@Test
- public void requireThatToStringAllowsNullToLimit() {
+ void requireThatToStringAllowsNullToLimit() {
assertEquals("foo in [69..]", new FeatureRange("foo", 69L, null).toString());
}
@Test
- public void requireThatSimpleStringsArePrettyPrinted() {
+ void requireThatSimpleStringsArePrettyPrinted() {
assertEquals("foo in [6..9]",
- new FeatureRange("foo", 6L, 9L).toString());
+ new FeatureRange("foo", 6L, 9L).toString());
}
@Test
- public void requireThatComplexStringsAreEscaped() {
+ void requireThatComplexStringsAreEscaped() {
assertEquals("'\\foo' in [6..9]",
- new FeatureRange("\foo", 6L, 9L).toString());
+ new FeatureRange("\foo", 6L, 9L).toString());
}
@Test
- public void requireThatRangePartitionsCanBeAdded() {
+ void requireThatRangePartitionsCanBeAdded() {
FeatureRange range = new FeatureRange("foo", 10L, 22L);
range.addPartition(new RangePartition("foo=10-19"));
range.addPartition(new RangePartition("foo", 0, 0x8000000000000000L, true));
@@ -237,7 +237,7 @@ public class FeatureRangeTest {
}
@Test
- public void requireThatRangePartitionsCanBeCleared() {
+ void requireThatRangePartitionsCanBeCleared() {
FeatureRange range = new FeatureRange("foo", 10L, 22L);
range.addPartition(new RangePartition("foo=10-19"));
range.addPartition(new RangeEdgePartition("foo=20", 20, 0, 2));
@@ -247,7 +247,7 @@ public class FeatureRangeTest {
}
@Test
- public void requireThatFeatureRangeCanBeBuiltFromMixedInNode() {
+ void requireThatFeatureRangeCanBeBuiltFromMixedInNode() {
assertEquals(new FeatureRange("foo", 10L, 19L),
FeatureRange.buildFromMixedIn("foo", Arrays.asList("foo=10-19"), 10));
assertEquals(new FeatureRange("foo", -19L, -10L),
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureSetTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureSetTest.java
index e0ed8da13c8..7068538a1e0 100644
--- a/predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureSetTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureSetTest.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. 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 org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -9,12 +9,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -22,12 +17,12 @@ import static org.junit.Assert.fail;
public class FeatureSetTest {
@Test
- public void requireThatFeatureSetIsAValue() {
+ void requireThatFeatureSetIsAValue() {
assertTrue(PredicateValue.class.isAssignableFrom(FeatureSet.class));
}
@Test
- public void requireThatAccessorsWork() {
+ void requireThatAccessorsWork() {
FeatureSet node = new FeatureSet("key", "valueA", "valueB");
assertEquals("key", node.getKey());
assertValues(Arrays.asList("valueA", "valueB"), node);
@@ -40,7 +35,7 @@ public class FeatureSetTest {
}
@Test
- public void requireThatValueSetIsMutable() {
+ void requireThatValueSetIsMutable() {
FeatureSet node = new FeatureSet("key");
node.getValues().add("valueA");
assertValues(Arrays.asList("valueA"), node);
@@ -51,7 +46,7 @@ public class FeatureSetTest {
}
@Test
- public void requireThatConstructorsWork() {
+ void requireThatConstructorsWork() {
FeatureSet node = new FeatureSet("key", "valueA", "valueB");
assertEquals("key", node.getKey());
assertValues(Arrays.asList("valueA", "valueB"), node);
@@ -62,7 +57,7 @@ public class FeatureSetTest {
}
@Test
- public void requireThatCloneIsImplemented() throws CloneNotSupportedException {
+ void requireThatCloneIsImplemented() throws CloneNotSupportedException {
FeatureSet node1 = new FeatureSet("key", "valueA", "valueB");
FeatureSet node2 = node1.clone();
assertEquals(node1, node2);
@@ -71,28 +66,28 @@ public class FeatureSetTest {
}
@Test
- public void requireThatHashCodeIsImplemented() {
+ void requireThatHashCodeIsImplemented() {
assertEquals(new FeatureSet("key").hashCode(), new FeatureSet("key").hashCode());
}
@Test
- public void requireThatEqualsIsImplemented() {
+ void requireThatEqualsIsImplemented() {
FeatureSet lhs = new FeatureSet("keyA", "valueA", "valueB");
- assertTrue(lhs.equals(lhs));
- assertFalse(lhs.equals(new Object()));
+ assertEquals(lhs, lhs);
+ assertNotEquals(lhs, new Object());
FeatureSet rhs = new FeatureSet("keyB");
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs.setKey("keyA");
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs.addValue("valueA");
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs.addValue("valueB");
- assertTrue(lhs.equals(rhs));
+ assertEquals(lhs, rhs);
}
@Test
- public void requireThatkeyIsMandatoryInConstructor() {
+ void requireThatkeyIsMandatoryInConstructor() {
try {
new FeatureSet(null);
fail();
@@ -108,7 +103,7 @@ public class FeatureSetTest {
}
@Test
- public void requireThatkeyIsMandatoryInSetter() {
+ void requireThatkeyIsMandatoryInSetter() {
FeatureSet node = new FeatureSet("foo");
try {
node.setKey(null);
@@ -120,7 +115,7 @@ public class FeatureSetTest {
}
@Test
- public void requireThatValueIsMandatoryInSetter() {
+ void requireThatValueIsMandatoryInSetter() {
FeatureSet node = new FeatureSet("foo", "bar");
try {
node.addValue(null);
@@ -132,49 +127,49 @@ public class FeatureSetTest {
}
@Test
- public void requireThatKeyIsEscapedInToString() {
+ void requireThatKeyIsEscapedInToString() {
assertEquals("foo in [val]",
- new FeatureSet("foo", "val").toString());
+ new FeatureSet("foo", "val").toString());
assertEquals("'\\foo' in [val]",
- new FeatureSet("\foo", "val").toString());
+ new FeatureSet("\foo", "val").toString());
assertEquals("'\\x27foo\\x27' in [val]",
- new FeatureSet("'foo'", "val").toString());
+ new FeatureSet("'foo'", "val").toString());
}
@Test
- public void requireThatValuesAreEscapedInToString() {
+ void requireThatValuesAreEscapedInToString() {
assertEquals("key in [bar, foo]",
- new FeatureSet("key", "foo", "bar").toString());
+ new FeatureSet("key", "foo", "bar").toString());
assertEquals("key in ['\\foo', 'ba\\r']",
- new FeatureSet("key", "\foo", "ba\r").toString());
+ new FeatureSet("key", "\foo", "ba\r").toString());
assertEquals("key in ['\\x27bar\\x27', '\\x27foo\\x27']",
- new FeatureSet("key", "'foo'", "'bar'").toString());
+ new FeatureSet("key", "'foo'", "'bar'").toString());
}
@Test
- public void requireThatSimpleStringsArePrettyPrinted() {
+ void requireThatSimpleStringsArePrettyPrinted() {
assertEquals("foo in [bar]",
- new FeatureSet("foo", "bar").toString());
+ new FeatureSet("foo", "bar").toString());
}
@Test
- public void requireThatComplexStringsAreEscaped() {
+ void requireThatComplexStringsAreEscaped() {
assertEquals("'\\foo' in ['ba\\r']",
- new FeatureSet("\foo", "ba\r").toString());
+ new FeatureSet("\foo", "ba\r").toString());
}
@Test
- public void requireThatNegatedFeatureSetsArePrettyPrinted() {
+ void requireThatNegatedFeatureSetsArePrettyPrinted() {
assertEquals("country not in [no, se]",
- new Negation(new FeatureSet("country", "no", "se")).toString());
+ new Negation(new FeatureSet("country", "no", "se")).toString());
}
private static void assertValues(Collection<String> expected, FeatureSet actual) {
List<String> tmp = new ArrayList<>(expected);
for (String value : actual.getValues()) {
- assertNotNull(value, tmp.remove(value));
+ assertNotNull(tmp.remove(value), value);
}
- assertTrue(tmp.toString(), tmp.isEmpty());
+ assertTrue(tmp.isEmpty(), tmp.toString());
}
}
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/NegationTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/NegationTest.java
index 904dce795c3..2a86727c81a 100644
--- a/predicate-search-core/src/test/java/com/yahoo/document/predicate/NegationTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/NegationTest.java
@@ -1,14 +1,9 @@
// Copyright Yahoo. 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 org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -16,12 +11,12 @@ import static org.junit.Assert.fail;
public class NegationTest {
@Test
- public void requireThatNegationIsAnOperator() {
+ void requireThatNegationIsAnOperator() {
assertTrue(PredicateOperator.class.isAssignableFrom(Negation.class));
}
@Test
- public void requireThatAccessorsWork() {
+ void requireThatAccessorsWork() {
Predicate foo = SimplePredicates.newString("foo");
Negation node = new Negation(foo);
assertSame(foo, node.getOperand());
@@ -32,7 +27,7 @@ public class NegationTest {
}
@Test
- public void requireThatCloneIsImplemented() throws CloneNotSupportedException {
+ void requireThatCloneIsImplemented() throws CloneNotSupportedException {
Negation node1 = new Negation(SimplePredicates.newString("a"));
Negation node2 = node1.clone();
assertEquals(node1, node2);
@@ -41,25 +36,25 @@ public class NegationTest {
}
@Test
- public void requireThatHashCodeIsImplemented() {
+ void requireThatHashCodeIsImplemented() {
Predicate predicate = SimplePredicates.newPredicate();
assertEquals(new Negation(predicate).hashCode(), new Negation(predicate).hashCode());
}
@Test
- public void requireThatEqualsIsImplemented() {
+ void requireThatEqualsIsImplemented() {
Negation lhs = new Negation(SimplePredicates.newString("foo"));
- assertTrue(lhs.equals(lhs));
- assertFalse(lhs.equals(new Object()));
+ assertEquals(lhs, lhs);
+ assertNotEquals(lhs, new Object());
Negation rhs = new Negation(SimplePredicates.newString("bar"));
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs.setOperand(SimplePredicates.newString("foo"));
- assertTrue(lhs.equals(rhs));
+ assertEquals(lhs, rhs);
}
@Test
- public void requireThatChildIsMandatoryInConstructor() {
+ void requireThatChildIsMandatoryInConstructor() {
try {
new Negation(null);
fail();
@@ -69,7 +64,7 @@ public class NegationTest {
}
@Test
- public void requireThatChildIsMandatoryInSetter() {
+ void requireThatChildIsMandatoryInSetter() {
Predicate operand = SimplePredicates.newPredicate();
Negation negation = new Negation(operand);
try {
@@ -82,7 +77,7 @@ public class NegationTest {
}
@Test
- public void requireThatChildIsIncludedInToString() {
+ void requireThatChildIsIncludedInToString() {
assertEquals("not (foo)", new Negation(SimplePredicates.newString("foo")).toString());
}
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateHashTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateHashTest.java
index 7b1b6886aa0..2db73aff6fe 100644
--- a/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateHashTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateHashTest.java
@@ -1,16 +1,16 @@
// Copyright Yahoo. 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 org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author <a href="mailto:magnarn@yahoo-inc.com">Magnar Nedland</a>
*/
public class PredicateHashTest{
@Test
- public void requireThatShortStringsGetsHashes() {
+ void requireThatShortStringsGetsHashes() {
assertHashesTo(0x82af3d1de65ec252L, "abcdefg");
assertHashesTo(0xdc50d922fb0e91d6L, "雅虎");
assertHashesTo(0x709bd6ff1a84dc14L, "country=日本");
@@ -44,7 +44,7 @@ public class PredicateHashTest{
}
@Test
- public void requireThatLongStringsGetsHashes() {
+ void requireThatLongStringsGetsHashes() {
assertHashesTo(0x79fac97d13f4cc84L, "abcdefghijklmn1234567890");
assertHashesTo(0xd7af1798f1d5de44L, "abcdefghijklmn1234567890a");
assertHashesTo(0x5a259ad887478cccL, "abcdefghijklmn1234567890ab");
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateOperatorTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateOperatorTest.java
index 2bcc62b76e0..d1e36c2b117 100644
--- a/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateOperatorTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateOperatorTest.java
@@ -1,9 +1,9 @@
// Copyright Yahoo. 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 org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Simon Thoresen Hult
@@ -11,7 +11,7 @@ import static org.junit.Assert.assertTrue;
public class PredicateOperatorTest {
@Test
- public void requireThatOperatorIsAPredicate() {
+ void requireThatOperatorIsAPredicate() {
assertTrue(Predicate.class.isAssignableFrom(PredicateOperator.class));
}
}
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateParserTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateParserTest.java
index b4b45ab198e..96c774fe8ed 100644
--- a/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateParserTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateParserTest.java
@@ -1,11 +1,9 @@
// Copyright Yahoo. 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 org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author <a href="mailto:magnarn@yahoo-inc.com">Magnar Nedland</a>
@@ -14,7 +12,7 @@ import static org.junit.Assert.fail;
public class PredicateParserTest {
@Test
- public void requireThatParseErrorThrowsException() {
+ void requireThatParseErrorThrowsException() {
try {
Predicate.fromString("a in b");
fail("Expected an exception");
@@ -24,7 +22,7 @@ public class PredicateParserTest {
}
@Test
- public void requireThatLexerErrorThrowsException() {
+ void requireThatLexerErrorThrowsException() {
try {
Predicate.fromString("a-b in [b]");
fail("Expected an exception");
@@ -34,7 +32,7 @@ public class PredicateParserTest {
}
@Test
- public void requireThatSingleValueLeafNodesParse() {
+ void requireThatSingleValueLeafNodesParse() {
assertParsesTo("a in [b]", "a in [b]");
assertParsesTo("0 in [1]", "0 in [1]");
assertParsesTo("in in [in]", "in in [in]");
@@ -44,17 +42,17 @@ public class PredicateParserTest {
assertParsesTo("string in ['!@#$%^&*()[]']", "'string' in ['!@#$%^&*()[]']");
assertParsesTo("a in [b]", "a in [b]");
assertParsesTo("string in ['foo\\\\_\"\\t\\n\\f\\rbar']",
- "string in ['foo\\\\_\\x22\\t\\n\\f\\rbar']");
+ "string in ['foo\\\\_\\x22\\t\\n\\f\\rbar']");
assertParsesTo("'\\xC3\\xB8' in [b]", "'ø' in [b]");
assertParsesTo("'\\xEF\\xBF\\xBD' in [b]", "'\\xf8' in [b]");
assertParsesTo("'\\xEF\\xBF\\xBD' in [b]", "'\\xef\\xbf\\xbd' in ['b']");
assertParsesTo("'\\xE4\\xB8\\x9C\\xE8\\xA5\\xBF' in ['\\xE8\\x87\\xAA\\xE8\\xA1\\x8C\\xE8\\xBD\\xA6']",
- "'东西' in ['自行车']");
+ "'东西' in ['自行车']");
assertParsesTo("true in [false]", "true in [false]");
}
@Test
- public void requireThatMultiValueLeafNodesParse() {
+ void requireThatMultiValueLeafNodesParse() {
assertParsesTo("a in [b]", "a in [b]");
assertParsesTo("0 in [1]", "0 in [1]");
assertParsesTo("in in [and, in]", "in in [in, and]");
@@ -62,7 +60,7 @@ public class PredicateParserTest {
}
@Test
- public void requireThatBothSingleAndDoubleQuotesWork() {
+ void requireThatBothSingleAndDoubleQuotesWork() {
assertParsesTo("a in [b]", "'a' in ['b']");
assertParsesTo("a in [b]", "\"a\" in [\"b\"]");
assertParsesTo("'a\\x27' in [b]", "'a\\'' in ['b']");
@@ -70,7 +68,7 @@ public class PredicateParserTest {
}
@Test
- public void requireThatRangeLeafNodesParse() {
+ void requireThatRangeLeafNodesParse() {
assertParsesTo("a in [0..100]", "a in [0..100]");
assertParsesTo("0 in [..100]", "0 in [..100]");
assertParsesTo("0 in [0..]", "0 in [0..]");
@@ -81,7 +79,7 @@ public class PredicateParserTest {
}
@Test
- public void requireThatRangePartitionsAreIgnored() {
+ void requireThatRangePartitionsAreIgnored() {
assertParsesTo("a in [0..100]", "a in [0..100 (a=0-99,a=100+[..0])]");
assertParsesTo("a in [-100..0]", "a in [-100..0 (a=-0-99,a=-100+[..0])]");
assertParsesTo("a in [-9223372036854775808..0]", "a in [-9223372036854775808..0 (a=-0-9223372036854775808)]");
@@ -91,57 +89,57 @@ public class PredicateParserTest {
}
@Test
- public void requireThatNotInSetWorks() {
+ void requireThatNotInSetWorks() {
assertParsesTo("a not in [b]", "a not in [b]");
}
@Test
- public void requireThatConjunctionWorks() {
+ void requireThatConjunctionWorks() {
assertParsesTo("a in [b] and c in [d]", "a in [b] and c in [d]");
assertParsesTo("a in [b] and c in [d] and e in [f]", "a in [b] and c in [d] and e in [f]");
}
@Test
- public void requireThatDisjunctionWorks() {
+ void requireThatDisjunctionWorks() {
assertParsesTo("a in [b] or c in [d]", "a in [b] or c in [d]");
assertParsesTo("a in [b] or c in [d] or e in [f]", "a in [b] or c in [d] or e in [f]");
}
@Test
- public void requireThatParenthesesWorks() {
+ void requireThatParenthesesWorks() {
assertParsesTo("a in [b] or c in [d]",
- "(a in [b]) or (c in [d])");
+ "(a in [b]) or (c in [d])");
assertParsesTo("a in [b] or c in [d] or e in [f]",
- "(((a in [b]) or c in [d]) or e in [f])");
+ "(((a in [b]) or c in [d]) or e in [f])");
assertParsesTo("(a in [b] and c in [d]) or e in [f]",
- "a in [b] and c in [d] or e in [f]");
+ "a in [b] and c in [d] or e in [f]");
assertParsesTo("a in [b] and (c in [d] or e in [f])",
- "a in [b] and (c in [d] or e in [f])");
+ "a in [b] and (c in [d] or e in [f])");
assertParsesTo("a in [b] and (c in [d] or e in [f]) and g in [h]",
- "a in [b] and (c in [d] or e in [f]) and g in [h]");
+ "a in [b] and (c in [d] or e in [f]) and g in [h]");
}
@Test
- public void requireThatNotOutsideParenthesesWorks() {
+ void requireThatNotOutsideParenthesesWorks() {
assertParsesTo("a not in [b]", "not (a in [b])");
}
@Test
- public void requireThatConjunctionsCanGetMoreThanTwoChildren() {
+ void requireThatConjunctionsCanGetMoreThanTwoChildren() {
Predicate p = Predicate.fromString("a in [b] and c in [d] and e in [f] and g in [h]");
assertTrue(p instanceof Conjunction);
- assertEquals(4, ((Conjunction)p).getOperands().size());
+ assertEquals(4, ((Conjunction) p).getOperands().size());
}
@Test
- public void requireThatDisjunctionsCanGetMoreThanTwoChildren() {
+ void requireThatDisjunctionsCanGetMoreThanTwoChildren() {
Predicate p = Predicate.fromString("a in [b] or c in [d] or e in [f] or g in [h]");
assertTrue(p instanceof Disjunction);
- assertEquals(4, ((Disjunction)p).getOperands().size());
+ assertEquals(4, ((Disjunction) p).getOperands().size());
}
@Test
- public void requireThatBooleanCanBeParsed() {
+ void requireThatBooleanCanBeParsed() {
assertParsesTo("true", "true");
assertParsesTo("false", "false");
assertParsesTo("true or false", "true or false");
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateTest.java
index 10de465f342..544403f6c9f 100644
--- a/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateTest.java
@@ -1,14 +1,14 @@
// Copyright Yahoo. 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 org.junit.jupiter.api.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 org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Simon Thoresen Hult
@@ -16,12 +16,12 @@ import static org.junit.Assert.assertTrue;
public class PredicateTest {
@Test
- public void requireThatPredicateIsCloneable() {
+ void requireThatPredicateIsCloneable() {
assertTrue(Cloneable.class.isAssignableFrom(Predicate.class));
}
@Test
- public void requireThatANDConstructsAConjunction() {
+ void requireThatANDConstructsAConjunction() {
Predicate foo = SimplePredicates.newString("foo");
Predicate bar = SimplePredicates.newString("bar");
Predicate predicate = and(foo, bar);
@@ -30,7 +30,7 @@ public class PredicateTest {
}
@Test
- public void requireThatORConstructsADisjunction() {
+ void requireThatORConstructsADisjunction() {
Predicate foo = SimplePredicates.newString("foo");
Predicate bar = SimplePredicates.newString("bar");
Predicate predicate = or(foo, bar);
@@ -39,7 +39,7 @@ public class PredicateTest {
}
@Test
- public void requireThatNOTConstructsANegation() {
+ void requireThatNOTConstructsANegation() {
Predicate foo = SimplePredicates.newString("foo");
Predicate predicate = not(foo);
assertEquals(Negation.class, predicate.getClass());
@@ -47,52 +47,52 @@ public class PredicateTest {
}
@Test
- public void requireThatFeatureBuilderCanConstructFeatureRange() {
+ void requireThatFeatureBuilderCanConstructFeatureRange() {
assertEquals(new FeatureRange("key", 6L, 9L),
- feature("key").inRange(6, 9));
+ feature("key").inRange(6, 9));
assertEquals(new Negation(new FeatureRange("key", 6L, 9L)),
- feature("key").notInRange(6, 9));
+ feature("key").notInRange(6, 9));
assertEquals(new FeatureRange("key", 7L, null),
- feature("key").greaterThan(6));
+ feature("key").greaterThan(6));
assertEquals(new FeatureRange("key", 6L, null),
- feature("key").greaterThanOrEqualTo(6));
+ feature("key").greaterThanOrEqualTo(6));
assertEquals(new FeatureRange("key", null, 5L),
- feature("key").lessThan(6));
+ feature("key").lessThan(6));
assertEquals(new FeatureRange("key", null, 9L),
- feature("key").lessThanOrEqualTo(9));
+ feature("key").lessThanOrEqualTo(9));
}
@Test
- public void requireThatFeatureBuilderCanConstructFeatureSet() {
+ void requireThatFeatureBuilderCanConstructFeatureSet() {
assertEquals(new FeatureSet("key", "valueA", "valueB"),
- feature("key").inSet("valueA", "valueB"));
+ feature("key").inSet("valueA", "valueB"));
assertEquals(new Negation(new FeatureSet("key", "valueA", "valueB")),
- feature("key").notInSet("valueA", "valueB"));
+ feature("key").notInSet("valueA", "valueB"));
}
@Test
- public void requireThatPredicatesCanBeConstructedUsingConstructors() {
+ void requireThatPredicatesCanBeConstructedUsingConstructors() {
assertEquals("country in [no, se] and age in [20..30]",
- new Conjunction(new FeatureSet("country", "no", "se"),
- new FeatureRange("age", 20L, 30L)).toString());
+ new Conjunction(new FeatureSet("country", "no", "se"),
+ new FeatureRange("age", 20L, 30L)).toString());
assertEquals("country not in [no, se] or age in [20..] or height in [..160]",
- new Disjunction(new Negation(new FeatureSet("country", "no", "se")),
- new FeatureRange("age", 20L, null),
- new FeatureRange("height", null, 160L)).toString());
+ new Disjunction(new Negation(new FeatureSet("country", "no", "se")),
+ new FeatureRange("age", 20L, null),
+ new FeatureRange("height", null, 160L)).toString());
}
@Test
- public void requireThatPredicatesCanBeBuiltUsingChainedMethodCalls() {
+ void requireThatPredicatesCanBeBuiltUsingChainedMethodCalls() {
assertEquals("country not in [no, se] or age in [20..] or height in [..160]",
- new Disjunction()
- .addOperand(new Negation(new FeatureSet("country").addValue("no").addValue("se")))
- .addOperand(new FeatureRange("age").setFromInclusive(20L))
- .addOperand(new FeatureRange("height").setToInclusive(160L))
- .toString());
+ new Disjunction()
+ .addOperand(new Negation(new FeatureSet("country").addValue("no").addValue("se")))
+ .addOperand(new FeatureRange("age").setFromInclusive(20L))
+ .addOperand(new FeatureRange("height").setToInclusive(160L))
+ .toString());
}
@Test
- public void requireThatPredicatesCanBeBuiltUsingSeparateMethodCalls() {
+ void requireThatPredicatesCanBeBuiltUsingSeparateMethodCalls() {
Conjunction conjunction = new Conjunction();
FeatureSet countrySet = new FeatureSet("country");
countrySet.addValue("no");
@@ -105,6 +105,6 @@ public class PredicateTest {
heightRange.setToInclusive(160L);
conjunction.addOperand(heightRange);
assertEquals("country in [no, se] and age in [20..] and height in [..160]",
- conjunction.toString());
+ conjunction.toString());
}
}
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateValueTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateValueTest.java
index fe5f6db1cfa..c32a36f153b 100644
--- a/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateValueTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/PredicateValueTest.java
@@ -1,9 +1,9 @@
// Copyright Yahoo. 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 org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Simon Thoresen Hult
@@ -11,7 +11,7 @@ import static org.junit.Assert.assertTrue;
public class PredicateValueTest {
@Test
- public void requireThatValueIsAPredicate() {
+ void requireThatValueIsAPredicate() {
assertTrue(Predicate.class.isAssignableFrom(PredicateValue.class));
}
}
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
index c8cd3f776c8..a40e577fae5 100644
--- 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
@@ -1,14 +1,14 @@
// Copyright Yahoo. 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 org.junit.jupiter.api.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;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Simon Thoresen Hult
@@ -16,21 +16,21 @@ import static org.junit.Assert.assertEquals;
public class PredicatesTest {
@Test
- public void requireThatApiIsUsable() {
+ void requireThatApiIsUsable() {
assertEquals(
new Disjunction(
new Conjunction(new FeatureSet("country", "de", "no"),
- new Negation(new FeatureSet("gender", "female")),
- new FeatureRange("age", 6L, 9L)),
+ 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))),
+ 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))));
+ 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));
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/RangeEdgePartitionTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/RangeEdgePartitionTest.java
index be01b1cd842..00a25e4dc49 100644
--- a/predicate-search-core/src/test/java/com/yahoo/document/predicate/RangeEdgePartitionTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/RangeEdgePartitionTest.java
@@ -1,10 +1,9 @@
// Copyright Yahoo. 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 org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author <a href="mailto:magnarn@yahoo-inc.com">Magnar Nedland</a>
@@ -12,12 +11,12 @@ import static org.junit.Assert.assertEquals;
public class RangeEdgePartitionTest {
@Test
- public void requireThatRangeEdgePartitionIsAValue() {
+ void requireThatRangeEdgePartitionIsAValue() {
assertTrue(PredicateValue.class.isAssignableFrom(RangeEdgePartition.class));
}
@Test
- public void requireThatConstructorsWork() {
+ void requireThatConstructorsWork() {
RangeEdgePartition part = new RangeEdgePartition("foo=10", 10, 0, -1);
assertEquals("foo=10", part.getLabel());
assertEquals(0, part.getLowerBound());
@@ -25,7 +24,7 @@ public class RangeEdgePartitionTest {
}
@Test
- public void requireThatCloneIsImplemented() throws CloneNotSupportedException {
+ void requireThatCloneIsImplemented() throws CloneNotSupportedException {
RangeEdgePartition node1 = new RangeEdgePartition("foo=10", 10, 0, 0);
RangeEdgePartition node2 = node1.clone();
assertEquals(node1, node2);
@@ -33,29 +32,29 @@ public class RangeEdgePartitionTest {
}
@Test
- public void requireThatHashCodeIsImplemented() {
+ void requireThatHashCodeIsImplemented() {
assertEquals(new RangeEdgePartition("foo=-10", 10, 2, 3).hashCode(),
new RangeEdgePartition("foo=-10", 10, 2, 3).hashCode());
}
@Test
- public void requireThatEqualsIsImplemented() {
+ void requireThatEqualsIsImplemented() {
RangeEdgePartition lhs = new RangeEdgePartition("foo=10", 10, 5, 10);
- assertTrue(lhs.equals(lhs));
- assertFalse(lhs.equals(new Object()));
+ assertEquals(lhs, lhs);
+ assertNotEquals(lhs, new Object());
RangeEdgePartition rhs = new RangeEdgePartition("foo=20", 20, 0, 0);
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs = new RangeEdgePartition("foo=10", 10, 5, 10);
- assertTrue(lhs.equals(rhs));
- assertFalse(lhs.equals(new RangeEdgePartition("foo=10", 10, 5, 11)));
- assertFalse(lhs.equals(new RangeEdgePartition("foo=10", 10, 6, 10)));
- assertFalse(lhs.equals(new RangeEdgePartition("foo=10", 11, 5, 10)));
- assertFalse(lhs.equals(new RangeEdgePartition("foo=11", 10, 5, 10)));
+ assertEquals(lhs, rhs);
+ assertNotEquals(lhs, new RangeEdgePartition("foo=10", 10, 5, 11));
+ assertNotEquals(lhs, new RangeEdgePartition("foo=10", 10, 6, 10));
+ assertNotEquals(lhs, new RangeEdgePartition("foo=10", 11, 5, 10));
+ assertNotEquals(lhs, new RangeEdgePartition("foo=11", 10, 5, 10));
}
@Test
- public void requireThatKeyIsEscapedInToString() {
+ void requireThatKeyIsEscapedInToString() {
assertEquals("foo=10+[2..3]", new RangeEdgePartition("foo=10", 10, 2, 3).toString());
assertEquals("'\\foo=10'+[2..3]", new RangeEdgePartition("\foo=10", 10, 2, 3).toString());
assertEquals("'\\x27foo\\x27=10'+[2..3]", new RangeEdgePartition("'foo'=10", 10, 2, 3).toString());
diff --git a/predicate-search-core/src/test/java/com/yahoo/document/predicate/RangePartitionTest.java b/predicate-search-core/src/test/java/com/yahoo/document/predicate/RangePartitionTest.java
index c11a7fb433f..ea191c705a5 100644
--- a/predicate-search-core/src/test/java/com/yahoo/document/predicate/RangePartitionTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/document/predicate/RangePartitionTest.java
@@ -1,10 +1,9 @@
// Copyright Yahoo. 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 org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author <a href="mailto:magnarn@yahoo-inc.com">Magnar Nedland</a>
@@ -12,12 +11,12 @@ import static org.junit.Assert.assertEquals;
public class RangePartitionTest {
@Test
- public void requireThatRangePartitionIsAValue() {
+ void requireThatRangePartitionIsAValue() {
assertTrue(PredicateValue.class.isAssignableFrom(RangePartition.class));
}
@Test
- public void requireThatConstructorsWork() {
+ void requireThatConstructorsWork() {
RangePartition part = new RangePartition("foo=10-19");
assertEquals("foo=10-19", part.getLabel());
part = new RangePartition("foo", 10, 19, false);
@@ -27,7 +26,7 @@ public class RangePartitionTest {
}
@Test
- public void requireThatCloneIsImplemented() throws CloneNotSupportedException {
+ void requireThatCloneIsImplemented() throws CloneNotSupportedException {
RangePartition node1 = new RangePartition("foo=300-399");
RangePartition node2 = node1.clone();
assertEquals(node1, node2);
@@ -35,24 +34,24 @@ public class RangePartitionTest {
}
@Test
- public void requireThatHashCodeIsImplemented() {
+ void requireThatHashCodeIsImplemented() {
assertEquals(new RangePartition("foo=0-9").hashCode(), new RangePartition("foo=0-9").hashCode());
}
@Test
- public void requireThatEqualsIsImplemented() {
+ void requireThatEqualsIsImplemented() {
RangePartition lhs = new RangePartition("foo=10-19");
- assertTrue(lhs.equals(lhs));
- assertFalse(lhs.equals(new Object()));
+ assertEquals(lhs, lhs);
+ assertNotEquals(lhs, new Object());
RangePartition rhs = new RangePartition("bar=1000-1999");
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs = new RangePartition("foo=10-19");
- assertTrue(lhs.equals(rhs));
+ assertEquals(lhs, rhs);
}
@Test
- public void requireThatKeyIsEscapedInToString() {
+ void requireThatKeyIsEscapedInToString() {
assertEquals("foo=10-19", new RangePartition("foo=10-19").toString());
assertEquals("'\\foo=10-19'", new RangePartition("\foo=10-19").toString());
assertEquals("'\\x27foo\\x27=10-19'", new RangePartition("'foo'=10-19").toString());