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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations