@Test
public void testGetEntitiesWithLimit() throws Exception {

  Set<TimelineEntity> result = reader.getEntities(
      new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
      "app", null),
      new TimelineEntityFilters.Builder().entityLimit(2L).build(),
      new TimelineDataToRetrieve());
  Assert.assertEquals(2, result.size());
  // Needs to be rewritten once hashcode and equals for
  // TimelineEntity is implemented
  // Entities with id_1 and id_4 should be returned,
  // based on created time, descending.
  for (TimelineEntity entity : result) {
    if (!entity.getId().equals("id_1") && !entity.getId().equals("id_4")) {
      Assert.fail("Entity not sorted by created time");
    }
  }
  result = reader.getEntities(
      new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
      "app", null),
      new TimelineEntityFilters.Builder().entityLimit(3L).build(),
      new TimelineDataToRetrieve());
  // Even though 2 entities out of 4 have same created time, one entity
  // is left out due to limit
  Assert.assertEquals(3, result.size());
}