@SuppressWarnings("unchecked") @Test void testUpdateStream() { EntityType entityType = mock(EntityType.class); when(delegateRepository.getEntityType()).thenReturn(entityType); Entity entity0 = mock(Entity.class); Entity entity1 = mock(Entity.class); doAnswer(invocation -> ((Stream<?>) invocation.getArguments()[0]).count()) .when(delegateRepository) .update(any(Stream.class)); doAnswer(invocation -> invocation.getArguments()[1]) .when(l1CacheJanitor) .cleanCacheBeforeUpdate(eq(entityType), any(Stream.class)); l1CacheRepositoryDecorator.update(Stream.of(entity0, entity1)); verify(l1Cache).put(entity0); verify(l1Cache).put(entity1); verifyNoMoreInteractions(l1Cache, delegateRepository); }
@Override public void update(Entity entity) { if (useCache()) { l1CacheJanitor.cleanCacheBeforeUpdate(entity); putCache(entity); } delegate().update(entity); }
L1CacheRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void update(Entity entity) { if (useCache()) { l1CacheJanitor.cleanCacheBeforeUpdate(entity); putCache(entity); } delegate().update(entity); } }
L1CacheRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void update(Entity entity) { if (useCache()) { l1CacheJanitor.cleanCacheBeforeUpdate(entity); putCache(entity); } delegate().update(entity); } L1CacheRepositoryDecorator(
      Repository<Entity> delegateRepository, L1Cache l1Cache, L1CacheJanitor l1CacheJanitor); }
L1CacheRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void update(Entity entity) { if (useCache()) { l1CacheJanitor.cleanCacheBeforeUpdate(entity); putCache(entity); } delegate().update(entity); } L1CacheRepositoryDecorator(
      Repository<Entity> delegateRepository, L1Cache l1Cache, L1CacheJanitor l1CacheJanitor); @Override void add(Entity entity); @Override Integer add(Stream<Entity> entities); @Override Entity findOneById(Object id); @Override Entity findOneById(Object id, Fetch fetch); @Override Stream<Entity> findAll(Stream<Object> ids); @Override Stream<Entity> findAll(Stream<Object> ids, Fetch fetch); @Override void update(Entity entity); @Override void update(Stream<Entity> entities); @Override void delete(Entity entity); @Override void delete(Stream<Entity> entities); @Override void deleteById(Object id); @Override void deleteAll(Stream<Object> ids); @Override void deleteAll(); }
L1CacheRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void update(Entity entity) { if (useCache()) { l1CacheJanitor.cleanCacheBeforeUpdate(entity); putCache(entity); } delegate().update(entity); } L1CacheRepositoryDecorator(
      Repository<Entity> delegateRepository, L1Cache l1Cache, L1CacheJanitor l1CacheJanitor); @Override void add(Entity entity); @Override Integer add(Stream<Entity> entities); @Override Entity findOneById(Object id); @Override Entity findOneById(Object id, Fetch fetch); @Override Stream<Entity> findAll(Stream<Object> ids); @Override Stream<Entity> findAll(Stream<Object> ids, Fetch fetch); @Override void update(Entity entity); @Override void update(Stream<Entity> entities); @Override void delete(Entity entity); @Override void delete(Stream<Entity> entities); @Override void deleteById(Object id); @Override void deleteAll(Stream<Object> ids); @Override void deleteAll();  }