use of com.apple.foundationdb.record.metadata.ExpressionTestsProto.TestScalarFieldAccess in project fdb-record-layer by FoundationDB.
the class QueryExpressionTest method testOneOfThemEqualsValue.
@ParameterizedTest(name = "testOneOfThemEqualsValue [emptyMode = {0}]")
@EnumSource(Field.OneOfThemEmptyMode.class)
public void testOneOfThemEqualsValue(Field.OneOfThemEmptyMode emptyMode) throws Exception {
final TestScalarFieldAccess oneRepeatedValue = TestScalarFieldAccess.newBuilder().addRepeatMe("fishes").build();
final QueryComponent component = field("repeat_me").oneOfThem(emptyMode).equalsValue("fishes");
component.validate(TestScalarFieldAccess.getDescriptor());
final Boolean eval = evaluate(component, oneRepeatedValue);
assertEquals(Boolean.TRUE, eval);
}
use of com.apple.foundationdb.record.metadata.ExpressionTestsProto.TestScalarFieldAccess in project fdb-record-layer by FoundationDB.
the class QueryExpressionTest method testOr.
@Test
public void testOr() throws Exception {
final TestScalarFieldAccess val = TestScalarFieldAccess.newBuilder().build();
assertNull(evaluate(or(FALSE, NULL), val));
// Use equals here, because assertTrue/False would throw nullPointerException if or() returns null
assertEquals(true, evaluate(or(FALSE, TRUE), val));
assertEquals(true, evaluate(or(TRUE, FALSE), val));
assertEquals(false, evaluate(or(FALSE, FALSE), val));
assertEquals(true, evaluate(or(NULL, TRUE), val));
}
use of com.apple.foundationdb.record.metadata.ExpressionTestsProto.TestScalarFieldAccess in project fdb-record-layer by FoundationDB.
the class QueryExpressionTest method testOneOfThemEqualsNoValues.
@ParameterizedTest(name = "testOneOfThemEqualsNoValues [emptyMode = {0}]")
@EnumSource(Field.OneOfThemEmptyMode.class)
public void testOneOfThemEqualsNoValues(Field.OneOfThemEmptyMode emptyMode) throws Exception {
final TestScalarFieldAccess noRepeatedValues = TestScalarFieldAccess.newBuilder().build();
final QueryComponent component = field("repeat_me").oneOfThem(emptyMode).equalsValue("fishes");
component.validate(TestScalarFieldAccess.getDescriptor());
final Boolean eval = evaluate(component, noRepeatedValues);
assertEquals(emptyMode == Field.OneOfThemEmptyMode.EMPTY_UNKNOWN ? null : Boolean.FALSE, eval);
}
use of com.apple.foundationdb.record.metadata.ExpressionTestsProto.TestScalarFieldAccess in project fdb-record-layer by FoundationDB.
the class QueryExpressionTest method testNot.
@Test
public void testNot() throws Exception {
final TestScalarFieldAccess val = TestScalarFieldAccess.newBuilder().build();
assertNull(evaluate(not(NULL), val));
assertEquals(true, evaluate(not(FALSE), val));
assertEquals(false, evaluate(not(TRUE), val));
}
use of com.apple.foundationdb.record.metadata.ExpressionTestsProto.TestScalarFieldAccess in project fdb-record-layer by FoundationDB.
the class QueryExpressionTest method testParameterComparisonsSimple.
@Test
public void testParameterComparisonsSimple() throws Exception {
final TestScalarFieldAccess rec = TestScalarFieldAccess.newBuilder().setField("abc").build();
final QueryComponent equalsP1 = new FieldWithComparison("field", new Comparisons.ParameterComparison(Comparisons.Type.EQUALS, "p1"));
final QueryComponent notEqualsP2 = new FieldWithComparison("field", new Comparisons.ParameterComparison(Comparisons.Type.NOT_EQUALS, "p2"));
final Bindings b1 = Bindings.newBuilder().set("p1", "abc").set("p2", "xyz").build();
assertTrue(evaluate(equalsP1, b1, rec));
assertTrue(evaluate(notEqualsP2, b1, rec));
final Bindings b2 = Bindings.newBuilder().set("p1", "foo").set("p2", "bar").build();
assertFalse(evaluate(equalsP1, b2, rec));
assertTrue(evaluate(notEqualsP2, b2, rec));
}
Aggregations