Search in sources :

Example 11 with DecisionNavigatorItem

use of org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem in project kie-wb-common by kiegroup.

the class DecisionNavigatorTreeViewTest method testTreeItemUpdateCSSClassWhenItemHasChildren.

@Test
public void testTreeItemUpdateCSSClassWhenItemHasChildren() {
    final DecisionNavigatorItem item = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem child = mock(DecisionNavigatorItem.class);
    final TreeSet<DecisionNavigatorItem> children = new TreeSet<DecisionNavigatorItem>() {

        {
            add(child);
        }
    };
    final org.jboss.errai.common.client.dom.DOMTokenList classList = mock(org.jboss.errai.common.client.dom.DOMTokenList.class);
    final HTMLElement element = mock(HTMLElement.class);
    final String cssClass = "css-class";
    doReturn(item).when(treeItem).getItem();
    doReturn(element).when(treeItem).getElement();
    doReturn(cssClass).when(treeItem).getCSSClass(item);
    when(element.getClassList()).thenReturn(classList);
    when(item.getChildren()).thenReturn(children);
    when(item.isEditable()).thenReturn(true);
    treeItem.updateCSSClass();
    verify(classList).add(cssClass);
    verify(classList).add("parent-node");
    verify(classList).add("editable");
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) TreeSet(java.util.TreeSet) Test(org.junit.Test)

Example 12 with DecisionNavigatorItem

use of org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem in project kie-wb-common by kiegroup.

the class DecisionNavigatorTreeViewTest method testSave.

@Test
public void testSave() {
    final HTMLElement element = mock(HTMLElement.class);
    final DecisionNavigatorItem item = mock(DecisionNavigatorItem.class);
    final org.jboss.errai.common.client.dom.DOMTokenList tokenList = mock(org.jboss.errai.common.client.dom.DOMTokenList.class);
    doNothing().when(treeItem).updateLabel();
    doReturn(element).when(treeItem).getElement();
    doReturn(item).when(treeItem).getItem();
    when(element.getClassList()).thenReturn(tokenList);
    treeItem.save();
    verify(item).setLabel(inputText.value);
    verify(tokenList).remove("editing");
    verify(treeItem).updateLabel();
    verify(item).onUpdate();
    verify(locker).fire(any());
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) Test(org.junit.Test)

Example 13 with DecisionNavigatorItem

use of org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem in project kie-wb-common by kiegroup.

the class DecisionNavigatorBaseItemFactory method makeItem.

public DecisionNavigatorItem makeItem(final Node<View, Edge> node, final DecisionNavigatorItem.Type type) {
    final String uuid = node.getUUID();
    final String label = getLabel(node);
    final Command onClick = makeOnClickCommand(node);
    final List<DecisionNavigatorItem> nestedItems = makeNestedItems(node);
    final DecisionNavigatorItem item = navigatorItemBuilder().withUUID(uuid).withLabel(label).withType(type).withOnClick(onClick).build();
    nestedItems.forEach(item::addChild);
    return item;
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) Command(org.uberfire.mvp.Command)

Example 14 with DecisionNavigatorItem

use of org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem in project kie-wb-common by kiegroup.

the class DecisionNavigatorNestedItemFactoryTest method testMakeItem.

@Test
public void testMakeItem() {
    final String uuid = "uuid";
    final String label = "label";
    final DecisionNavigatorItem.Type type = DECISION_TABLE;
    final Command command = mock(Command.class);
    final String parentUUID = "parentUUID";
    when(node.getUUID()).thenReturn(parentUUID);
    doReturn(uuid).when(factory).getUUID(node);
    doReturn(label).when(factory).getLabel(node);
    doReturn(type).when(factory).getType(node);
    doReturn(command).when(factory).makeOnClickCommand(node, parentUUID);
    final DecisionNavigatorItem item = factory.makeItem(node);
    assertTrue(item.getOnClick().isPresent());
    assertEquals(command, item.getOnClick().get());
    assertEquals(uuid, item.getUUID());
    assertEquals(label, item.getLabel());
    assertEquals(type, item.getType());
    assertEquals(parentUUID, item.getParentUUID());
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Example 15 with DecisionNavigatorItem

use of org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem in project kie-wb-common by kiegroup.

the class DecisionNavigatorTreePresenterTest method testListIndex.

@Test
public void testListIndex() {
    final DecisionNavigatorItem item1 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem item2 = mock(DecisionNavigatorItem.class);
    final List<DecisionNavigatorItem> items = Arrays.asList(item1, item2);
    presenter.index(items);
    verify(presenter).index(item1);
    verify(presenter).index(item2);
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) Test(org.junit.Test)

Aggregations

DecisionNavigatorItem (org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem)29 Test (org.junit.Test)27 HTMLElement (org.jboss.errai.common.client.dom.HTMLElement)13 Command (org.uberfire.mvp.Command)5 Element (elemental2.dom.Element)4 HTMLDivElement (elemental2.dom.HTMLDivElement)4 HTMLInputElement (elemental2.dom.HTMLInputElement)4 HTMLUListElement (elemental2.dom.HTMLUListElement)4 DMNDiagram (org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)4 DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)4 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)4 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)3 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)3 Graph (org.kie.workbench.common.stunner.core.graph.Graph)3 Node (org.kie.workbench.common.stunner.core.graph.Node)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 Text (elemental2.dom.Text)2 ArrayList (java.util.ArrayList)2 TreeSet (java.util.TreeSet)2 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)2