use of org.kie.workbench.common.services.datamodeller.core.impl.ObjectPropertyImpl in project kie-wb-common by kiegroup.
the class RemovePropertyCommandTest method execute.
@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));
}
use of org.kie.workbench.common.services.datamodeller.core.impl.ObjectPropertyImpl in project kie-wb-common by kiegroup.
the class DataObjectBrowserViewImplTest method addPropertyTypeBrowseColumn.
@Test
public void addPropertyTypeBrowseColumn() {
FieldMetadataProvider fieldMetadataProvider = objectProperty -> {
if ("testField".equals(objectProperty.getName())) {
ImageWrapper imageWrapper = new ImageWrapper("testUri", "testDescription");
FieldMetadata fieldMetadata = new FieldMetadata(imageWrapper);
return Optional.of(fieldMetadata);
}
return Optional.empty();
};
Instance<FieldMetadataProvider> fieldMetadataProviderInstance = new MockInstanceImpl<>(fieldMetadataProvider);
view = new DataObjectBrowserViewImpl(validationPopup, fieldMetadataProviderInstance);
Column<ObjectProperty, List<ImageWrapper>> column = view.createPropertyTypeBrowseColumn();
ObjectProperty matchingObjectProperty = new ObjectPropertyImpl("testField", "className", false);
List<ImageWrapper> imageWrapperList = column.getValue(matchingObjectProperty);
assertEquals(1, imageWrapperList.size());
ObjectProperty nonMatchingObjectProperty = new ObjectPropertyImpl("nonMatchingTestField", "className", false);
imageWrapperList = column.getValue(nonMatchingObjectProperty);
assertEquals(0, imageWrapperList.size());
}
use of org.kie.workbench.common.services.datamodeller.core.impl.ObjectPropertyImpl in project kie-wb-common by kiegroup.
the class DataModelerEventTest method createEvent.
@Test
public void createEvent() {
DataObject currentDataObject = new DataObjectImpl();
ObjectProperty currentField = new ObjectPropertyImpl();
Method currentMethod = new MethodImpl();
Module currentModule = new Module();
String source = "testSource";
String contextId = "testContextId";
Path path = new PathFactory.PathImpl();
DataModelerEvent event = new DataModelerEvent().withCurrentDataObject(currentDataObject).withCurrentField(currentField).withCurrentMethod(currentMethod).withCurrentProject(currentModule).withSource(source).withContextId(contextId).withPath(path);
assertEquals(currentDataObject, event.getCurrentDataObject());
assertEquals(currentField, event.getCurrentField());
assertEquals(currentMethod, event.getCurrentMethod());
assertEquals(currentModule, event.getCurrentModule());
assertEquals(source, event.getSource());
assertEquals(contextId, event.getContextId());
assertEquals(path, event.getPath());
}
use of org.kie.workbench.common.services.datamodeller.core.impl.ObjectPropertyImpl in project kie-wb-common by kiegroup.
the class DataModelTestUtil method addProperty.
public ObjectProperty addProperty(DataObject dataObject, String name, String className, boolean baseType, boolean multiple, String bag) {
// TODO set modifiers.
ObjectProperty property = new ObjectPropertyImpl(name, className, multiple, bag, Visibility.PUBLIC, false, false);
dataObject.addProperty(property);
return property;
}
use of org.kie.workbench.common.services.datamodeller.core.impl.ObjectPropertyImpl in project kie-wb-common by kiegroup.
the class AddPropertyCommand method execute.
@Override
public void execute() {
// extra check
boolean multiple = isMultiple && !getContext().getHelper().isPrimitiveType(propertyType);
property = new ObjectPropertyImpl(propertyName, propertyType, multiple);
if (propertyLabel != null && !"".equals(propertyLabel)) {
Annotation annotation = new AnnotationImpl(getContext().getAnnotationDefinitions().get(MainDomainAnnotations.LABEL_ANNOTATION));
annotation.setValue(MainDomainAnnotations.VALUE_PARAM, propertyLabel);
property.addAnnotation(annotation);
}
dataObject.addProperty(property);
if (!property.isBaseType()) {
getContext().getHelper().dataObjectReferenced(property.getClassName(), dataObject.getClassName());
}
notifyChange(new DataObjectFieldCreatedEvent(getContext().getContextId(), getSource(), getDataObject(), property));
}
Aggregations