Search in sources :

Example 21 with DataType

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);
}
Also used : ArrayList(java.util.ArrayList) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 22 with DataType

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();
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 23 with DataType

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);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 24 with DataType

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);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 25 with DataType

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);
}
Also used : DataObjectProperty(org.kie.workbench.common.dmn.api.editors.types.DataObjectProperty) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Aggregations

DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)274 Test (org.junit.Test)245 HTMLElement (elemental2.dom.HTMLElement)44 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)39 Element (elemental2.dom.Element)30 ArrayList (java.util.ArrayList)26 DOMTokenList (elemental2.dom.DOMTokenList)24 DataTypeListItem (org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem)14 HTMLDivElement (elemental2.dom.HTMLDivElement)13 HTMLButtonElement (elemental2.dom.HTMLButtonElement)12 Command (org.uberfire.mvp.Command)12 FlashMessage (org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage)9 DataTypeManager (org.kie.workbench.common.dmn.client.editors.types.common.DataTypeManager)9 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)8 DNDListComponent (org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)7 HTMLAnchorElement (elemental2.dom.HTMLAnchorElement)6 HTMLInputElement (elemental2.dom.HTMLInputElement)6 DataObject (org.kie.workbench.common.dmn.api.editors.types.DataObject)6