Search in sources :

Example 21 with DecisionNavigatorItem

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

the class DecisionNavigatorTreeViewTest method testTreeItemUpdateTitle.

@Test
public void testTreeItemUpdateTitle() {
    final DecisionNavigatorItem item = mock(DecisionNavigatorItem.class);
    final HTMLElement element = mock(HTMLElement.class);
    final String label = "label";
    doReturn(item).when(treeItem).getItem();
    doReturn(element).when(treeItem).getElement();
    when(item.getLabel()).thenReturn(label);
    treeItem.updateTitle();
    verify(element).setAttribute("title", label);
}
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 22 with DecisionNavigatorItem

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

the class DecisionNavigatorTreeViewTest method testTreeItemUpdateCSSClassWhenItemHasChildrenAndIsReadOnly.

@Test
public void testTreeItemUpdateCSSClassWhenItemHasChildrenAndIsReadOnly() {
    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);
    when(readOnlyProvider.isReadOnlyDiagram()).thenReturn(true);
    treeItem.updateCSSClass();
    verify(classList).add(cssClass);
    verify(classList).add("parent-node");
    verify(classList, never()).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 23 with DecisionNavigatorItem

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

the class DecisionNavigatorTreeViewTest method testTreeItemUpdateLabel.

@Test
public void testTreeItemUpdateLabel() {
    final DecisionNavigatorItem item = mock(DecisionNavigatorItem.class);
    final Text textNode = mock(Text.class);
    final String label = "label";
    doReturn(item).when(treeItem).getItem();
    doReturn(textNode).when(treeItem).getTextNode(label);
    when(item.getLabel()).thenReturn(label);
    treeItem.updateLabel();
    assertEquals(label, inputText.value);
    verify(textContent).appendChild(textNode);
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) Text(elemental2.dom.Text) Test(org.junit.Test)

Example 24 with DecisionNavigatorItem

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

the class DecisionNavigatorTreeViewTest method testTreeItemSetup.

@Test
public void testTreeItemSetup() {
    final DecisionNavigatorItem expectedItem = mock(DecisionNavigatorItem.class);
    final Element children = mock(Element.class);
    doNothing().when(treeItem).updateDataUUID();
    doNothing().when(treeItem).updateTitle();
    doNothing().when(treeItem).updateCSSClass();
    doNothing().when(treeItem).updateLabel();
    doNothing().when(treeItem).updateSubItems(children);
    doNothing().when(treeItem).initOuiaComponentAttributes();
    final DecisionNavigatorTreeView.TreeItem actualTreeItem = treeItem.setup(expectedItem, children);
    final DecisionNavigatorItem actualItem = treeItem.getItem();
    verify(treeItem).updateDataUUID();
    verify(treeItem).updateTitle();
    verify(treeItem).updateCSSClass();
    verify(treeItem).updateLabel();
    verify(treeItem).updateSubItems(children);
    verify(treeItem).initOuiaComponentAttributes();
    assertEquals(treeItem, actualTreeItem);
    assertEquals(expectedItem, actualItem);
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) Element(elemental2.dom.Element) HTMLInputElement(elemental2.dom.HTMLInputElement) HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) HTMLUListElement(elemental2.dom.HTMLUListElement) HTMLDivElement(elemental2.dom.HTMLDivElement) Test(org.junit.Test)

Example 25 with DecisionNavigatorItem

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

the class DecisionNavigatorTreeViewTest method testSetup.

@Test
public void testSetup() {
    final List<DecisionNavigatorItem> items = new ArrayList<>();
    final Element element = mock(Element.class);
    doReturn(element).when(treeView).makeTree(items);
    treeView.setup(items);
    verify(this.items).appendChild(element);
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) Element(elemental2.dom.Element) HTMLInputElement(elemental2.dom.HTMLInputElement) HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) HTMLUListElement(elemental2.dom.HTMLUListElement) HTMLDivElement(elemental2.dom.HTMLDivElement) ArrayList(java.util.ArrayList) 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