use of com.apple.foundationdb.record.metadata.ExpressionTestsProto.TestScalarFieldAccess in project fdb-record-layer by FoundationDB.
the class QueryExpressionTest method testAnd.
@Test
public void testAnd() throws Exception {
final TestScalarFieldAccess val = TestScalarFieldAccess.newBuilder().build();
assertNull(evaluate(and(TRUE, NULL), val));
// Use equals here, because assertTrue/False would throw nullPointerException if and() returns null
assertEquals(true, evaluate(and(TRUE, TRUE), val));
assertEquals(false, evaluate(and(TRUE, FALSE), val));
assertEquals(false, evaluate(and(NULL, FALSE), val));
assertNull(evaluate(and(NULL, TRUE), val));
}
use of com.apple.foundationdb.record.metadata.ExpressionTestsProto.TestScalarFieldAccess in project fdb-record-layer by FoundationDB.
the class QueryExpressionTest method testParameterComparison.
protected void testParameterComparison(String name, String field, Object val1, Comparisons.Type type, Object val2, Boolean expected) throws Exception {
if (type.isUnary()) {
assertThrows(name, RecordCoreException.class, () -> new Comparisons.ParameterComparison(type, "fooParam"));
return;
}
final TestScalarFieldAccess rec = createRecord(field, val1).build();
try {
final Comparisons.Comparison comparison = new Comparisons.ParameterComparison(type, "fooParam");
final QueryComponent qc = new FieldWithComparison(field, comparison);
final Bindings bindings = Bindings.newBuilder().set("fooParam", val2).build();
if (val1 != null && val2 != null && (type == Comparisons.Type.IN && !(val2 instanceof List) || type.name().startsWith("TEXT_"))) {
assertThrows(name, RecordCoreException.class, () -> evaluate(qc, bindings, rec));
} else {
assertEquals(expected, evaluate(qc, bindings, rec), name);
}
} catch (Exception e) {
throw new AssertionError(name + " Threw: " + e.getMessage(), e);
}
}
Aggregations