use of org.bson.types.BSONTimestamp in project camel by apache.
the class MongoDBTailTrackingStrategyTest method testExtractLastValForTimestamp.
@Test
public void testExtractLastValForTimestamp() throws Exception {
DBObject o = mock(DBObject.class);
final int lastVal = 1483701465;
when(o.get(INCREASING_FIELD_NAME)).thenReturn(new BSONTimestamp(lastVal, 1));
Object res = MongoDBTailTrackingEnum.TIMESTAMP.extractLastVal(o, INCREASING_FIELD_NAME);
assertThat(res, is(lastVal));
}
use of org.bson.types.BSONTimestamp in project camel by apache.
the class MongoDBTailTrackingStrategyTest method testExtracCreateQueryForTimestamp.
@Test
public void testExtracCreateQueryForTimestamp() throws Exception {
final int lastVal = 1483701465;
BasicDBObject basicDBObject = MongoDBTailTrackingEnum.TIMESTAMP.createQuery(lastVal, INCREASING_FIELD_NAME);
final Object actual = basicDBObject.get(INCREASING_FIELD_NAME);
assertThat(actual, is(notNullValue()));
assertThat(actual instanceof BasicDBObject, is(true));
assertThat(((BasicDBObject) actual).get("$gt") instanceof BSONTimestamp, is(true));
BSONTimestamp bsonTimestamp = (BSONTimestamp) ((BasicDBObject) actual).get("$gt");
assertThat(bsonTimestamp.getTime(), is(lastVal));
}
Aggregations