Search in sources :

Example 1 with TreeListItem

use of org.kie.workbench.common.dmn.client.editors.types.imported.treelist.TreeListItem in project kie-wb-common by kiegroup.

the class ImportDataObjectModalView method addItems.

@Override
public void addItems(final List<DataObject> dataObjects) {
    final List<TreeListItem> dataObjectItems = new ArrayList<>();
    for (final DataObject data : dataObjects) {
        dataObjectItems.add(createTreeListItem(data));
    }
    treeList.populate(dataObjectItems);
    itemsContainer.appendChild(treeList.getElement());
}
Also used : DataObject(org.kie.workbench.common.dmn.api.editors.types.DataObject) ArrayList(java.util.ArrayList) TreeListItem(org.kie.workbench.common.dmn.client.editors.types.imported.treelist.TreeListItem)

Example 2 with TreeListItem

use of org.kie.workbench.common.dmn.client.editors.types.imported.treelist.TreeListItem in project kie-wb-common by kiegroup.

the class ImportDataObjectModalView method createTreeListItem.

TreeListItem createTreeListItem(final DataObject data) {
    final TreeListItem item = items.get();
    item.setDataSource(data);
    item.setDescription(data.getClassType());
    return item;
}
Also used : TreeListItem(org.kie.workbench.common.dmn.client.editors.types.imported.treelist.TreeListItem)

Example 3 with TreeListItem

use of org.kie.workbench.common.dmn.client.editors.types.imported.treelist.TreeListItem in project kie-wb-common by kiegroup.

the class ImportDataObjectModalViewTest method testGetSelectedItems.

@Test
public void testGetSelectedItems() {
    final TreeListItem listItem1 = mock(TreeListItem.class);
    final DataObject dataObject1 = mock(DataObject.class);
    final TreeListItem listItem2 = mock(TreeListItem.class);
    final DataObject dataObject2 = mock(DataObject.class);
    when(listItem1.getDataSource()).thenReturn(dataObject1);
    when(listItem2.getDataSource()).thenReturn(dataObject2);
    final List<TreeListItem> selectedItems = Arrays.asList(listItem1, listItem2);
    when(treeList.getSelectedItems()).thenReturn(selectedItems);
    final List<DataObject> actual = view.getSelectedItems();
    assertEquals(2, actual.size());
    assertTrue(actual.contains(dataObject1));
    assertTrue(actual.contains(dataObject2));
}
Also used : DataObject(org.kie.workbench.common.dmn.api.editors.types.DataObject) TreeListItem(org.kie.workbench.common.dmn.client.editors.types.imported.treelist.TreeListItem) Test(org.junit.Test)

Example 4 with TreeListItem

use of org.kie.workbench.common.dmn.client.editors.types.imported.treelist.TreeListItem in project kie-wb-common by kiegroup.

the class ImportDataObjectModalViewTest method testCreateTreeListItem.

@Test
public void testCreateTreeListItem() {
    final TreeListItem item = mock(TreeListItem.class);
    when(items.get()).thenReturn(item);
    final String myClass = "my class";
    final DataObject data = new DataObject(myClass);
    final TreeListItem actual = view.createTreeListItem(data);
    assertEquals(item, actual);
    verify(item).setDescription(myClass);
}
Also used : DataObject(org.kie.workbench.common.dmn.api.editors.types.DataObject) TreeListItem(org.kie.workbench.common.dmn.client.editors.types.imported.treelist.TreeListItem) Test(org.junit.Test)

Example 5 with TreeListItem

use of org.kie.workbench.common.dmn.client.editors.types.imported.treelist.TreeListItem in project kie-wb-common by kiegroup.

the class ImportDataObjectModalViewTest method testAddItems.

@Test
public void testAddItems() {
    final String d1Name = "ClassOne";
    final String d2Name = "ClassTwo";
    final String d3Name = "ClassThree";
    final DataObject d1 = new DataObject(d1Name);
    final DataObject d2 = new DataObject(d2Name);
    final DataObject d3 = new DataObject(d3Name);
    final List<DataObject> dataObjects = Arrays.asList(d1, d2, d3);
    final TreeListItem list1 = mock(TreeListItem.class);
    final TreeListItem list2 = mock(TreeListItem.class);
    final TreeListItem list3 = mock(TreeListItem.class);
    doReturn(list1).when(view).createTreeListItem(d1);
    doReturn(list2).when(view).createTreeListItem(d2);
    doReturn(list3).when(view).createTreeListItem(d3);
    view.addItems(dataObjects);
    verify(itemsContainer).appendChild(treeListElement);
    verify(treeList).populate(itemsCaptor.capture());
    final List<TreeListItem> dataObjectItems = itemsCaptor.getValue();
    assertEquals(3, dataObjectItems.size());
    assertTrue(dataObjectItems.contains(list1));
    assertTrue(dataObjectItems.contains(list2));
    assertTrue(dataObjectItems.contains(list3));
}
Also used : DataObject(org.kie.workbench.common.dmn.api.editors.types.DataObject) TreeListItem(org.kie.workbench.common.dmn.client.editors.types.imported.treelist.TreeListItem) Test(org.junit.Test)

Aggregations

TreeListItem (org.kie.workbench.common.dmn.client.editors.types.imported.treelist.TreeListItem)6 DataObject (org.kie.workbench.common.dmn.api.editors.types.DataObject)5 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)1