use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListTest method testCreateNewDataTypeFromProperty.
@Test
public void testCreateNewDataTypeFromProperty() {
final DataObjectProperty dataProperty = mock(DataObjectProperty.class);
final String propertyName = "name";
final String propertyType = "type";
final DataType newType = mock(DataType.class);
when(dataProperty.getProperty()).thenReturn(propertyName);
when(dataProperty.getType()).thenReturn(propertyType);
when(dataTypeManager.fromNew()).thenReturn(dataTypeManager);
when(dataTypeManager.asList(anyBoolean())).thenReturn(dataTypeManager);
when(dataTypeManager.withType(propertyType)).thenReturn(dataTypeManager);
when(dataTypeManager.get()).thenReturn(newType);
final DataType actual = dataTypeList.createNewDataType(dataProperty);
assertEquals(newType, actual);
verify(dataTypeManager).asList(false);
verify(newType).setName(propertyName);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListTest method testImportDataObjects.
@Test
public void testImportDataObjects() {
final DataObject present = mock(DataObject.class);
final DataObject notPresent = mock(DataObject.class);
final List<DataObject> selectedDataObjects = asList(present, notPresent);
final DataType presentDataType = mock(DataType.class);
final DataType notPresentDataType = mock(DataType.class);
final String notPresentClass = "not.present";
final String importedPresentClass = "org.something.MyClass";
final DataType existingDataType = mock(DataType.class);
doReturn(presentDataType).when(dataTypeList).createNewDataType(present);
doReturn(notPresentDataType).when(dataTypeList).createNewDataType(notPresent);
doReturn(Optional.of(existingDataType)).when(dataTypeList).findDataTypeByName(importedPresentClass);
doReturn(Optional.empty()).when(dataTypeList).findDataTypeByName(notPresentClass);
doNothing().when(dataTypeList).replace(existingDataType, presentDataType);
doNothing().when(dataTypeList).insertProperties(present);
doNothing().when(dataTypeList).insertProperties(notPresent);
doNothing().when(dataTypeList).insert(notPresentDataType);
doNothing().when(dataTypeList).removeFullQualifiedNames(selectedDataObjects);
when(notPresent.getClassType()).thenReturn(notPresentClass);
when(present.getClassType()).thenReturn(importedPresentClass);
dataTypeList.importDataObjects(selectedDataObjects);
verify(dataTypeList).findDataTypeByName(importedPresentClass);
verify(dataTypeList).replace(existingDataType, presentDataType);
verify(dataTypeList).insertProperties(present);
verify(dataTypeList, never()).insert(presentDataType);
verify(dataTypeList).insert(notPresentDataType);
verify(dataTypeList).insertProperties(notPresent);
verify(dataTypeList).removeFullQualifiedNames(selectedDataObjects);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListItemViewTest method testSetupSubDataTypesCSSClassWhenDataTypeHasSubDataTypes.
@Test
public void testSetupSubDataTypesCSSClassWhenDataTypeHasSubDataTypes() {
final DataType dataType = mock(DataType.class);
dragAndDropElement.classList = mock(DOMTokenList.class);
when(dataType.hasSubDataTypes()).thenReturn(true);
view.setupSubDataTypesCSSClass(dataType);
verify(dragAndDropElement.classList).add("has-sub-data-types");
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListItemViewTest method testSetupSubDataTypesCSSClassWhenDataTypeDoesNotHaveSubDataTypes.
@Test
public void testSetupSubDataTypesCSSClassWhenDataTypeDoesNotHaveSubDataTypes() {
final DataType dataType = mock(DataType.class);
dragAndDropElement.classList = mock(DOMTokenList.class);
when(dataType.hasSubDataTypes()).thenReturn(false);
view.setupSubDataTypesCSSClass(dataType);
verify(dragAndDropElement.classList).remove("has-sub-data-types");
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListItemViewTest method testIsOnFocusModeWhenItReturnsFalse.
@Test
public void testIsOnFocusModeWhenItReturnsFalse() {
final DataType dataType = mock(DataType.class);
final Element dataTypeRow = mock(Element.class);
dataTypeRow.classList = mock(DOMTokenList.class);
doReturn(dataType).when(view).getDataType();
doReturn(dataTypeRow).when(view).getRowElement(dataType);
when(dataTypeRow.classList.contains(FOCUSED_CSS_CLASS)).thenReturn(false);
assertFalse(view.isOnFocusMode());
}
Aggregations