@Test public void execute() { DataObject dataObject = new DataObjectImpl("org.test", "TestDataObject"); dataObject.addProperty(new ObjectPropertyImpl("testProperty", Integer.class.getName(), false)); DataModelChangeNotifier notifier = mock(DataModelChangeNotifier.class); RemovePropertyCommand command = new RemovePropertyCommand(new DataModelerContext(), "source", dataObject, "testProperty", notifier); command.execute(); assertNull(dataObject.getProperty("testProperty")); verify(notifier, times(1)).notifyChange(any(DataObjectFieldDeletedEvent.class)); }
@Override public void execute() { if (dataObject != null) { ObjectProperty property = dataObject.getProperty(propertyName); if (property != null) { dataObject.removeProperty(propertyName); notifyChange(new DataObjectFieldDeletedEvent(getContext().getContextId(), getSource(), getDataObject(), property)); } } }
RemovePropertyCommand extends AbstractDataModelCommand { @Override public void execute() { if (dataObject != null) { ObjectProperty property = dataObject.getProperty(propertyName); if (property != null) { dataObject.removeProperty(propertyName); notifyChange(new DataObjectFieldDeletedEvent(getContext().getContextId(), getSource(), getDataObject(), property)); } } } }
RemovePropertyCommand extends AbstractDataModelCommand { @Override public void execute() { if (dataObject != null) { ObjectProperty property = dataObject.getProperty(propertyName); if (property != null) { dataObject.removeProperty(propertyName); notifyChange(new DataObjectFieldDeletedEvent(getContext().getContextId(), getSource(), getDataObject(), property)); } } } RemovePropertyCommand(final DataModelerContext context,
                                 final String source,
                                 final DataObject dataObject,
                                 final String propertyName,
                                 final DataModelChangeNotifier notifier); }
RemovePropertyCommand extends AbstractDataModelCommand { @Override public void execute() { if (dataObject != null) { ObjectProperty property = dataObject.getProperty(propertyName); if (property != null) { dataObject.removeProperty(propertyName); notifyChange(new DataObjectFieldDeletedEvent(getContext().getContextId(), getSource(), getDataObject(), property)); } } } RemovePropertyCommand(final DataModelerContext context,
                                 final String source,
                                 final DataObject dataObject,
                                 final String propertyName,
                                 final DataModelChangeNotifier notifier); @Override void execute(); }
RemovePropertyCommand extends AbstractDataModelCommand { @Override public void execute() { if (dataObject != null) { ObjectProperty property = dataObject.getProperty(propertyName); if (property != null) { dataObject.removeProperty(propertyName); notifyChange(new DataObjectFieldDeletedEvent(getContext().getContextId(), getSource(), getDataObject(), property)); } } } RemovePropertyCommand(final DataModelerContext context,
                                 final String source,
                                 final DataObject dataObject,
                                 final String propertyName,
                                 final DataModelChangeNotifier notifier); @Override void execute();  }