use of org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem in project kie-wb-common by kiegroup.
the class DataTypeListShortcutsTest method testOnEscapeWhenCurrentDataTypeListItemIsNotPresent.
@Test
public void testOnEscapeWhenCurrentDataTypeListItemIsNotPresent() {
final DataTypeListItem listItem1 = mock(DataTypeListItem.class);
final DataTypeListItem listItem2 = mock(DataTypeListItem.class);
final List<DataTypeListItem> items = asList(listItem1, listItem2);
when(view.getCurrentDataTypeListItem()).thenReturn(Optional.empty());
when(view.getVisibleDataTypeListItems()).thenReturn(items);
shortcuts.onEscape();
verify(listItem1).disableEditMode();
verify(listItem2).disableEditMode();
verify(shortcuts, never()).highlight(any());
verify(shortcuts).reset();
}
use of org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem in project kie-wb-common by kiegroup.
the class DataTypeListShortcutsTest method testInit.
@Test
public void testInit() {
// The 'init' method is being called during the setup.
final DataTypeListItem listItem = mock(DataTypeListItem.class);
final HTMLElement htmlElement = mock(HTMLElement.class);
final DataTypeList actualDataTypeList = shortcuts.getDataTypeList();
final DataTypeList expectedDataTypeList = shortcuts.getDataTypeList();
when(listItem.getDragAndDropElement()).thenReturn(htmlElement);
assertEquals(expectedDataTypeList, actualDataTypeList);
verify(expectedDataTypeList).registerDataTypeListItemUpdateCallback(onDataTypeListItemUpdateArgumentCaptor.capture());
onDataTypeListItemUpdateArgumentCaptor.getValue().accept(listItem);
verify(view).highlight(htmlElement);
}
use of org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem in project kie-wb-common by kiegroup.
the class DataTypeSearchBarViewTest method testGroupElementWithItsParentWhenParentIsAtTheEndOfList.
@Test
public void testGroupElementWithItsParentWhenParentIsAtTheEndOfList() {
final DataTypeListItem item = mock(DataTypeListItem.class);
final DataTypeListItem parent = mock(DataTypeListItem.class);
final List<DataTypeListItem> groupedElements = new ArrayList<>();
groupedElements.add(parent);
final List<DataTypeListItem> allElements = Arrays.asList(parent);
final String parentUuid = "parent_uuid";
final HTMLElement itemDragAndDropElement = mock(HTMLElement.class);
final HTMLElement parentDragAndDropElement = mock(HTMLElement.class);
when(parent.getDragAndDropElement()).thenReturn(parentDragAndDropElement);
when(item.getDragAndDropElement()).thenReturn(itemDragAndDropElement);
when(itemDragAndDropElement.getAttribute(PARENT_UUID_ATTR)).thenReturn(parentUuid);
when(parentDragAndDropElement.getAttribute(UUID_ATTR)).thenReturn(parentUuid);
doReturn(true).when(view).isParentElementOnList(groupedElements, parentUuid);
doReturn(0).when(view).getIndexOfParentOrLastElementInGroup(groupedElements, parent);
view.groupElementWithItsParent(groupedElements, allElements, item);
assertEquals(2, groupedElements.size());
assertEquals(parent, groupedElements.get(0));
assertEquals(item, groupedElements.get(1));
verify(view, never()).groupElementWithItsParent(groupedElements, allElements, parent);
verify(view).getIndexOfParentOrLastElementInGroup(groupedElements, parent);
}
use of org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem in project kie-wb-common by kiegroup.
the class DataTypeSearchBarViewTest method testGroupElementWithItsParentWhenParentIsNotOnList.
@Test
public void testGroupElementWithItsParentWhenParentIsNotOnList() {
final DataTypeListItem item = mock(DataTypeListItem.class);
final DataTypeListItem parent = mock(DataTypeListItem.class);
final List<DataTypeListItem> groupedElements = new ArrayList<>();
final List<DataTypeListItem> allElements = Arrays.asList(parent);
final String parentUuid = "parent_uuid";
final HTMLElement itemDragAndDropElement = mock(HTMLElement.class);
final HTMLElement parentDragAndDropElement = mock(HTMLElement.class);
when(parent.getDragAndDropElement()).thenReturn(parentDragAndDropElement);
when(item.getDragAndDropElement()).thenReturn(itemDragAndDropElement);
when(itemDragAndDropElement.getAttribute(PARENT_UUID_ATTR)).thenReturn(parentUuid);
when(parentDragAndDropElement.getAttribute(UUID_ATTR)).thenReturn(parentUuid);
doReturn(false).when(view).isParentElementOnList(groupedElements, parentUuid);
doNothing().when(view).groupElementWithItsParent(groupedElements, allElements, parent);
view.groupElementWithItsParent(groupedElements, allElements, item);
assertEquals(1, groupedElements.size());
assertEquals(item, groupedElements.get(0));
verify(view).groupElementWithItsParent(groupedElements, allElements, parent);
verify(view, never()).getIndexOfParentOrLastElementInGroup(groupedElements, parent);
}
use of org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem in project kie-wb-common by kiegroup.
the class DataTypeSearchBarViewTest method testGetIndexOfParentOrLastElementInGroup.
@Test
public void testGetIndexOfParentOrLastElementInGroup() {
final DataTypeListItem parent = mock(DataTypeListItem.class);
final HTMLElement parentElement = mock(HTMLElement.class);
final String parentId = "parentId";
final List<DataTypeListItem> groupedElements = new ArrayList<>();
groupedElements.add(parent);
final int expectedIndex = 0;
when(parentElement.getAttribute(UUID_ATTR)).thenReturn(parentId);
when(parent.getDragAndDropElement()).thenReturn(parentElement);
final int index = view.getIndexOfParentOrLastElementInGroup(groupedElements, parent);
assertEquals(expectedIndex, index);
}
Aggregations