use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListTest method testRefreshItemsByUpdatedDataTypes.
@Test
public void testRefreshItemsByUpdatedDataTypes() {
final String uuid1 = "uuid1";
final String uuid2 = "uuid2";
final String uuid3 = "uuid3";
final DataType dataType1 = mock(DataType.class);
final DataType dataType2 = mock(DataType.class);
final DataType dataType3 = mock(DataType.class);
final DataTypeListItem listItem = mock(DataTypeListItem.class);
final List<DataType> subDataTypes = asList(dataType2, dataType3);
final List<DataType> existingItems = new ArrayList<>(asList(dataType1, dataType2, dataType3));
doReturn(Optional.of(listItem)).when(dataTypeList).findItem(dataType1);
doReturn(Optional.empty()).when(dataTypeList).findItem(dataType2);
doReturn(Optional.empty()).when(dataTypeList).findItem(dataType3);
doNothing().when(dataTypeList).refreshSubItemsFromListItem(any(), anyListOf(DataType.class));
when(dataType1.getUUID()).thenReturn(uuid1);
when(dataType2.getUUID()).thenReturn(uuid2);
when(dataType3.getUUID()).thenReturn(uuid3);
when(dataType1.getSubDataTypes()).thenReturn(subDataTypes);
dataTypeList.refreshItemsByUpdatedDataTypes(existingItems);
verify(listItem).refresh();
verify(dataTypeList).refreshSubItemsFromListItem(listItem, subDataTypes);
verify(dndListComponent).consolidateYPosition();
verify(dndListComponent).refreshItemsPosition();
verify(searchBar).refresh();
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListTest method testAddDataTypeWithDefinedDataType.
@Test
public void testAddDataTypeWithDefinedDataType() {
final DataTypeListItem listItem = mock(DataTypeListItem.class);
final DataType dataType = mock(DataType.class);
doReturn(listItem).when(dataTypeList).makeListItem(dataType);
dataTypeList.addDataType(dataType, false);
verify(searchBar).reset();
verify(dataType).create();
verify(view).showOrHideNoCustomItemsMessage();
verify(listItem).refresh();
verify(listItem, never()).enableEditMode();
verify(dndListComponent).refreshItemsCSSAndHTMLPosition();
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListTest method testInsertProperties.
@Test
public void testInsertProperties() {
final DataObject dataObject = mock(DataObject.class);
final String myImportedClass = "org.MyClass";
final DataType existingDt = mock(DataType.class);
final DataTypeListItem dtListItem = mock(DataTypeListItem.class);
final Optional<DataTypeListItem> dtListItemOptional = Optional.of(dtListItem);
final DataObjectProperty property1 = mock(DataObjectProperty.class);
final DataObjectProperty property2 = mock(DataObjectProperty.class);
final List<DataObjectProperty> properties = Arrays.asList(property1, property2);
final DataType property1DataType = mock(DataType.class);
final DataType property2DataType = mock(DataType.class);
when(dataObject.getClassType()).thenReturn(myImportedClass);
when(dataObject.getProperties()).thenReturn(properties);
doReturn(Optional.of(existingDt)).when(dataTypeList).findDataTypeByName(myImportedClass);
doReturn(dtListItemOptional).when(dataTypeList).findItem(existingDt);
doReturn(property1DataType).when(dataTypeList).createNewDataType(property1);
doReturn(property2DataType).when(dataTypeList).createNewDataType(property2);
dataTypeList.insertProperties(dataObject);
verify(dtListItem).insertNestedField(property1DataType);
verify(dtListItem).insertNestedField(property2DataType);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListTest method testRemoveItemByDataType.
@Test
public void testRemoveItemByDataType() {
final DataType dataType = mock(DataType.class);
final String uuid = "uuid";
doNothing().when(dataTypeList).removeItem(Mockito.<String>any());
when(dataType.getUUID()).thenReturn(uuid);
dataTypeList.removeItem(dataType);
verify(dataTypeList).removeItem(uuid);
verify(view).removeItem(dataType);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListTest method testFindItemWhenItemExists.
@Test
public void testFindItemWhenItemExists() {
final String uuid1 = "uuid1";
final String uuid2 = "uuid2";
final DataType dataType1 = mock(DataType.class);
final DataType dataType2 = mock(DataType.class);
final DataTypeListItem dataTypeListItem1 = mock(DataTypeListItem.class);
final DataTypeListItem dataTypeListItem2 = mock(DataTypeListItem.class);
final List<DataTypeListItem> existingItems = new ArrayList<>(asList(dataTypeListItem1, dataTypeListItem2));
when(dataType1.getUUID()).thenReturn(uuid1);
when(dataType2.getUUID()).thenReturn(uuid2);
when(dataTypeListItem1.getDataType()).thenReturn(dataType1);
when(dataTypeListItem2.getDataType()).thenReturn(dataType2);
when(dataTypeList.getItems()).thenReturn(existingItems);
final Optional<DataTypeListItem> item = dataTypeList.findItem(dataType1);
assertEquals(dataTypeListItem1, item.get());
}
Aggregations