Search in sources :

Example 16 with DataObject

use of org.kie.workbench.common.dmn.api.editors.types.DataObject 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 17 with DataObject

use of org.kie.workbench.common.dmn.api.editors.types.DataObject 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 18 with DataObject

use of org.kie.workbench.common.dmn.api.editors.types.DataObject 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)

Example 19 with DataObject

use of org.kie.workbench.common.dmn.api.editors.types.DataObject in project kie-wb-common by kiegroup.

the class ImportDataObjectModalViewTest method testOnSelectionChanged.

@Test
public void testOnSelectionChanged() {
    final DataObject do1 = mock(DataObject.class);
    final DataObject do2 = mock(DataObject.class);
    final DataObject do3 = mock(DataObject.class);
    final TreeListItem treeListItem1 = mock(TreeListItem.class);
    final TreeListItem treeListItem2 = mock(TreeListItem.class);
    final TreeListItem treeListItem3 = mock(TreeListItem.class);
    when(treeListItem1.getDataSource()).thenReturn(do1);
    when(treeListItem2.getDataSource()).thenReturn(do2);
    when(treeListItem3.getDataSource()).thenReturn(do3);
    view.onSelectionChanged(Arrays.asList(treeListItem1, treeListItem2, treeListItem3));
    verify(presenter).onDataObjectSelectionChanged(dataObjectsCaptor.capture());
    final List<DataObject> values = dataObjectsCaptor.getValue();
    assertEquals(3, values.size());
    assertThat(values).containsExactly(do1, do2, do3);
}
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 20 with DataObject

use of org.kie.workbench.common.dmn.api.editors.types.DataObject in project kie-wb-common by kiegroup.

the class ImportDataObjectModalTest method testOnDataObjectSelectionChangedAndDoesntHasDuplicatedName.

@Test
public void testOnDataObjectSelectionChangedAndDoesntHasDuplicatedName() {
    final String name1 = "name1";
    final String name2 = "name2";
    final String name3 = "name3";
    final List<String> existingDataTypes = Arrays.asList("unique1", "unique2", "unique3");
    final DataObject do1 = createDataObject(name1);
    final DataObject do2 = createDataObject(name2);
    final DataObject do3 = createDataObject(name3);
    final List<DataObject> dataObjects = Arrays.asList(do1, do2, do3);
    doReturn(existingDataTypes).when(modal).getExistingDataTypes();
    modal.onDataObjectSelectionChanged(dataObjects);
    verify(view, never()).showDataTypeWithSameNameWarning();
    verify(view).hideDataTypeWithSameNameWarning();
}
Also used : DataObject(org.kie.workbench.common.dmn.api.editors.types.DataObject) Test(org.junit.Test)

Aggregations

DataObject (org.kie.workbench.common.dmn.api.editors.types.DataObject)21 Test (org.junit.Test)13 TreeListItem (org.kie.workbench.common.dmn.client.editors.types.imported.treelist.TreeListItem)5 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)4 DataObjectProperty (org.kie.workbench.common.dmn.api.editors.types.DataObjectProperty)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Consumer (java.util.function.Consumer)1 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)1 BuiltInType (org.kie.workbench.common.dmn.api.property.dmn.types.BuiltInType)1 KieModule (org.kie.workbench.common.services.shared.project.KieModule)1 ServiceCallback (org.kie.workbench.common.stunner.core.client.service.ServiceCallback)1