/** * Add the specified {@code timestamp} to the {@link Criteria} that is * building. * * @param timestamp * @return the builder */ public TimestampState at(Timestamp timestamp) { criteria.add(new TimestampSymbol(timestamp.getMicros())); return new TimestampState(criteria); }
@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); }
@Test public void testTimestampPinningSomeTimestamps() { Criteria criteria = Criteria.where().key("name") .operator(Operator.EQUALS).value("Jeff Nelson").and() .group(Criteria.where().key("company").operator(Operator.EQUALS) .value("Cinchapi").at(Timestamp.now()).or() .key("company").operator(Operator.EQUALS) .value("Blavity")) .build(); Timestamp timestamp = Timestamp.now(); criteria = criteria.at(timestamp); List<Symbol> symbols = Parsing.groupExpressions(criteria.getSymbols()); symbols.forEach((symbol) -> { if(symbol instanceof Expression) { Expression expression = (Expression) symbol; Assert.assertEquals(expression.raw().timestamp(), timestamp.getMicros()); } }); }