use of org.kie.workbench.common.screens.datamodeller.client.DataModelerContext in project kie-wb-common by kiegroup.
the class DataObjectBrowserTest method onDataObjectFieldDeleted.
@Test
public void onDataObjectFieldDeleted() {
DataObjectBrowser dataObjectBrowser = spy(createBrowser());
DataModelerContext context = createContext();
context.setContextId("contextId");
dataObjectBrowser.setContext(context);
DataObject dataObject = mock(DataObject.class);
dataObjectBrowser.setDataObject(dataObject);
DataObjectFieldDeletedEvent event = new DataObjectFieldDeletedEvent();
event.setContextId("contextId");
Mockito.reset(dataObjectBrowser);
dataObjectBrowser.onDataObjectFieldDeleted(event);
verify(dataObjectBrowser, times(1)).setDataObject(dataObject);
}
use of org.kie.workbench.common.screens.datamodeller.client.DataModelerContext in project kie-wb-common by kiegroup.
the class DataObjectBrowserTest method addInvalidPropertyTest.
@Test
public void addInvalidPropertyTest() {
DataObjectBrowser objectBrowser = createBrowser();
DataModelerContext context = createContext();
objectBrowser.setContext(context);
// the dataObject has fields: field1, field2 and field3
DataObject dataObject = context.getDataObject();
// open the new property dialog.
objectBrowser.onNewProperty();
// check the new field popup is shown
verify(newFieldPopupView, times(1)).show();
// emulate the user data entering in the new field popup
when(newFieldPopupView.getFieldName()).thenReturn("field4");
when(newFieldPopupView.getSelectedType()).thenReturn("java.lang.String");
when(newFieldPopupView.getIsMultiple()).thenReturn(false);
// emulate that the provided field name is NOT correct
Map<String, Boolean> validationResult = new HashMap<String, Boolean>();
validationResult.put("field4", false);
when(validationService.evaluateJavaIdentifiers(new String[] { "field4" })).thenReturn(validationResult);
// emulate the user pressing the create button in the new field popup
newFieldPopup.onCreate();
// the error message should have been set
verify(newFieldPopupView, times(1)).setErrorMessage(anyString());
verify(view, times(1)).setTableHeight(DataObjectBrowser.DataObjectBrowserHelper.calculateTableHeight(3));
// no property should have been added.
assertEquals(3, dataObject.getProperties().size());
}
use of org.kie.workbench.common.screens.datamodeller.client.DataModelerContext in project kie-wb-common by kiegroup.
the class NewFieldPopupTest method doCreateFieldTest.
private void doCreateFieldTest(boolean createAndContinue) {
DataModelerContext context = DataModelerEditorsTestHelper.createTestContext();
NewFieldPopup newFieldPopup = new NewFieldPopup(view);
PopupHandler handler = new PopupHandler();
newFieldPopup.addPopupHandler(handler);
// simulate the data entered by user
when(view.getFieldName()).thenReturn("fieldName");
when(view.getFieldLabel()).thenReturn("fieldLabel");
when(view.getIsMultiple()).thenReturn(true);
when(view.getSelectedType()).thenReturn("java.lang.Integer");
newFieldPopup.init(context);
newFieldPopup.show();
// simulate the buttons clicking
if (createAndContinue) {
newFieldPopup.onCreateAndContinue();
} else {
newFieldPopup.onCreate();
}
verify(view, times(1)).getFieldName();
verify(view, times(1)).getFieldLabel();
verify(view, times(1)).getSelectedType();
verify(view, times(1)).getIsMultiple();
assertEquals("fieldName", handler.getFieldName());
assertEquals("fieldLabel", handler.getFieldLabel());
assertEquals(true, handler.isMultiple());
assertEquals("java.lang.Integer", handler.getType());
assertEquals(createAndContinue, handler.isCreateAndContinue());
assertEquals(false, handler.isCanceled());
}
use of org.kie.workbench.common.screens.datamodeller.client.DataModelerContext in project kie-wb-common by kiegroup.
the class PackageSelectorTest method selectedPackageChange.
@Test
public void selectedPackageChange() {
DataModelerContext context = createContext();
List<Pair<String, String>> expectedPackageList = expectedPackageList();
PackageSelector packageSelector = new PackageSelector(view);
packageSelector.setContext(context);
verify(view, times(1)).initPackageList(expectedPackageList, null, true);
packageSelector.setCurrentPackage("package2");
verify(view, times(1)).initPackageList(expectedPackageList, "package2", false);
}
use of org.kie.workbench.common.screens.datamodeller.client.DataModelerContext in project kie-wb-common by kiegroup.
the class PackageSelectorTest method loadEditorTest.
@Test
public void loadEditorTest() {
DataModelerContext context = createContext();
List<Pair<String, String>> expectedPackageList = expectedPackageList();
PackageSelector packageSelector = new PackageSelector(view);
packageSelector.setContext(context);
verify(view, times(1)).initPackageList(expectedPackageList, null, true);
}
Aggregations