use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class JPADataObjectEditorTest method tableNameChangeTest.
@Test
public void tableNameChangeTest() {
JPADataObjectEditor objectEditor = createObjectEditor();
// load the editor
objectEditor.onContextChange(context);
DataObject dataObject = context.getDataObject();
// emulates user interaction
objectEditor.onTableNameChange("NewTableName");
// the field should have been updated according to the values entered on the ui
assertEquals("NewTableName", AnnotationValueHandler.getStringValue(dataObject, Table.class.getName(), "name"));
}
use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class MainDataObjectFieldEditorTest method loadDataObjectFieldTest.
@Test
public void loadDataObjectFieldTest() {
MainDataObjectFieldEditor fieldEditor = createFieldEditor();
DataObject dataObject = context.getDataObject();
ObjectProperty field = dataObject.getProperty("field1");
// emulates selection of field1 in current context.
context.setObjectProperty(field);
// The domain editors typically reacts upon DataModelerContext changes.
// when the context changes the editor will typically be reloaded.
fieldEditor.onContextChange(context);
// the view should be populated with the values from the field.
verify(view, times(1)).setName(field.getName());
verify(view, times(1)).setLabel(AnnotationValueHandler.getStringValue(field, Label.class.getName(), "value"));
verify(view, times(1)).setDescription(AnnotationValueHandler.getStringValue(field, Description.class.getName(), "value"));
verify(view, times(1)).initTypeList(anyList(), eq(field.getClassName()), eq(false));
assertFalse(fieldEditor.isReadonly());
}
use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class DroolsDataObjectFieldEditorTest method loadDataObjectFieldTest.
@Test
public void loadDataObjectFieldTest() {
DroolsDataObjectFieldEditor fieldEditor = createFieldEditor();
DataObject dataObject = context.getDataObject();
ObjectProperty field1 = dataObject.getProperty("field1");
// emulates selection of field1 in current context.
context.setObjectProperty(field1);
;
// The domain editors typically reacts upon DataModelerContext changes.
// when the context changes the editor will typically be reloaded.
fieldEditor.onContextChange(context);
// the view should be populated with the values from the field.
verify(view, times(1)).setEquals(true);
verify(view, times(1)).setPosition("0");
assertFalse(fieldEditor.isReadonly());
}
use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class DroolsDataObjectFieldEditorTest method valuesChangesTest.
@Test
public void valuesChangesTest() {
DroolsDataObjectFieldEditor fieldEditor = createFieldEditor();
DataObject dataObject = context.getDataObject();
ObjectProperty field1 = dataObject.getProperty("field1");
// emulates selection of field1 in current context.
context.setObjectProperty(field1);
;
// The domain editors typically reacts upon DataModelerContext changes.
// when the context changes the editor will typically be reloaded.
fieldEditor.onContextChange(context);
// emulate the user input.
when(view.getEquals()).thenReturn(false);
when(view.getPosition()).thenReturn("1");
// notify the presenter about the changes in the UI
fieldEditor.onEqualsChange();
fieldEditor.onPositionChange();
assertNull(field1.getAnnotation(Key.class.getName()));
assertEquals(1, AnnotationValueHandler.getValue(field1, Position.class.getName(), "value"));
verify(dataModelerEvent, times(2)).fire(any(DataModelerEvent.class));
}
use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class MainDataObjectEditorTest method valuesChangeTest.
@Test
public void valuesChangeTest() {
MainDataObjectEditor objectEditor = createObjectEditor();
// load the editor
objectEditor.onContextChange(context);
context.getEditorModelContent().setOriginalClassName(context.getDataObject().getClassName());
context.getEditorModelContent().setPath(mock(Path.class));
// emulate the user input
when(view.getName()).thenReturn(NEW_NAME);
when(view.getPackageName()).thenReturn(NEW_PACKAGE);
when(view.getSuperClass()).thenReturn(NEW_SUPERCLASS);
when(view.getDescription()).thenReturn(NEW_DESCRIPTION);
when(view.getLabel()).thenReturn(NEW_LABEL);
Map<String, Boolean> validationResult = new HashMap<String, Boolean>();
validationResult.put(NEW_NAME, true);
when(validationService.evaluateJavaIdentifiers(any(String[].class))).thenReturn(validationResult);
// notify the presenter about the changes in the UI
objectEditor.onNameChange();
objectEditor.onPackageChange();
objectEditor.onSuperClassChange();
objectEditor.onLabelChange();
objectEditor.onDescriptionChange();
verify(showAssetUsagesDisplayer, times(2)).showAssetUsages(anyString(), any(), any(), any(), any(), any());
// After the changes has been processed by the presenter the dataObject should have been populated with the new values.
DataObject dataObject = context.getDataObject();
assertEquals(NEW_NAME, dataObject.getName());
assertEquals(NEW_PACKAGE, dataObject.getPackageName());
assertEquals(NEW_SUPERCLASS, dataObject.getSuperClassName());
assertEquals(NEW_LABEL, AnnotationValueHandler.getStringValue(dataObject, Label.class.getName()));
assertEquals(NEW_DESCRIPTION, AnnotationValueHandler.getStringValue(dataObject, Description.class.getName()));
verify(dataModelerEvent, times(5)).fire(any(DataModelerEvent.class));
}
Aggregations