Search in sources :

Example 1 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 testInsertFieldBelowWhenTheNewDataTypeIsTopLevel.

@Test
public void testInsertFieldBelowWhenTheNewDataTypeIsTopLevel() {
    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(true);
    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).insertBelow(newDataType, reference);
}
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 2 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 testInsertFieldAboveWhenTheNewDataTypeIsTopLevel.

@Test
public void testInsertFieldAboveWhenTheNewDataTypeIsTopLevel() {
    final DNDListComponent dndListComponent = mock(DNDListComponent.class);
    final DataType newDataType = mock(DataType.class);
    final DataType reference = mock(DataType.class);
    final DataTypeListItem newListItem = mock(DataTypeListItem.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(true);
    when(newDataType.create(reference, ABOVE)).thenReturn(updatedDataTypes);
    when(dataTypeList.getDNDListComponent()).thenReturn(dndListComponent);
    when(dataTypeList.findItemByDataTypeHash(newDataTypeHash)).thenReturn(Optional.of(newListItem));
    when(dataTypeList.calculateParentHash(reference)).thenReturn(referenceDataTypeHash);
    doReturn(newDataTypeHash).when(listItem).getNewDataTypeHash(newDataType, referenceDataTypeHash);
    doReturn(dataTypeManager).when(dataTypeManager).fromNew();
    doReturn(newDataType).when(dataTypeManager).get();
    doReturn(reference).when(listItem).getDataType();
    listItem.insertFieldAbove();
    verify(listItem).closeEditMode();
    verify(dataTypeList).insertAbove(newDataType, reference);
    verify(dndListComponent).refreshItemsCSSAndHTMLPosition();
    verify(listItem).enableEditModeAndUpdateCallbacks(newDataTypeHash);
}
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 3 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 testGetPositionY.

@Test
public void testGetPositionY() {
    final DNDListComponent dndListComponent = mock(DNDListComponent.class);
    final Element element = mock(Element.class);
    final Integer expectedPositionY = 2;
    when(dataTypeList.getDNDListComponent()).thenReturn(dndListComponent);
    when(dndListComponent.getPositionY(element)).thenReturn(expectedPositionY);
    final Integer actualPositionY = listItem.getPositionY(element);
    assertEquals(expectedPositionY, actualPositionY);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) Element(elemental2.dom.Element) DNDListComponent(org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent) Test(org.junit.Test)

Example 4 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 testInsertFieldAboveWhenTheNewDataTypeIsNotTopLevel.

@Test
public void testInsertFieldAboveWhenTheNewDataTypeIsNotTopLevel() {
    final DNDListComponent dndListComponent = mock(DNDListComponent.class);
    final DataType newDataType = mock(DataType.class);
    final DataType reference = mock(DataType.class);
    final DataTypeListItem newListItem = mock(DataTypeListItem.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, ABOVE)).thenReturn(updatedDataTypes);
    when(dataTypeList.getDNDListComponent()).thenReturn(dndListComponent);
    when(dataTypeList.findItemByDataTypeHash(newDataTypeHash)).thenReturn(Optional.of(newListItem));
    when(dataTypeList.calculateParentHash(reference)).thenReturn(referenceDataTypeHash);
    doReturn(newDataTypeHash).when(listItem).getNewDataTypeHash(newDataType, referenceDataTypeHash);
    doReturn(dataTypeManager).when(dataTypeManager).fromNew();
    doReturn(newDataType).when(dataTypeManager).get();
    doReturn(reference).when(listItem).getDataType();
    listItem.insertFieldAbove();
    verify(listItem).closeEditMode();
    verify(dataTypeList).refreshItemsByUpdatedDataTypes(updatedDataTypes);
    verify(dndListComponent).refreshItemsCSSAndHTMLPosition();
    verify(listItem).enableEditModeAndUpdateCallbacks(newDataTypeHash);
}
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 5 with DNDListComponent

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

the class DataTypeListItem method setupDragAndDropComponent.

void setupDragAndDropComponent() {
    final DNDListComponent dragAndDropComponent = getDNDListComponent();
    this.dragAndDropElement = dragAndDropComponent.registerNewItem(getContentElement());
}
Also used : DNDListComponent(org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent)

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