@Test public void testGetAll() throws InterruptedException { WebHookPayloadManager manager = new WebHookPayloadManager(server); WebHookEndPointContentStore store = new WebHookEndPointContentStore(manager); WebHookEndPointPayload payload1 = WebHookEndPointPayload.builder() .date(new Date()) .contentType("application/json") .payload("blah blah") .build().generateHash(); String hash1 = payload1.getHash(); store.put(payload1); await().until( contentStoreSize(store), equalTo(1) ); WebHookEndPointPayload payload2 = WebHookEndPointPayload.builder() .date(new Date()) .contentType("application/json") .payload("blah blah") .build().generateHash(); String hash2 = payload2.getHash(); store.put(payload2); assertEquals(hash1, store.getAll().get(1).getHash()); System.out.println(store.getAll().get(1).getHash()); assertEquals(hash2, store.getAll().get(0).getHash()); System.out.println(store.getAll().get(0).getHash()); }
@Synchronized public List<WebHookEndPointPayload> getAll(){ List<WebHookEndPointPayload> sortedStore = new ArrayList<>(); sortedStore.addAll(store); Collections.sort(sortedStore, dateComparator); return sortedStore; }
WebHookEndPointContentStore { @Synchronized public List<WebHookEndPointPayload> getAll(){ List<WebHookEndPointPayload> sortedStore = new ArrayList<>(); sortedStore.addAll(store); Collections.sort(sortedStore, dateComparator); return sortedStore; } }
WebHookEndPointContentStore { @Synchronized public List<WebHookEndPointPayload> getAll(){ List<WebHookEndPointPayload> sortedStore = new ArrayList<>(); sortedStore.addAll(store); Collections.sort(sortedStore, dateComparator); return sortedStore; } WebHookEndPointContentStore(WebHookPayloadManager webHookPayloadManager); }
WebHookEndPointContentStore { @Synchronized public List<WebHookEndPointPayload> getAll(){ List<WebHookEndPointPayload> sortedStore = new ArrayList<>(); sortedStore.addAll(store); Collections.sort(sortedStore, dateComparator); return sortedStore; } WebHookEndPointContentStore(WebHookPayloadManager webHookPayloadManager); @Synchronized void put(WebHookEndPointPayload payload); @Synchronized List<WebHookEndPointPayload> getAll(); }
WebHookEndPointContentStore { @Synchronized public List<WebHookEndPointPayload> getAll(){ List<WebHookEndPointPayload> sortedStore = new ArrayList<>(); sortedStore.addAll(store); Collections.sort(sortedStore, dateComparator); return sortedStore; } WebHookEndPointContentStore(WebHookPayloadManager webHookPayloadManager); @Synchronized void put(WebHookEndPointPayload payload); @Synchronized List<WebHookEndPointPayload> getAll();  }