use of org.junit.function.ThrowingRunnable in project aerospike-client-java by aerospike.
the class TestFilterExp method filterAbs.
@Test
public void filterAbs() {
Policy policy = new Policy();
policy.filterExp = Exp.build(Exp.eq(Exp.abs(Exp.intBin(binE)), Exp.val(2)));
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 filterIntXor.
@Test
public void filterIntXor() {
Policy policy = new Policy();
policy.filterExp = Exp.build(Exp.not(Exp.and(Exp.eq(Exp.intXor(Exp.intBin(binA), Exp.val(0)), Exp.val(1)), Exp.eq(Exp.intXor(Exp.intBin(binA), Exp.val(0xFF)), Exp.val(0xFE)))));
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.and(Exp.eq(Exp.intXor(Exp.intBin(binA), Exp.val(0)), Exp.val(1)), Exp.eq(Exp.intXor(Exp.intBin(binA), Exp.val(0xFF)), Exp.val(0xFE))));
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 deleteExcept.
@Test
public void deleteExcept() {
WritePolicy policy = new WritePolicy();
policy.filterExp = Exp.build(Exp.eq(Exp.intBin(binA), Exp.val(1)));
policy.failOnFilteredOut = true;
client.delete(policy, keyA);
AerospikeException ae = assertThrows(AerospikeException.class, new ThrowingRunnable() {
public void run() {
client.delete(policy, keyB);
}
});
assertEquals(ResultCode.FILTERED_OUT, ae.getResultCode());
}
use of org.junit.function.ThrowingRunnable in project aerospike-client-java by aerospike.
the class TestFilterExp method filterAddFloat.
@Test
public void filterAddFloat() {
String name = "val";
Policy policy = new Policy();
policy.filterExp = Exp.build(Exp.let(Exp.def(name, Exp.add(Exp.floatBin(binB), Exp.val(1.1))), Exp.and(Exp.ge(Exp.var(name), Exp.val(3.2999)), Exp.le(Exp.var(name), Exp.val(3.3001)))));
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 filterToInt.
@Test
public void filterToInt() {
Policy policy = new Policy();
policy.filterExp = Exp.build(Exp.eq(Exp.toInt(Exp.floatBin(binB)), Exp.val(2)));
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