EntityServiceImpl implements EntityService { @Override @Transactional public void deleteEntity(Long entityId) { Entity entity = allEntities.retrieveById(entityId); assertWritableEntity(entity, entityId); if (entity.isDraft()) { entity = ((EntityDraft) entity).getParentEntity(); } allEntityDrafts.deleteAll(entity); allEntities.delete(entity); }  @Override @Transactional Long getCurrentSchemaVersion(String className); @Override @Transactional void incrementVersion(Long entityId); @Override @Transactional EntityDto createEntity(EntityDto entityDto); @Override @Transactional DraftResult saveDraftEntityChanges(Long entityId, DraftData draftData, String username); @Override @Transactional DraftResult saveDraftEntityChanges(Long entityId, DraftData draftData); @Override @Transactional void abandonChanges(Long entityId); @Override @Transactional List<String> commitChanges(Long entityId, String changesOwner); @Override @Transactional List<String> commitChanges(Long entityId); @Override @Transactional List<EntityDto> listWorkInProgress(); @Override @Transactional AdvancedSettingsDto getAdvancedSettings(Long entityId); @Override @Transactional AdvancedSettingsDto getAdvancedSettings(Long entityId, boolean committed); @Override @Transactional AdvancedSettingsDto safeGetAdvancedSettingsCommitted(String entityClassName); @Override @Transactional void updateRestOptions(Long entityId, RestOptionsDto restOptionsDto); @Override @Transactional void updateTracking(Long entityId, TrackingDto trackingDto); @Override @Transactional void addLookups(EntityDto entityDto, LookupDto... lookups); @Override @Transactional void addLookups(EntityDto entityDto, Collection<LookupDto> lookups); @Override @Transactional void addLookups(Long entityId, LookupDto... lookups); @Override @Transactional void addLookups(Long entityId, Collection<LookupDto> lookups); @Override @Transactional Map<String, FieldDto> getLookupFieldsMapping(Long entityId, String lookupName); @Override @Transactional void deleteEntity(Long entityId); @Override @Transactional List<EntityDto> listEntities(); @Override @Transactional List<EntityDto> listEntities(boolean withSecurityCheck); @Override @Transactional List<EntityDto> listEntitiesByBundle(String bundleSymbolicName); @Override @Transactional EntityDto getEntity(Long entityId); @Override @Transactional EntityDto getEntityByClassName(String className); @Override @Transactional List<EntityDto> findEntitiesByPackage(String packageName); @Override @Transactional List<LookupDto> getEntityLookups(Long entityId); @Override @Transactional List<FieldDto> getFields(Long entityId); @Override @Transactional List<FieldDto> getEntityFields(Long entityId); @Override @Transactional List<FieldDto> getEntityFieldsForUI(Long entityId); @Override @Transactional SchemaHolder getSchema(); @Override @Transactional List<FieldDto> getEntityFieldsByClassName(String className); @Override @Transactional List<FieldDto> getEntityFieldsByClassNameForUI(String className); @Override @Transactional FieldDto findFieldByName(Long entityId, String name); @Override @Transactional FieldDto findEntityFieldByName(Long entityId, String name); @Override @Transactional FieldDto getEntityFieldById(Long entityId, Long fieldId); @Override @Transactional EntityDto getEntityForEdit(Long entityId); @Override @Transactional EntityDraft getEntityDraft(Long entityId); @Override @Transactional EntityDraft getEntityDraft(Long entityId, String username); @Override @Transactional void addFields(EntityDto entity, Collection<FieldDto> fields); @Override @Transactional void addFields(Long entityId, FieldDto... fields); @Override @Transactional void addFields(EntityDto entity, FieldDto... fields); @Override @Transactional void addFields(Long entityId, Collection<FieldDto> fields); @Override @Transactional void addFilterableFields(EntityDto entityDto, Collection<String> fieldNames); @Override @Transactional EntityDto updateDraft(Long entityId); @Override @Transactional LookupDto getLookupByName(Long entityId, String lookupName); @Override @Transactional List<FieldDto> getDisplayFields(Long entityId); @Override @Transactional void addNonEditableFields(EntityDto entityDto, Map<String, Boolean> nonEditableFields); @Override @Transactional void addDisplayedFields(EntityDto entityDto, Map<String, Long> positions); @Override @Transactional void updateSecurityOptions(Long entityId, SecurityMode securityMode, Set<String> securityMembers, SecurityMode readOnlySecurityMode, Set<String> readOnlySecurityMembers); @Override @Transactional void updateMaxFetchDepth(Long entityId, Integer maxFetchDepth); @Autowired void setAllEntities(AllEntities allEntities); @Autowired void setAllTypes(AllTypes allTypes); @Autowired void setAllEntityDrafts(AllEntityDrafts allEntityDrafts); @Autowired void setAllEntityAudits(AllEntityAudits allEntityAudits); @Autowired void setAllUserPreferences(AllUserPreferences allUserPreferences); @Autowired void setMDSConstructor(MDSConstructor mdsConstructor); @Autowired void setBundleContext(BundleContext bundleContext); @Autowired void setEntityValidator(EntityValidator entityValidator); @Autowired void setComboboxDataMigrationHelper(ComboboxDataMigrationHelper comboboxDataMigrationHelper); @Autowired void setUserPreferencesService(UserPreferencesService userPreferencesService);  }
@Test public void shouldDeleteDraftsAndEntities() { when(allEntities.retrieveById(1L)).thenReturn(entity); entityService.deleteEntity(1L); verify(allEntityDrafts).deleteAll(entity); verify(allEntities).delete(entity); }