use of org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent in project kie-wb-common by kiegroup.
the class DataTypeListItemTest method testSetPositionY.
@Test
public void testSetPositionY() {
final DNDListComponent dndListComponent = mock(DNDListComponent.class);
final Element element = mock(Element.class);
final int positionY = 2;
when(dataTypeList.getDNDListComponent()).thenReturn(dndListComponent);
listItem.setPositionY(element, positionY);
verify(dndListComponent).setPositionY(element, positionY);
}
use of org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent in project kie-wb-common by kiegroup.
the class DataTypeSearchBarTest method testGetDataTypeListItemsSortedByPositionY.
@Test
public void testGetDataTypeListItemsSortedByPositionY() {
final DataTypeListItem list0 = mock(DataTypeListItem.class);
final DataTypeListItem list1 = mock(DataTypeListItem.class);
final HTMLElement element0 = mock(HTMLElement.class);
final HTMLElement element1 = mock(HTMLElement.class);
final DNDListComponent dndListComponent = mock(DNDListComponent.class);
final Integer positionY0 = 3;
final Integer positionY1 = 2;
final Map<String, Integer> store = new HashMap<>();
when(dndListComponent.getPositionY(element0)).thenReturn(positionY0);
when(dndListComponent.getPositionY(element1)).thenReturn(positionY1);
when(list0.getDragAndDropElement()).thenReturn(element0);
when(list1.getDragAndDropElement()).thenReturn(element1);
when(dataTypeList.getItems()).thenReturn(asList(list0, list1));
when(dataTypeList.getDNDListComponent()).thenReturn(dndListComponent);
doReturn(store).when(searchBar).getDataTypeListPositionsStore();
final List<DataTypeListItem> actualListItems = searchBar.getDataTypeListItemsSortedByPositionY();
final List<DataTypeListItem> expectedListItems = asList(list1, list0);
assertEquals(expectedListItems, actualListItems);
}
use of org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent in project kie-wb-common by kiegroup.
the class DataTypeSearchBarViewTest method testShowSearchResults.
@Test
public void testShowSearchResults() {
final DNDListComponent dndListComponent = mock(DNDListComponent.class);
final DataType dataType0 = mock(DataType.class);
final DataType dataType1 = mock(DataType.class);
final DataType dataType2 = mock(DataType.class);
final DataTypeListItem listItem0 = mock(DataTypeListItem.class);
final DataTypeListItem listItem1 = mock(DataTypeListItem.class);
final DataTypeListItem listItem2 = mock(DataTypeListItem.class);
final DataTypeListItem listItem3 = mock(DataTypeListItem.class);
final HTMLElement element0 = mock(HTMLElement.class);
final HTMLElement element1 = mock(HTMLElement.class);
final HTMLElement element2 = mock(HTMLElement.class);
final HTMLElement element3 = mock(HTMLElement.class);
final List<DataType> results = asList(dataType0, dataType1, dataType2);
final List<DataTypeListItem> listItems = asList(listItem0, listItem1, listItem2, listItem3);
element0.classList = mock(DOMTokenList.class);
element1.classList = mock(DOMTokenList.class);
element2.classList = mock(DOMTokenList.class);
element3.classList = mock(DOMTokenList.class);
when(listItem0.getDataType()).thenReturn(dataType0);
when(listItem1.getDataType()).thenReturn(dataType1);
when(listItem2.getDataType()).thenReturn(dataType2);
when(listItem0.getDragAndDropElement()).thenReturn(element0);
when(listItem1.getDragAndDropElement()).thenReturn(element1);
when(listItem2.getDragAndDropElement()).thenReturn(element2);
when(listItem3.getDragAndDropElement()).thenReturn(element3);
when(presenter.getDataTypeListItemsSortedByPositionY()).thenReturn(listItems);
when(presenter.getDNDListComponent()).thenReturn(dndListComponent);
doNothing().when(view).enableSearch();
view.showSearchResults(results);
verify(element0.classList).remove(HIDDEN_CSS_CLASS);
verify(element1.classList).remove(HIDDEN_CSS_CLASS);
verify(element2.classList).remove(HIDDEN_CSS_CLASS);
verify(element3.classList).add(HIDDEN_CSS_CLASS);
verify(dndListComponent).setPositionY(element0, 0);
verify(dndListComponent).setPositionY(element1, 1);
verify(dndListComponent).setPositionY(element2, 2);
verify(dndListComponent).setPositionY(element3, -1);
verify(dndListComponent).refreshItemsPosition();
verify(dndListComponent).refreshDragAreaSize();
verify(listItem0).expand();
verify(listItem1).expand();
verify(listItem2).expand();
verify(view).enableSearch();
verify(view).groupElementsWithItsParents(listItems);
verify(view).expandListItems(listItems);
}
use of org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent in project kie-wb-common by kiegroup.
the class DataTypeSearchBarTest method testRestoreDataTypeListPositionsWhenSearchBarHasDataTypeListPositionsStored.
@Test
public void testRestoreDataTypeListPositionsWhenSearchBarHasDataTypeListPositionsStored() {
final DataType dataType0 = mock(DataType.class);
final DataType dataType1 = mock(DataType.class);
final DataTypeListItem list0 = mock(DataTypeListItem.class);
final DataTypeListItem list1 = mock(DataTypeListItem.class);
final HTMLElement element0 = mock(HTMLElement.class);
final HTMLElement element1 = mock(HTMLElement.class);
final DNDListComponent dndListComponent = mock(DNDListComponent.class);
final List<DataTypeListItem> items = asList(list0, list1);
final String uuid0 = "0000-0000-0000-0000";
final String uuid1 = "1111-1111-1111-1111";
final Integer positionY0 = 2;
final Integer positionY1 = -1;
final Map<String, Integer> store = spy(new Maps.Builder<String, Integer>().put(uuid0, positionY0).put(uuid1, positionY1).build());
final Map<String, Boolean> collapsedStore = spy(new Maps.Builder<String, Boolean>().put(uuid0, false).put(uuid1, true).build());
element0.classList = mock(DOMTokenList.class);
element1.classList = mock(DOMTokenList.class);
when(dndListComponent.getPositionY(element0)).thenReturn(positionY0);
when(dndListComponent.getPositionY(element1)).thenReturn(positionY1);
when(list0.getDragAndDropElement()).thenReturn(element0);
when(list1.getDragAndDropElement()).thenReturn(element1);
when(list0.getDataType()).thenReturn(dataType0);
when(list1.getDataType()).thenReturn(dataType1);
when(dataType0.getUUID()).thenReturn(uuid0);
when(dataType1.getUUID()).thenReturn(uuid1);
when(dataTypeList.getItems()).thenReturn(items);
when(dataTypeList.getDNDListComponent()).thenReturn(dndListComponent);
doReturn(store).when(searchBar).getDataTypeListPositionsStore();
doReturn(collapsedStore).when(searchBar).getDataTypeListCollapsedStatusStore();
searchBar.restoreDataTypeListPositions();
verify(dndListComponent).setPositionY(element0, positionY0);
verify(dndListComponent).setPositionY(element1, positionY1);
verify(element0.classList).remove(HIDDEN_CSS_CLASS);
verify(element1.classList).add(HIDDEN_CSS_CLASS);
verify(dndListComponent).refreshItemsPosition();
verify(list0, never()).collapse();
verify(list1).collapse();
verify(store).clear();
verify(collapsedStore).clear();
}
use of org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent in project kie-wb-common by kiegroup.
the class DataTypeSearchBarTest method testStoreDataTypeListPositionsWhenSearchBarDoesNotHaveDataTypeListPositionsStored.
@Test
public void testStoreDataTypeListPositionsWhenSearchBarDoesNotHaveDataTypeListPositionsStored() {
final DataType dataType0 = mock(DataType.class);
final DataType dataType1 = mock(DataType.class);
final DataTypeListItem list0 = mock(DataTypeListItem.class);
final DataTypeListItem list1 = mock(DataTypeListItem.class);
final HTMLElement element0 = mock(HTMLElement.class);
final HTMLElement element1 = mock(HTMLElement.class);
final DNDListComponent dndListComponent = mock(DNDListComponent.class);
final List<DataTypeListItem> items = asList(list0, list1);
final String uuid0 = "0000-0000-0000-0000";
final String uuid1 = "1111-1111-1111-1111";
final Integer positionY0 = 2;
final Integer positionY1 = 4;
final Map<String, Integer> store = new HashMap<>();
when(dndListComponent.getPositionY(element0)).thenReturn(positionY0);
when(dndListComponent.getPositionY(element1)).thenReturn(positionY1);
when(list0.getDragAndDropElement()).thenReturn(element0);
when(list1.getDragAndDropElement()).thenReturn(element1);
when(list0.getDataType()).thenReturn(dataType0);
when(list1.getDataType()).thenReturn(dataType1);
when(dataType0.getUUID()).thenReturn(uuid0);
when(dataType1.getUUID()).thenReturn(uuid1);
when(dataTypeList.getItems()).thenReturn(items);
when(dataTypeList.getDNDListComponent()).thenReturn(dndListComponent);
doReturn(store).when(searchBar).getDataTypeListPositionsStore();
searchBar.storeDataTypeListPositions();
assertEquals(2, store.size());
assertEquals(positionY0, store.get(uuid0));
assertEquals(positionY1, store.get(uuid1));
}
Aggregations