Skip to content

Commit

Permalink
fixing test
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavbhole committed Jun 26, 2020
1 parent 679f144 commit 5d58484
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ synchronized public void updateCache(BaseSchemaFactory schemaFactory
Message messageInDB = parser.parseFrom(cacheValue);
Long lastUpdatedInDB = Long.valueOf(messageInDB.getField(field).toString());

if(newLastUpdated > lastUpdatedInDB) {
if (newLastUpdated > lastUpdatedInDB) {
db.put(key.getBytes(), value);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public void testUpdateCacheWithLesserLastUpdated() throws Exception{
Assert.assertEquals(productAdUpdated.id(), "32309719080");
Assert.assertEquals(productAdUpdated.description(), "test desc");
Assert.assertEquals(productAdUpdated.status(), "ON"); // NOT Updated due to lesser last updated time, old record is discarded
Assert.assertEquals(extractionNamespace.getLastUpdatedTime().longValue(), -1);
Assert.assertEquals(extractionNamespace.getLastUpdatedTime().longValue(), 1480733203504L); // update ts on first message from kafka, although oldest
Assert.assertEquals(productAdUpdated.lastUpdated(), "1480733203505");
} finally {
if(db != null) {
Expand All @@ -229,14 +229,16 @@ public void testGetCacheValue() throws Exception{
options = new Options().setCreateIfMissing(true);
db = RocksDB.open(options, tempFile.getAbsolutePath());

Message msg = AdProtos.Ad.newBuilder()
.setId("32309719080")
.setTitle("some title")
.setStatus("ON")
.setLastUpdated("1470733203505")
.build();
Map<String, FlatBufferValue> map = new HashMap();
map.put("id", FlatBufferValue.of("32309719080"));
map.put("title", FlatBufferValue.of("some title"));
map.put("status", FlatBufferValue.of("ON"));
map.put("description", FlatBufferValue.of("test desc"));
map.put("last_updated", FlatBufferValue.of("1480733203505"));

FlatBufferBuilder flatBufferBuilder = productAdWrapper.createFlatBuffer(map);

db.put("32309719080".getBytes(), msg.toByteArray());
db.put("32309719080".getBytes(), productAdWrapper.toByteArr(flatBufferBuilder.dataBuffer()));

when(rocksDBManager.getDB(anyString())).thenReturn(db);

Expand Down

0 comments on commit 5d58484

Please sign in to comment.