@SuppressWarnings("unchecked") @Test void testDeleteStreamNoCascade() { when(xrefAttr.getCascadeDelete()).thenReturn(null); when(entity.getEntity(XREF_ATTR_NAME)).thenReturn(refEntity); when(dataService.findOneById(REF_ENTITY_TYPE_NAME, REF_ENTITY_ID)).thenReturn(refEntity); cascadeDeleteRepositoryDecorator.delete(Stream.of(entity)); ArgumentCaptor<Stream<Entity>> captor = ArgumentCaptor.forClass(Stream.class); verify(delegateRepository).delete(captor.capture()); assertEquals(singletonList(entity), captor.getValue().collect(toList())); verify(dataService, never()).delete(REF_ENTITY_TYPE_NAME, refEntity); }
@Override public void delete(Entity entity) { if (hasCascadeDeleteAttributes()) { prepareCascadeDeletes(entity); super.delete(entity); handleCascadeDeletes(entity); } else { delegate().delete(entity); } }
CascadeDeleteRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void delete(Entity entity) { if (hasCascadeDeleteAttributes()) { prepareCascadeDeletes(entity); super.delete(entity); handleCascadeDeletes(entity); } else { delegate().delete(entity); } } }
CascadeDeleteRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void delete(Entity entity) { if (hasCascadeDeleteAttributes()) { prepareCascadeDeletes(entity); super.delete(entity); handleCascadeDeletes(entity); } else { delegate().delete(entity); } } CascadeDeleteRepositoryDecorator(
      Repository<Entity> delegateRepository, DataService dataService); }
CascadeDeleteRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void delete(Entity entity) { if (hasCascadeDeleteAttributes()) { prepareCascadeDeletes(entity); super.delete(entity); handleCascadeDeletes(entity); } else { delegate().delete(entity); } } CascadeDeleteRepositoryDecorator(
      Repository<Entity> delegateRepository, DataService dataService); @Override void delete(Entity entity); @Override void deleteById(Object id); @Override void deleteAll(); @Override void delete(Stream<Entity> entities); @Override void deleteAll(Stream<Object> ids); }
CascadeDeleteRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void delete(Entity entity) { if (hasCascadeDeleteAttributes()) { prepareCascadeDeletes(entity); super.delete(entity); handleCascadeDeletes(entity); } else { delegate().delete(entity); } } CascadeDeleteRepositoryDecorator(
      Repository<Entity> delegateRepository, DataService dataService); @Override void delete(Entity entity); @Override void deleteById(Object id); @Override void deleteAll(); @Override void delete(Stream<Entity> entities); @Override void deleteAll(Stream<Object> ids);  }