use of org.junit.function.ThrowingRunnable in project aerospike-client-java by aerospike.
the class TestFilterExp method filterRscan.
@Test
public void filterRscan() {
Policy policy = new Policy();
policy.filterExp = Exp.build(Exp.not(Exp.eq(Exp.rscan(Exp.intBin(binA), Exp.val(true)), Exp.val(63))));
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.rscan(Exp.intBin(binA), Exp.val(true)), Exp.val(63)));
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 filterCond.
@Test
public void filterCond() {
Policy policy = new Policy();
policy.filterExp = Exp.build(Exp.not(Exp.eq(Exp.cond(Exp.eq(Exp.intBin(binA), Exp.val(0)), Exp.add(Exp.intBin(binD), Exp.intBin(binE)), Exp.eq(Exp.intBin(binA), Exp.val(1)), Exp.sub(Exp.intBin(binD), Exp.intBin(binE)), Exp.eq(Exp.intBin(binA), Exp.val(2)), Exp.mul(Exp.intBin(binD), Exp.intBin(binE)), Exp.val(-1)), 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());
policy.filterExp = Exp.build(Exp.eq(Exp.cond(Exp.eq(Exp.intBin(binA), Exp.val(0)), Exp.add(Exp.intBin(binD), Exp.intBin(binE)), Exp.eq(Exp.intBin(binA), Exp.val(1)), Exp.sub(Exp.intBin(binD), Exp.intBin(binE)), Exp.eq(Exp.intBin(binA), Exp.val(2)), Exp.mul(Exp.intBin(binD), Exp.intBin(binE)), Exp.val(-1)), Exp.val(2)));
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 filterIntAnd.
@Test
public void filterIntAnd() {
Policy policy = new Policy();
policy.filterExp = Exp.build(Exp.not(Exp.and(Exp.eq(Exp.intAnd(Exp.intBin(binA), Exp.val(0)), Exp.val(0)), Exp.eq(Exp.intAnd(Exp.intBin(binA), Exp.val(0xFFFF)), 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.and(Exp.eq(Exp.intAnd(Exp.intBin(binA), Exp.val(0)), Exp.val(0)), Exp.eq(Exp.intAnd(Exp.intBin(binA), Exp.val(0xFFFF)), 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 operateWriteExcept.
@Test
public void operateWriteExcept() {
WritePolicy policy = new WritePolicy();
policy.filterExp = Exp.build(Exp.eq(Exp.intBin(binA), Exp.val(1)));
policy.failOnFilteredOut = true;
Bin bin = new Bin(binA, 3);
client.operate(policy, keyA, Operation.put(bin), Operation.get(binA));
AerospikeException ae = assertThrows(AerospikeException.class, new ThrowingRunnable() {
public void run() {
client.operate(policy, keyB, Operation.put(bin), Operation.get(binA));
}
});
assertEquals(ResultCode.FILTERED_OUT, ae.getResultCode());
}
use of org.junit.function.ThrowingRunnable in project aerospike-client-java by aerospike.
the class TestFilterExp method operateReadExcept.
@Test
public void operateReadExcept() {
WritePolicy policy = new WritePolicy();
policy.filterExp = Exp.build(Exp.eq(Exp.intBin(binA), Exp.val(1)));
policy.failOnFilteredOut = true;
client.operate(policy, keyA, Operation.get(binA));
AerospikeException ae = assertThrows(AerospikeException.class, new ThrowingRunnable() {
public void run() {
client.operate(policy, keyB, Operation.get(binA));
}
});
assertEquals(ResultCode.FILTERED_OUT, ae.getResultCode());
}
Aggregations