@Test public void testGetRecentStatuses() throws EntryExistsException { for (int i = 1; i < 11; i++) { final String entryId = "abcd_" + i; final Map<String, Integer> entry = ImmutableMap.of("a", i); final Map<String, Integer> status = ImmutableMap.of("count", i * 10); handler.insert(entryId, DateTimes.of(StringUtils.format("2014-01-%02d", i)), "test", entry, false, status); } final List<TaskInfo<Map<String, Integer>, Map<String, Integer>>> statuses = handler.getCompletedTaskInfo( DateTimes.of("2014-01-01"), 7, null ); Assert.assertEquals(7, statuses.size()); int i = 10; for (TaskInfo<Map<String, Integer>, Map<String, Integer>> status : statuses) { Assert.assertEquals(ImmutableMap.of("count", i-- * 10), status.getStatus()); } }
@Test public void testGetRecentStatuses2() throws EntryExistsException { for (int i = 1; i < 6; i++) { final String entryId = "abcd_" + i; final Map<String, Integer> entry = ImmutableMap.of("a", i); final Map<String, Integer> status = ImmutableMap.of("count", i * 10); handler.insert(entryId, DateTimes.of(StringUtils.format("2014-01-%02d", i)), "test", entry, false, status); } final List<TaskInfo<Map<String, Integer>, Map<String, Integer>>> statuses = handler.getCompletedTaskInfo( DateTimes.of("2014-01-01"), 10, null ); Assert.assertEquals(5, statuses.size()); int i = 5; for (TaskInfo<Map<String, Integer>, Map<String, Integer>> status : statuses) { Assert.assertEquals(ImmutableMap.of("count", i-- * 10), status.getStatus()); } }
handler.getCompletedTaskInfo(DateTimes.of("2014-01-01"), null, null).stream() .map(taskInfo -> taskInfo.getId()) .collect(Collectors.toList()) Assert.assertEquals( ImmutableList.of(entryId3), handler.getCompletedTaskInfo(DateTimes.of("2014-01-01"), null, null).stream() .map(taskInfo -> taskInfo.getId()) .collect(Collectors.toList())
handler.getCompletedTaskInfo(DateTimes.of("2014-01-01"), null, null) ); handler.getCompletedTaskInfo(DateTimes.of("2014-01-03"), null, null) ); handler.getCompletedTaskInfo(DateTimes.of("2014-01-01"), null, null) .stream() .map(TaskInfo::getStatus)