Search in sources :

Example 16 with ThrowingRunnable

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

the class TestFilterExp method durableDeleteExcept.

@Test
public void durableDeleteExcept() {
    if (!args.enterprise) {
        return;
    }
    WritePolicy policy = new WritePolicy();
    policy.filterExp = Exp.build(Exp.eq(Exp.intBin(binA), Exp.val(1)));
    policy.failOnFilteredOut = true;
    policy.durableDelete = 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());
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) WritePolicy(com.aerospike.client.policy.WritePolicy) ThrowingRunnable(org.junit.function.ThrowingRunnable) Test(org.junit.Test)

Example 17 with ThrowingRunnable

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

the class TestFilterExp method filterLog.

@Test
public void filterLog() {
    String name = "x";
    Policy policy = new Policy();
    policy.filterExp = Exp.build(Exp.let(Exp.def(name, Exp.log(Exp.floatBin(binB), Exp.val(2.0))), Exp.and(Exp.ge(Exp.var(name), Exp.val(1.1374)), Exp.le(Exp.var(name), Exp.val(1.1376)))));
    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 18 with ThrowingRunnable

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

the class TestFilterExp method filterLscan.

@Test
public void filterLscan() {
    Policy policy = new Policy();
    policy.filterExp = Exp.build(Exp.not(Exp.eq(Exp.lscan(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.lscan(Exp.intBin(binA), Exp.val(true)), Exp.val(63)));
    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 19 with ThrowingRunnable

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

the class TestFilterExp method filterExclusive.

@Test
public void filterExclusive() {
    Policy policy = new Policy();
    policy.filterExp = Exp.build(Exp.exclusive(Exp.eq(Exp.intBin(binA), Exp.val(1)), Exp.eq(Exp.intBin(binD), 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());
    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 20 with ThrowingRunnable

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

the class TestFilterExp method filterAddInt.

@Test
public void filterAddInt() {
    Policy policy = new Policy();
    policy.filterExp = Exp.build(Exp.eq(Exp.add(Exp.intBin(binA), Exp.intBin(binD), Exp.val(1)), 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)

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