Search in sources :

Example 1 with Criteria

use of com.cinchapi.concourse.lang.Criteria in project concourse by cinchapi.

the class FindCriteriaTest method testFindCriteriaTimestampValueBetweenOperator.

@Test
public void testFindCriteriaTimestampValueBetweenOperator() {
    Timestamp a = Timestamp.now();
    Timestamp b = Timestamp.now();
    Timestamp c = Timestamp.now();
    Timestamp d = Timestamp.now();
    Timestamp e = Timestamp.now();
    client.add("foo", b, 1);
    client.add("foo", c, 2);
    client.add("foo", e, 3);
    Criteria criteria = Criteria.where().key("foo").operator(Operator.BETWEEN).value(a).value(d);
    Assert.assertEquals(ImmutableSet.of(1L, 2L), client.find(criteria));
}
Also used : Criteria(com.cinchapi.concourse.lang.Criteria) ConcourseIntegrationTest(com.cinchapi.concourse.test.ConcourseIntegrationTest) Test(org.junit.Test)

Example 2 with Criteria

use of com.cinchapi.concourse.lang.Criteria in project concourse by cinchapi.

the class ComplexTObjectTest method testCachedObject.

@Test
public void testCachedObject() {
    Criteria criteria = Criteria.where().key(Random.getString()).operator(Operator.EQUALS).value(Random.getObject()).build();
    TCriteria expected = Language.translateToThriftCriteria(criteria);
    ComplexTObject complex = ComplexTObject.fromJavaObject(expected);
    TCriteria cachedObj = complex.getJavaObject();
    // check if it is same reference
    if (cachedObj != complex.getJavaObject()) {
        Assert.fail();
    }
}
Also used : Criteria(com.cinchapi.concourse.lang.Criteria) Test(org.junit.Test)

Example 3 with Criteria

use of com.cinchapi.concourse.lang.Criteria in project concourse by cinchapi.

the class ComplexTObjectTest method testSerializeTCriteria.

@Test
public void testSerializeTCriteria() {
    Criteria criteria = Criteria.where().key(Random.getString()).operator(Operator.EQUALS).value(Random.getObject()).build();
    TCriteria expected = Language.translateToThriftCriteria(criteria);
    ComplexTObject complex = ComplexTObject.fromJavaObject(expected);
    Assert.assertEquals(expected, complex.getJavaObject());
}
Also used : Criteria(com.cinchapi.concourse.lang.Criteria) Test(org.junit.Test)

Example 4 with Criteria

use of com.cinchapi.concourse.lang.Criteria in project concourse by cinchapi.

the class ComplexTObjectTest method testTCriteriaByteBuffer.

@Test
public void testTCriteriaByteBuffer() {
    Criteria source = Criteria.where().key(Random.getString()).operator(Operator.EQUALS).value(Random.getObject()).build();
    ComplexTObject expected = ComplexTObject.fromJavaObject(source);
    ByteBuffer buffer = expected.toByteBuffer();
    ComplexTObject actual = ComplexTObject.fromByteBuffer(buffer);
    Assert.assertEquals(expected, actual);
}
Also used : Criteria(com.cinchapi.concourse.lang.Criteria) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 5 with Criteria

use of com.cinchapi.concourse.lang.Criteria in project concourse by cinchapi.

the class ComplexTObjectTest method testComplexTObjectBinaryFormat.

@Test
public void testComplexTObjectBinaryFormat() {
    Criteria criteria = Criteria.where().key("name").operator(Operator.EQUALS).value("jeff").at(Timestamp.now()).and().key("comapny").operator(Operator.EQUALS).value("cinchapi").at(Timestamp.now()).build();
    TCriteria tcriteria = Language.translateToThriftCriteria(criteria);
    ComplexTObject expected = ComplexTObject.fromJavaObject(tcriteria);
    ComplexTObject actual = ComplexTObject.fromByteBuffer(expected.toByteBuffer());
    Assert.assertEquals(expected, actual);
}
Also used : Criteria(com.cinchapi.concourse.lang.Criteria) Test(org.junit.Test)

Aggregations

Criteria (com.cinchapi.concourse.lang.Criteria)11 Test (org.junit.Test)10 ConcourseIntegrationTest (com.cinchapi.concourse.test.ConcourseIntegrationTest)6 ConditionTree (com.cinchapi.ccl.syntax.ConditionTree)1 Association (com.cinchapi.common.collect.Association)1 Tag (com.cinchapi.concourse.Tag)1 TCriteria (com.cinchapi.concourse.thrift.TCriteria)1 TOrder (com.cinchapi.concourse.thrift.TOrder)1 ByteBuffer (java.nio.ByteBuffer)1 Collection (java.util.Collection)1