Search in sources :

Example 6 with DecisionNavigatorItem

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

the class DecisionNavigatorItemFactoryTest method testGetOnUpdate.

@Test
public void testGetOnUpdate() {
    final DMNDiagramElement dmnDiagramElement = mock(DMNDiagramElement.class);
    final DecisionNavigatorItem item = mock(DecisionNavigatorItem.class);
    final Name dmnDiagramElementName = new Name();
    final String newDiagramName = "New diagram name";
    when(item.getLabel()).thenReturn(newDiagramName);
    when(dmnDiagramElement.getName()).thenReturn(dmnDiagramElementName);
    factory.getOnUpdate(dmnDiagramElement).accept(item);
    verify(selectedEvent).fire(diagramSelectedArgumentCaptor.capture());
    final DMNDiagramElement actualDiagram = diagramSelectedArgumentCaptor.getValue().getDiagramElement();
    assertEquals(dmnDiagramElement, actualDiagram);
    assertEquals(newDiagramName, actualDiagram.getName().getValue());
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 7 with DecisionNavigatorItem

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

the class DecisionNavigatorItemFactoryTest method testMakeSeparator.

@Test
public void testMakeSeparator() {
    final String drds = "DRDs";
    final DecisionNavigatorItem drdSeparator = factory.makeSeparator(drds);
    assertEquals(drds, drdSeparator.getLabel());
    assertEquals(SEPARATOR, drdSeparator.getType());
    assertNotNull(drdSeparator.getUUID());
    assertNull(drdSeparator.getParentUUID());
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) Test(org.junit.Test)

Example 8 with DecisionNavigatorItem

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

the class DecisionNavigatorTreeViewTest method testTreeItemInitOuiaAttributes.

@Test
public void testTreeItemInitOuiaAttributes() {
    final DecisionNavigatorItem item = mock(DecisionNavigatorItem.class);
    final Text textNode = mock(Text.class);
    final String label = "label";
    final HTMLElement element = mock(HTMLElement.class);
    doReturn(element).when(treeItem).getElement();
    doReturn(item).when(treeItem).getItem();
    doReturn(DECISION).when(item).getType();
    doReturn(textNode).when(treeItem).getTextNode(label);
    when(item.getLabel()).thenReturn(label);
    treeItem.initOuiaComponentAttributes();
    verify(element).setAttribute(OuiaComponentTypeAttribute.COMPONENT_TYPE, "dmn-graph-navigator-decision");
    verify(element).setAttribute(OuiaComponentIdAttribute.COMPONENT_ID, "dmn-graph-navigator-decision-label");
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) Text(elemental2.dom.Text) Test(org.junit.Test)

Example 9 with DecisionNavigatorItem

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

the class DecisionNavigatorTreeViewTest method testOnRemoveClick.

@Test
public void testOnRemoveClick() {
    final HTMLElement element = mock(HTMLElement.class);
    final DecisionNavigatorItem item = mock(DecisionNavigatorItem.class);
    final ClickEvent event = mock(ClickEvent.class);
    final org.jboss.errai.common.client.dom.DOMTokenList tokenList = mock(org.jboss.errai.common.client.dom.DOMTokenList.class);
    doReturn(element).when(treeItem).getElement();
    doReturn(item).when(treeItem).getItem();
    when(element.getClassList()).thenReturn(tokenList);
    treeItem.onRemoveClick(event);
    verify(item).onRemove();
    verify(locker).fire(any());
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Test(org.junit.Test)

Example 10 with DecisionNavigatorItem

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

the class DecisionNavigatorTreeViewTest method testTreeItemUpdateCSSClassWhenItemDoesNotHaveChildren.

@Test
public void testTreeItemUpdateCSSClassWhenItemDoesNotHaveChildren() {
    final DecisionNavigatorItem item = mock(DecisionNavigatorItem.class);
    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.isEditable()).thenReturn(false);
    treeItem.updateCSSClass();
    verify(classList).add(cssClass);
    verify(classList, never()).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) 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