use of org.kie.workbench.common.screens.datamodeller.events.DataObjectDeletedEvent in project kie-wb-common by kiegroup.
the class DataModelerEventObserverTest method onPersistableDataObjectDeletedTest.
@Test
public void onPersistableDataObjectDeletedTest() {
DataObjectDeletedEvent deletedEvent = new DataObjectDeletedEvent(module, dataObject);
descriptorModel.getPersistenceUnit().getClasses().add(new PersistableDataObject(deletedEvent.getCurrentDataObject().getClassName()));
eventObserver.onDataObjectDeleted(deletedEvent);
verify(descriptorService, times(1)).save(eq(descriptorPath), eq(descriptorModel), Mockito.<Metadata>any(), anyString());
assertFalse(descriptorModel.getPersistenceUnit().getClasses().contains(new PersistableDataObject(dataObject.getClassName())));
}
use of org.kie.workbench.common.screens.datamodeller.events.DataObjectDeletedEvent in project kie-wb-common by kiegroup.
the class DataModelerServiceImpl method delete.
@Override
public void delete(final Path path, final String comment) {
try {
KieModule module = moduleService.resolveModule(path);
if (module == null) {
logger.warn("File : " + path.toURI() + " do not belong to a valid module");
return;
}
deleteService.delete(path, comment);
String className = serviceHelper.calculateClassName(module, path);
DataObject dataObject = new DataObjectImpl(NamingUtils.extractPackageName(className), NamingUtils.extractClassName(className));
dataObjectDeletedEvent.fire(new DataObjectDeletedEvent(module, dataObject));
} catch (final Exception e) {
logger.error("File: " + path.toURI() + " couldn't be deleted due to the following error. ", e);
throw new ServiceException("File: " + path.toURI() + " couldn't be deleted due to the following error. " + e.getMessage());
}
}
Aggregations