@Test public void onNonPersistableDataObjectCreatedTest() { descriptorModel.getPersistenceUnit().getClasses().add(new PersistableDataObject("package1.PersistableObject")); DataObjectCreatedEvent createdEvent = new DataObjectCreatedEvent(module, dataObject); eventObserver.onDataObjectCreated(createdEvent); verify(descriptorService, times(0)).save(eq(descriptorPath), eq(descriptorModel), any(Metadata.class), anyString()); assertEquals(1, descriptorModel.getPersistenceUnit().getClasses().size()); }
public void onDataObjectCreated(@Observes DataObjectCreatedEvent event) { Path descriptorPath; PersistenceDescriptorModel persistenceDescriptor; if (isPersistable(event.getCurrentDataObject())) { descriptorPath = descriptorService.calculatePersistenceDescriptorPath(event.getCurrentModule()); persistenceDescriptor = safeLoad(descriptorPath); if (persistenceDescriptor != null && !containsClass(persistenceDescriptor.getPersistenceUnit(), event.getCurrentDataObject().getClassName())) { persistenceDescriptor.getPersistenceUnit().getClasses().add(new PersistableDataObject(event.getCurrentDataObject().getClassName())); descriptorService.save(descriptorPath, persistenceDescriptor, null, "Entity added to persistence descriptor"); } } }
DataModelerEventObserver { public void onDataObjectCreated(@Observes DataObjectCreatedEvent event) { Path descriptorPath; PersistenceDescriptorModel persistenceDescriptor; if (isPersistable(event.getCurrentDataObject())) { descriptorPath = descriptorService.calculatePersistenceDescriptorPath(event.getCurrentModule()); persistenceDescriptor = safeLoad(descriptorPath); if (persistenceDescriptor != null && !containsClass(persistenceDescriptor.getPersistenceUnit(), event.getCurrentDataObject().getClassName())) { persistenceDescriptor.getPersistenceUnit().getClasses().add(new PersistableDataObject(event.getCurrentDataObject().getClassName())); descriptorService.save(descriptorPath, persistenceDescriptor, null, "Entity added to persistence descriptor"); } } } }
DataModelerEventObserver { public void onDataObjectCreated(@Observes DataObjectCreatedEvent event) { Path descriptorPath; PersistenceDescriptorModel persistenceDescriptor; if (isPersistable(event.getCurrentDataObject())) { descriptorPath = descriptorService.calculatePersistenceDescriptorPath(event.getCurrentModule()); persistenceDescriptor = safeLoad(descriptorPath); if (persistenceDescriptor != null && !containsClass(persistenceDescriptor.getPersistenceUnit(), event.getCurrentDataObject().getClassName())) { persistenceDescriptor.getPersistenceUnit().getClasses().add(new PersistableDataObject(event.getCurrentDataObject().getClassName())); descriptorService.save(descriptorPath, persistenceDescriptor, null, "Entity added to persistence descriptor"); } } } DataModelerEventObserver(); @Inject  DataModelerEventObserver(final PersistenceDescriptorService descriptorService,
                                    final @Named("ioStrategy") IOService ioService); }
DataModelerEventObserver { public void onDataObjectCreated(@Observes DataObjectCreatedEvent event) { Path descriptorPath; PersistenceDescriptorModel persistenceDescriptor; if (isPersistable(event.getCurrentDataObject())) { descriptorPath = descriptorService.calculatePersistenceDescriptorPath(event.getCurrentModule()); persistenceDescriptor = safeLoad(descriptorPath); if (persistenceDescriptor != null && !containsClass(persistenceDescriptor.getPersistenceUnit(), event.getCurrentDataObject().getClassName())) { persistenceDescriptor.getPersistenceUnit().getClasses().add(new PersistableDataObject(event.getCurrentDataObject().getClassName())); descriptorService.save(descriptorPath, persistenceDescriptor, null, "Entity added to persistence descriptor"); } } } DataModelerEventObserver(); @Inject  DataModelerEventObserver(final PersistenceDescriptorService descriptorService,
                                    final @Named("ioStrategy") IOService ioService); void onDataObjectCreated(@Observes DataObjectCreatedEvent event); void onDataObjectDeleted(@Observes DataObjectDeletedEvent event); }
DataModelerEventObserver { public void onDataObjectCreated(@Observes DataObjectCreatedEvent event) { Path descriptorPath; PersistenceDescriptorModel persistenceDescriptor; if (isPersistable(event.getCurrentDataObject())) { descriptorPath = descriptorService.calculatePersistenceDescriptorPath(event.getCurrentModule()); persistenceDescriptor = safeLoad(descriptorPath); if (persistenceDescriptor != null && !containsClass(persistenceDescriptor.getPersistenceUnit(), event.getCurrentDataObject().getClassName())) { persistenceDescriptor.getPersistenceUnit().getClasses().add(new PersistableDataObject(event.getCurrentDataObject().getClassName())); descriptorService.save(descriptorPath, persistenceDescriptor, null, "Entity added to persistence descriptor"); } } } DataModelerEventObserver(); @Inject  DataModelerEventObserver(final PersistenceDescriptorService descriptorService,
                                    final @Named("ioStrategy") IOService ioService); void onDataObjectCreated(@Observes DataObjectCreatedEvent event); void onDataObjectDeleted(@Observes DataObjectDeletedEvent event);  }