@Test void testDeleteCascadeMrefNotEmpty() { String mrefAttrName = "mrefAttrName"; Attribute mrefAttr = mock(Attribute.class); when(mrefAttr.getName()).thenReturn(mrefAttrName); when(mrefAttr.getDataType()).thenReturn(MREF); when(mrefAttr.getRefEntity()).thenReturn(refEntityType); when(entityType.getAtomicAttributes()).thenReturn(asList(stringAttr, mrefAttr)); when(dataService.findOneById(REF_ENTITY_TYPE_NAME, REF_ENTITY_ID)).thenReturn(refEntity); when(mrefAttr.getCascadeDelete()).thenReturn(Boolean.TRUE); when(entity.getEntities(mrefAttrName)).thenReturn(singletonList(refEntity)); cascadeDeleteRepositoryDecorator.delete(entity); verify(delegateRepository).delete(entity); verify(dataService).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);  }