use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListTest method testRemoveItemByUUID.
@Test
public void testRemoveItemByUUID() {
final DataType dataType0 = mock(DataType.class);
final DataType dataType1 = mock(DataType.class);
final DataTypeListItem dataTypeListItem0 = mock(DataTypeListItem.class);
final DataTypeListItem dataTypeListItem1 = mock(DataTypeListItem.class);
final List<DataTypeListItem> items = new ArrayList<>(asList(dataTypeListItem0, dataTypeListItem1));
when(dataType0.getUUID()).thenReturn("012");
when(dataType1.getUUID()).thenReturn("345");
when(dataTypeListItem0.getDataType()).thenReturn(dataType0);
when(dataTypeListItem1.getDataType()).thenReturn(dataType1);
when(dataTypeList.getItems()).thenReturn(items);
dataTypeList.removeItem("012");
final List expected = singletonList(dataTypeListItem1);
final List<DataTypeListItem> actual = dataTypeList.getItems();
assertEquals(expected, actual);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListTest method testInsertAbove.
@Test
public void testInsertAbove() {
final DataType dataType = mock(DataType.class);
final DataType reference = mock(DataType.class);
final DataTypeListItem listItem = mock(DataTypeListItem.class);
doReturn(listItem).when(dataTypeList).makeListItem(dataType);
dataTypeList.insertAbove(dataType, reference);
verify(view).insertAbove(listItem, reference);
verify(dndListComponent).consolidateYPosition();
verify(dndListComponent).refreshItemsPosition();
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListTest method testMakeListItemWithDataType.
@Test
public void testMakeListItemWithDataType() {
final DataType dataType = mock(DataType.class);
final DataTypeListItem expectedListItem = mock(DataTypeListItem.class);
doReturn(expectedListItem).when(dataTypeList).makeListItem();
doReturn(new ArrayList<>()).when(dataTypeList).getItems();
final DataTypeListItem actualListItem = dataTypeList.makeListItem(dataType);
final List<DataTypeListItem> actualItems = dataTypeList.getItems();
final List expectedItems = singletonList(expectedListItem);
verify(expectedListItem).setupDataType(dataType, 1);
assertEquals(expectedListItem, actualListItem);
assertEquals(expectedItems, actualItems);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListTest method testReplace.
@Test
public void testReplace() {
final DataType newDataType = mock(DataType.class);
final DataType existing = mock(DataType.class);
doNothing().when(dataTypeList).insert(newDataType);
dataTypeList.replace(existing, newDataType);
verify(dndDataTypesHandler).deleteKeepingReferences(existing);
verify(dataTypeList).insert(newDataType);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListTest method testCreateNewDataTypeFromPropertyWhenIsList.
@Test
public void testCreateNewDataTypeFromPropertyWhenIsList() {
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(dataProperty.isList()).thenReturn(true);
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(true);
verify(newType).setName(propertyName);
}
Aggregations