Search in sources :

Example 6 with ThrowingRunnable

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);
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) Expression(com.aerospike.client.exp.Expression) Record(com.aerospike.client.Record) ThrowingRunnable(org.junit.function.ThrowingRunnable) Test(org.junit.Test)

Example 7 with ThrowingRunnable

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);
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) Expression(com.aerospike.client.exp.Expression) Record(com.aerospike.client.Record) ThrowingRunnable(org.junit.function.ThrowingRunnable) Test(org.junit.Test)

Example 8 with ThrowingRunnable

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);
}
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 9 with ThrowingRunnable

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);
}
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 10 with ThrowingRunnable

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);
}
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