@Test @DisplayName("Loads all data into cache when retrieving one entry") void testFindById() { when(delegate.findAll()).thenAnswer(__ -> Stream.of("A", "B", "C")); assertThat(table.findById("A")).isEqualTo("A"); assertThat(table.findById("B")).isEqualTo("B"); assertThat(table.findById("C")).isEqualTo("C"); verify(delegate, times(1)).findAll(); verifyNoMoreInteractions(delegate); }
@Override public E findById(String id) { return getCache().get(id); }
CachingClientTable implements ClientTable<E> { @Override public E findById(String id) { return getCache().get(id); } }
CachingClientTable implements ClientTable<E> { @Override public E findById(String id) { return getCache().get(id); } CachingClientTable(DatabaseAccessor accessor, Function<String, ? extends ClientOperation<E>> operationMap, Function<E, String> idGetter);   CachingClientTable(ClientTable<E> delegate, Function<String, ? extends ClientOperation<E>> operationMap, Function<? super E, String> idGetter); }
CachingClientTable implements ClientTable<E> { @Override public E findById(String id) { return getCache().get(id); } CachingClientTable(DatabaseAccessor accessor, Function<String, ? extends ClientOperation<E>> operationMap, Function<E, String> idGetter);   CachingClientTable(ClientTable<E> delegate, Function<String, ? extends ClientOperation<E>> operationMap, Function<? super E, String> idGetter); @Override String getName(); @Override Stream<E> findAll(); @Override E findById(String id); @Override synchronized Event append(String user, String operation, String objectId, String data); }
CachingClientTable implements ClientTable<E> { @Override public E findById(String id) { return getCache().get(id); } CachingClientTable(DatabaseAccessor accessor, Function<String, ? extends ClientOperation<E>> operationMap, Function<E, String> idGetter);   CachingClientTable(ClientTable<E> delegate, Function<String, ? extends ClientOperation<E>> operationMap, Function<? super E, String> idGetter); @Override String getName(); @Override Stream<E> findAll(); @Override E findById(String id); @Override synchronized Event append(String user, String operation, String objectId, String data);  }