JSONCache { public static Response getOrCache(String identifier, Supplier<Response> jsonResponseSupplier) { byte[] found = cache.getIfPresent(identifier); if (found == null) { Response response = jsonResponseSupplier.get(); cache.put(identifier, response.getBytes()); return response; } return Response.builder() .setMimeType(MimeType.JSON) .setContent(found) .build(); } private  JSONCache(); static Response getOrCache(String identifier, Supplier<Response> jsonResponseSupplier); static String getOrCacheString(DataID dataID, UUID serverUUID, Supplier<String> stringSupplier); static Response getOrCache(DataID dataID, Supplier<T> objectSupplier); static Response getOrCache(DataID dataID, UUID serverUUID, Supplier<T> objectSupplier); static void invalidate(String identifier); static void invalidate(DataID dataID); static void invalidate(UUID serverUUID, DataID... dataIDs); static void invalidate(DataID dataID, UUID serverUUID); static void invalidateMatching(DataID... dataIDs); static void invalidateMatching(DataID dataID); static void invalidateAll(); static void cleanUp(); static List<String> getCachedIDs();  }
@Test void cachedByDataIDName() { JSONCache.getOrCache(TEST_ID, () -> CACHED); assertContains(); }
@Test void cachedByServerUUID() { JSONCache.getOrCache(TEST_ID, TEST_UUID, () -> CACHED); assertContainsUUID(); }