@Test public void shouldReturnEmptyResultIfStorageIsEmpty() { assertThat(sut.getMessagesAfter(0)).isEmpty(); }
public synchronized Collection<SimpleMessage> getMessagesAfter(long id) { if (storage.isEmpty()) { return Collections.emptySet(); } return storage.entrySet().stream().filter(e -> e.getKey() > id).map(e -> e.getValue()) .collect(Collectors.toSet()); }
LocalMessageStorage { public synchronized Collection<SimpleMessage> getMessagesAfter(long id) { if (storage.isEmpty()) { return Collections.emptySet(); } return storage.entrySet().stream().filter(e -> e.getKey() > id).map(e -> e.getValue()) .collect(Collectors.toSet()); } }
LocalMessageStorage { public synchronized Collection<SimpleMessage> getMessagesAfter(long id) { if (storage.isEmpty()) { return Collections.emptySet(); } return storage.entrySet().stream().filter(e -> e.getKey() > id).map(e -> e.getValue()) .collect(Collectors.toSet()); }  }
LocalMessageStorage { public synchronized Collection<SimpleMessage> getMessagesAfter(long id) { if (storage.isEmpty()) { return Collections.emptySet(); } return storage.entrySet().stream().filter(e -> e.getKey() > id).map(e -> e.getValue()) .collect(Collectors.toSet()); }  synchronized Collection<SimpleMessage> getMessagesAfter(long id); synchronized void addMessage(SimpleMessage message); synchronized void clear(); synchronized int size(); synchronized long getLastId(); }
LocalMessageStorage { public synchronized Collection<SimpleMessage> getMessagesAfter(long id) { if (storage.isEmpty()) { return Collections.emptySet(); } return storage.entrySet().stream().filter(e -> e.getKey() > id).map(e -> e.getValue()) .collect(Collectors.toSet()); }  synchronized Collection<SimpleMessage> getMessagesAfter(long id); synchronized void addMessage(SimpleMessage message); synchronized void clear(); synchronized int size(); synchronized long getLastId();  }