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