@SuppressWarnings("unchecked") @Test void testDeleteAllStream() { EntityType entityType = mock(EntityType.class); when(delegateRepository.getEntityType()).thenReturn(entityType); Object entityId0 = mock(Object.class); Object entityId1 = mock(Object.class); doAnswer(invocation -> ((Stream<?>) invocation.getArguments()[0]).count()) .when(delegateRepository) .deleteAll(any(Stream.class)); doAnswer(invocation -> invocation.getArguments()[1]) .when(l1CacheJanitor) .cleanCacheBeforeDeleteById(eq(entityType), any(Stream.class)); l1CacheRepositoryDecorator.deleteAll(Stream.of(entityId0, entityId1)); verify(l1Cache).putDeletion(entityType, entityId0); verify(l1Cache).putDeletion(entityType, entityId1); verifyNoMoreInteractions(l1Cache, delegateRepository); }
@Override public void deleteAll(Stream<Object> ids) { if (useCache()) { EntityType entityType = getEntityType(); ids = l1CacheJanitor .cleanCacheBeforeDeleteById(entityType, ids) .filter(id -> this.delCache(entityType, id)); } delegate().deleteAll(ids); }
L1CacheRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void deleteAll(Stream<Object> ids) { if (useCache()) { EntityType entityType = getEntityType(); ids = l1CacheJanitor .cleanCacheBeforeDeleteById(entityType, ids) .filter(id -> this.delCache(entityType, id)); } delegate().deleteAll(ids); } }
L1CacheRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void deleteAll(Stream<Object> ids) { if (useCache()) { EntityType entityType = getEntityType(); ids = l1CacheJanitor .cleanCacheBeforeDeleteById(entityType, ids) .filter(id -> this.delCache(entityType, id)); } delegate().deleteAll(ids); } L1CacheRepositoryDecorator(
      Repository<Entity> delegateRepository, L1Cache l1Cache, L1CacheJanitor l1CacheJanitor); }
L1CacheRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void deleteAll(Stream<Object> ids) { if (useCache()) { EntityType entityType = getEntityType(); ids = l1CacheJanitor .cleanCacheBeforeDeleteById(entityType, ids) .filter(id -> this.delCache(entityType, id)); } delegate().deleteAll(ids); } 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 deleteAll(Stream<Object> ids) { if (useCache()) { EntityType entityType = getEntityType(); ids = l1CacheJanitor .cleanCacheBeforeDeleteById(entityType, ids) .filter(id -> this.delCache(entityType, id)); } delegate().deleteAll(ids); } 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();  }