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