use of org.junit.function.ThrowingRunnable in project aerospike-client-java by aerospike.
the class TestExpOperation method expReturnsUnknown.
@Test
public void expReturnsUnknown() {
Expression exp = Exp.build(Exp.cond(Exp.eq(Exp.intBin(binC), Exp.val(5)), Exp.unknown(), Exp.binExists(binA), Exp.val(5), Exp.unknown()));
AerospikeException ae = assertThrows(AerospikeException.class, new ThrowingRunnable() {
public void run() {
client.operate(null, keyA, ExpOperation.write(binC, exp, ExpWriteFlags.DEFAULT), Operation.get(binC));
}
});
assertEquals(ResultCode.OP_NOT_APPLICABLE, ae.getResultCode());
Record record = client.operate(null, keyA, ExpOperation.write(binC, exp, ExpWriteFlags.EVAL_NO_FAIL), Operation.get(binC));
assertRecordFound(keyA, record);
// System.out.println(record);
List<?> results = record.getList(binC);
Object val = results.get(0);
assertEquals(null, val);
val = results.get(1);
assertEquals(null, val);
}
use of org.junit.function.ThrowingRunnable in project aerospike-client-java by aerospike.
the class TestExpOperation method expReadOnWriteEvalError.
@Test
public void expReadOnWriteEvalError() {
Expression wexp = Exp.build(Exp.intBin(binD));
Expression rexp = Exp.build(Exp.intBin(binA));
Record record = client.operate(null, keyA, ExpOperation.write(binD, wexp, ExpWriteFlags.DEFAULT), ExpOperation.read(expVar, rexp, ExpReadFlags.DEFAULT));
assertRecordFound(keyA, record);
// System.out.println(record);
AerospikeException ae = assertThrows(AerospikeException.class, new ThrowingRunnable() {
public void run() {
client.operate(null, keyB, ExpOperation.write(binD, wexp, ExpWriteFlags.DEFAULT), ExpOperation.read(expVar, rexp, ExpReadFlags.DEFAULT));
}
});
assertEquals(ResultCode.OP_NOT_APPLICABLE, ae.getResultCode());
// Add NO_FAIL.
record = client.operate(null, keyB, ExpOperation.read(expVar, rexp, ExpReadFlags.EVAL_NO_FAIL));
assertRecordFound(keyB, record);
// System.out.println(record);
}
use of org.junit.function.ThrowingRunnable in project aerospike-client-java by aerospike.
the class TestFilterExp method filterMax.
@Test
public void filterMax() {
Policy policy = new Policy();
policy.filterExp = Exp.build(Exp.not(Exp.eq(Exp.max(Exp.intBin(binA), Exp.intBin(binD), Exp.intBin(binE)), Exp.val(1))));
policy.failOnFilteredOut = true;
AerospikeException ae = assertThrows(AerospikeException.class, new ThrowingRunnable() {
public void run() {
client.get(policy, keyA);
}
});
assertEquals(ResultCode.FILTERED_OUT, ae.getResultCode());
policy.filterExp = Exp.build(Exp.eq(Exp.max(Exp.intBin(binA), Exp.intBin(binD), Exp.intBin(binE)), Exp.val(1)));
Record r = client.get(policy, keyA);
assertBinEqual(keyA, r, binA, 1);
}
use of org.junit.function.ThrowingRunnable in project aerospike-client-java by aerospike.
the class TestFilterExp method filterMul.
@Test
public void filterMul() {
Policy policy = new Policy();
policy.filterExp = Exp.build(Exp.eq(Exp.mul(Exp.val(2), Exp.intBin(binA), Exp.intBin(binD)), Exp.val(4)));
policy.failOnFilteredOut = true;
AerospikeException ae = assertThrows(AerospikeException.class, new ThrowingRunnable() {
public void run() {
client.get(policy, keyA);
}
});
assertEquals(ResultCode.FILTERED_OUT, ae.getResultCode());
Record r = client.get(policy, keyB);
assertBinEqual(keyA, r, binA, 2);
}
use of org.junit.function.ThrowingRunnable in project aerospike-client-java by aerospike.
the class TestFilterExp method filterCeil.
@Test
public void filterCeil() {
Policy policy = new Policy();
policy.filterExp = Exp.build(Exp.eq(Exp.ceil(Exp.floatBin(binB)), Exp.val(3.0)));
policy.failOnFilteredOut = true;
AerospikeException ae = assertThrows(AerospikeException.class, new ThrowingRunnable() {
public void run() {
client.get(policy, keyA);
}
});
assertEquals(ResultCode.FILTERED_OUT, ae.getResultCode());
Record r = client.get(policy, keyB);
assertBinEqual(keyA, r, binA, 2);
}
Aggregations