Search in sources :

Example 31 with ThrowingRunnable

use of org.junit.function.ThrowingRunnable in project aerospike-client-java by aerospike.

the class TestFilterExp method filterIntOr.

@Test
public void filterIntOr() {
    Policy policy = new Policy();
    policy.filterExp = Exp.build(Exp.not(Exp.and(Exp.eq(Exp.intOr(Exp.intBin(binA), Exp.val(0)), Exp.val(1)), Exp.eq(Exp.intOr(Exp.intBin(binA), Exp.val(0xFF)), Exp.val(0xFF)))));
    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.intOr(Exp.intBin(binA), Exp.val(0)), Exp.val(1)), Exp.eq(Exp.intOr(Exp.intBin(binA), Exp.val(0xFF)), Exp.val(0xFF))));
    Record r = client.get(policy, keyA);
    assertBinEqual(keyA, r, binA, 1);
}
Also used : Policy(com.aerospike.client.policy.Policy) BatchPolicy(com.aerospike.client.policy.BatchPolicy) WritePolicy(com.aerospike.client.policy.WritePolicy) AerospikeException(com.aerospike.client.AerospikeException) Record(com.aerospike.client.Record) ThrowingRunnable(org.junit.function.ThrowingRunnable) Test(org.junit.Test)

Example 32 with ThrowingRunnable

use of org.junit.function.ThrowingRunnable in project aerospike-client-java by aerospike.

the class TestFilterExp method filterBitCount.

@Test
public void filterBitCount() {
    Policy policy = new Policy();
    policy.filterExp = Exp.build(Exp.not(Exp.eq(Exp.count(Exp.intBin(binA)), 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.count(Exp.intBin(binA)), Exp.val(1)));
    Record r = client.get(policy, keyA);
    assertBinEqual(keyA, r, binA, 1);
}
Also used : Policy(com.aerospike.client.policy.Policy) BatchPolicy(com.aerospike.client.policy.BatchPolicy) WritePolicy(com.aerospike.client.policy.WritePolicy) AerospikeException(com.aerospike.client.AerospikeException) Record(com.aerospike.client.Record) ThrowingRunnable(org.junit.function.ThrowingRunnable) Test(org.junit.Test)

Example 33 with ThrowingRunnable

use of org.junit.function.ThrowingRunnable in project aerospike-client-java by aerospike.

the class TestFilterExp method filterRshift.

@Test
public void filterRshift() {
    Policy policy = new Policy();
    policy.filterExp = Exp.build(Exp.not(Exp.eq(Exp.rshift(Exp.intBin(binE), Exp.val(62)), Exp.val(3))));
    policy.failOnFilteredOut = true;
    AerospikeException ae = assertThrows(AerospikeException.class, new ThrowingRunnable() {

        public void run() {
            client.get(policy, keyB);
        }
    });
    assertEquals(ResultCode.FILTERED_OUT, ae.getResultCode());
    policy.filterExp = Exp.build(Exp.eq(Exp.rshift(Exp.intBin(binE), Exp.val(62)), Exp.val(3)));
    Record r = client.get(policy, keyB);
    assertBinEqual(keyB, r, binE, -2);
}
Also used : Policy(com.aerospike.client.policy.Policy) BatchPolicy(com.aerospike.client.policy.BatchPolicy) WritePolicy(com.aerospike.client.policy.WritePolicy) AerospikeException(com.aerospike.client.AerospikeException) Record(com.aerospike.client.Record) ThrowingRunnable(org.junit.function.ThrowingRunnable) Test(org.junit.Test)

Example 34 with ThrowingRunnable

use of org.junit.function.ThrowingRunnable in project aerospike-client-java by aerospike.

the class TestFilterExp method filterDiv.

@Test
public void filterDiv() {
    Policy policy = new Policy();
    policy.filterExp = Exp.build(Exp.eq(Exp.div(Exp.val(8), 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);
}
Also used : Policy(com.aerospike.client.policy.Policy) BatchPolicy(com.aerospike.client.policy.BatchPolicy) WritePolicy(com.aerospike.client.policy.WritePolicy) AerospikeException(com.aerospike.client.AerospikeException) Record(com.aerospike.client.Record) ThrowingRunnable(org.junit.function.ThrowingRunnable) Test(org.junit.Test)

Example 35 with ThrowingRunnable

use of org.junit.function.ThrowingRunnable in project aerospike-client-java by aerospike.

the class TestFilterExp method filterSub.

@Test
public void filterSub() {
    Policy policy = new Policy();
    policy.filterExp = Exp.build(Exp.eq(Exp.sub(Exp.val(1), Exp.intBin(binA), Exp.intBin(binD)), 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);
}
Also used : Policy(com.aerospike.client.policy.Policy) BatchPolicy(com.aerospike.client.policy.BatchPolicy) WritePolicy(com.aerospike.client.policy.WritePolicy) AerospikeException(com.aerospike.client.AerospikeException) Record(com.aerospike.client.Record) ThrowingRunnable(org.junit.function.ThrowingRunnable) Test(org.junit.Test)

Aggregations

ThrowingRunnable (org.junit.function.ThrowingRunnable)49 Test (org.junit.Test)48 AerospikeException (com.aerospike.client.AerospikeException)41 WritePolicy (com.aerospike.client.policy.WritePolicy)34 Record (com.aerospike.client.Record)32 BatchPolicy (com.aerospike.client.policy.BatchPolicy)28 Policy (com.aerospike.client.policy.Policy)28 Expression (com.aerospike.client.exp.Expression)5 Bin (com.aerospike.client.Bin)3 Key (com.aerospike.client.Key)2 Options (com.github.jknack.handlebars.Options)2 RandomTestUtils.randomString (uk.nhs.digital.test.util.RandomTestUtils.randomString)2 Drawable (android.graphics.drawable.Drawable)1 Handler (android.os.Handler)1 Version (com.aerospike.client.util.Version)1 Matchers.anyDrawable (com.bumptech.glide.test.Matchers.anyDrawable)1 Migration (com.google.copybara.config.Migration)1 GitLogEntry (com.google.copybara.git.GitRepository.GitLogEntry)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 MarkdownConversionException (uk.nhs.digital.common.components.apispecification.commonmark.MarkdownConversionException)1