use of org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem 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.DataTypeListItem 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));
}
use of org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem in project kie-wb-common by kiegroup.
the class DataTypeListShortcutsViewTest method testGetVisibleDataTypeListItems.
@Test
public void testGetVisibleDataTypeListItems() {
final DataTypeList dataTypeList = mock(DataTypeList.class);
final DataTypeListItem item1 = mock(DataTypeListItem.class);
final DataTypeListItem item2 = mock(DataTypeListItem.class);
final DataTypeListItem item3 = mock(DataTypeListItem.class);
final DataType dataType1 = fakeDataType("123");
final DataType dataType2 = fakeDataType("456");
final DataType dataType3 = fakeDataType("789");
final Element dataTypeRow1 = fakeDataTypeRow("123");
final Element dataTypeRow2 = fakeDataTypeRow("456");
final Element dataTypeRow3 = fakeDataTypeRow("789");
final List<DataTypeListItem> items = asList(item1, item2, item3);
final JQueryList<Element> jQueryList = mock(JQueryList.class);
when(item1.getDataType()).thenReturn(dataType1);
when(item2.getDataType()).thenReturn(dataType2);
when(item3.getDataType()).thenReturn(dataType3);
when(dataTypeList.getItems()).thenReturn(items);
when(presenter.getDataTypeList()).thenReturn(dataTypeList);
jQueryList.length = 3;
when(jQueryList.get(0)).thenReturn(dataTypeRow1);
when(jQueryList.get(1)).thenReturn(dataTypeRow2);
when(jQueryList.get(2)).thenReturn(dataTypeRow3);
doReturn(jQueryList).when(view).filterVisible();
final List<DataTypeListItem> actual = view.getVisibleDataTypeListItems();
final List<DataTypeListItem> expected = asList(item1, item2, item3);
assertEquals(expected, actual);
}
use of org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem in project kie-wb-common by kiegroup.
the class DataTypeListShortcutsViewTest method testFocusInWhenCurrentUUIDIsBlank.
@Test
public void testFocusInWhenCurrentUUIDIsBlank() {
final DataTypeListItem listItem = mock(DataTypeListItem.class);
final HTMLElement element = mock(HTMLElement.class);
when(listItem.getDragAndDropElement()).thenReturn(element);
doReturn("").when(view).getCurrentUUID();
doReturn("uuid").when(view).getPreviousUUID();
doReturn(Optional.of(listItem)).when(view).getDataTypeListItem("uuid");
doNothing().when(view).highlight(any());
view.focusIn();
verify(view).highlight(element);
}
use of org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem in project kie-wb-common by kiegroup.
the class DataTypeListShortcutsViewTest method testGetCurrentDataTypeListItem.
@Test
public void testGetCurrentDataTypeListItem() {
final DataTypeList dataTypeList = mock(DataTypeList.class);
final DataTypeListItem item = mock(DataTypeListItem.class);
final DataType dataType = fakeDataType("123");
final Element dataTypeRow1 = fakeDataTypeRow("123");
final Element dataTypeRow2 = fakeDataTypeRow("456");
final Element dataTypeRow3 = fakeDataTypeRow("789");
final JQueryList<Element> jQueryList = mock(JQueryList.class);
final List<DataTypeListItem> items = singletonList(item);
when(item.getDataType()).thenReturn(dataType);
when(dataTypeList.getItems()).thenReturn(items);
when(presenter.getDataTypeList()).thenReturn(dataTypeList);
jQueryList.length = 3;
when(jQueryList.get(0)).thenReturn(dataTypeRow1);
when(jQueryList.get(1)).thenReturn(dataTypeRow2);
when(jQueryList.get(2)).thenReturn(dataTypeRow3);
doReturn(jQueryList).when(view).filterVisible();
doReturn("123").when(view).getCurrentUUID();
final DataTypeListItem actual = view.getCurrentDataTypeListItem().orElseThrow(RuntimeException::new);
assertEquals(item, actual);
}
Aggregations