OffsetService { public Map<Integer, String> getOffsets(final List<Integer> items) { Map<Integer, String> result = new HashMap<>(items.size()); for (int each : items) { String offset = jobNodeStorage.getJobNodeDataDirectly(OffsetNode.getItemNode(each)); if (!Strings.isNullOrEmpty(offset)) { result.put(each, offset); } } return result; } OffsetService(final CoordinatorRegistryCenter coordinatorRegistryCenter, final JobConfiguration jobConfiguration); void updateOffset(final int item, final String offset); Map<Integer, String> getOffsets(final List<Integer> items);  }
@Test public void assertGetOffsets() { when(jobNodeStorage.getJobNodeDataDirectly("offset/0")).thenReturn("offset0"); when(jobNodeStorage.getJobNodeDataDirectly("offset/1")).thenReturn(""); when(jobNodeStorage.getJobNodeDataDirectly("offset/2")).thenReturn("offset2"); Map<Integer, String> expected = new HashMap<>(1); expected.put(0, "offset0"); assertThat(offsetService.getOffsets(Arrays.asList(0, 1)), is(expected)); verify(jobNodeStorage).getJobNodeDataDirectly("offset/0"); verify(jobNodeStorage).getJobNodeDataDirectly("offset/1"); }