Search in sources :

Example 6 with DNDListComponent

use of org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent in project kie-wb-common by kiegroup.

the class DataTypeListItemTest method testInsertFieldBelowWhenTheNewDataTypeIsNotTopLevel.

@Test
public void testInsertFieldBelowWhenTheNewDataTypeIsNotTopLevel() {
    final DNDListComponent dndListComponent = mock(DNDListComponent.class);
    final DataType newDataType = mock(DataType.class);
    final DataType reference = mock(DataType.class);
    final List<DataType> updatedDataTypes = asList(mock(DataType.class), mock(DataType.class));
    final String referenceDataTypeHash = "tDataType.id";
    final String newDataTypeHash = "tDataType.name";
    when(newDataType.isTopLevel()).thenReturn(false);
    when(newDataType.create(reference, BELOW)).thenReturn(updatedDataTypes);
    when(dataTypeList.calculateParentHash(reference)).thenReturn(referenceDataTypeHash);
    when(dataTypeList.getDNDListComponent()).thenReturn(dndListComponent);
    doReturn(newDataTypeHash).when(listItem).getNewDataTypeHash(newDataType, referenceDataTypeHash);
    doReturn(dataTypeManager).when(dataTypeManager).fromNew();
    doReturn(newDataType).when(dataTypeManager).get();
    doReturn(reference).when(listItem).getDataType();
    listItem.insertFieldBelow();
    verify(listItem).closeEditMode();
    verify(listItem).enableEditModeAndUpdateCallbacks(newDataTypeHash);
    verify(dataTypeList).refreshItemsByUpdatedDataTypes(updatedDataTypes);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) DNDListComponent(org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent) Test(org.junit.Test)

Example 7 with DNDListComponent

use of org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent in project kie-wb-common by kiegroup.

the class DataTypeListItemTest method testSetupIndentationLevel.

@Test
public void testSetupIndentationLevel() {
    final HTMLElement dragAndDropElement = mock(HTMLElement.class);
    final DNDListComponent dndListComponent = mock(DNDListComponent.class);
    when(dataTypeList.getDNDListComponent()).thenReturn(dndListComponent);
    doReturn(dragAndDropElement).when(listItem).getDragAndDropElement();
    doReturn(5).when(listItem).getLevel();
    listItem.setupIndentationLevel();
    verify(dndListComponent).setPositionX(dragAndDropElement, 4);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) DNDListComponent(org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent) Test(org.junit.Test)

Example 8 with DNDListComponent

use of org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent in project kie-wb-common by kiegroup.

the class DataTypeListItemTest method testGetDragAndDropListElement.

@Test
public void testGetDragAndDropListElement() {
    final DNDListComponent dndListComponent = mock(DNDListComponent.class);
    final HTMLElement expectedHTMLElement = mock(HTMLElement.class);
    when(dataTypeList.getDNDListComponent()).thenReturn(dndListComponent);
    when(dndListComponent.getElement()).thenReturn(expectedHTMLElement);
    final HTMLElement actualHTMLElement = listItem.getDragAndDropListElement();
    assertEquals(expectedHTMLElement, actualHTMLElement);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) DNDListComponent(org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent) Test(org.junit.Test)

Example 9 with DNDListComponent

use of org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent in project kie-wb-common by kiegroup.

the class DataTypeListItemTest method testSetupDragAndDropComponent.

@Test
public void testSetupDragAndDropComponent() {
    final DNDListComponent dragAndDropComponent = mock(DNDListComponent.class);
    final HTMLElement htmlElement = mock(HTMLElement.class);
    final HTMLElement expectedElement = mock(HTMLElement.class);
    when(dataTypeList.getDNDListComponent()).thenReturn(dragAndDropComponent);
    when(listItem.getContentElement()).thenReturn(htmlElement);
    when(dragAndDropComponent.registerNewItem(htmlElement)).thenReturn(expectedElement);
    listItem.setupDragAndDropComponent();
    final HTMLElement actualElement = listItem.getDragAndDropElement();
    assertEquals(expectedElement, actualElement);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) DNDListComponent(org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent) Test(org.junit.Test)

Example 10 with DNDListComponent

use of org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent in project kie-wb-common by kiegroup.

the class DataTypeListItemTest method testSetPositionX.

@Test
public void testSetPositionX() {
    final DNDListComponent dndListComponent = mock(DNDListComponent.class);
    final Element element = mock(Element.class);
    final int positionX = 2;
    when(dataTypeList.getDNDListComponent()).thenReturn(dndListComponent);
    listItem.setPositionX(element, positionX);
    verify(dndListComponent).setPositionX(element, positionX);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) Element(elemental2.dom.Element) DataTypeConstraint(org.kie.workbench.common.dmn.client.editors.types.listview.constraint.DataTypeConstraint) DNDListComponent(org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent) Test(org.junit.Test)

Aggregations

DNDListComponent (org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent)16 Test (org.junit.Test)15 HTMLElement (elemental2.dom.HTMLElement)10 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)7 DataTypeListItem (org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem)4 Element (elemental2.dom.Element)3 DOMTokenList (elemental2.dom.DOMTokenList)2 HashMap (java.util.HashMap)2 DataTypeConstraint (org.kie.workbench.common.dmn.client.editors.types.listview.constraint.DataTypeConstraint)2