Search in sources :

Example 1 with DecisionNavigatorItem

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

the class DecisionNavigatorTreeViewTest method testMakeTreeItemElement.

@Test
public void testMakeTreeItemElement() {
    final DecisionNavigatorItem item = makeItem("uuid");
    final DecisionNavigatorTreeView.TreeItem newTreeItem = mock(DecisionNavigatorTreeView.TreeItem.class);
    final DecisionNavigatorTreeView.TreeItem treeItem = mock(DecisionNavigatorTreeView.TreeItem.class);
    final Element childrenTree = mock(Element.class);
    final HTMLElement htmlElement = mock(HTMLElement.class);
    final elemental2.dom.HTMLElement expectedHtmlElement = mock(elemental2.dom.HTMLElement.class);
    doReturn(childrenTree).when(treeView).makeTree(item.getChildren());
    when(managedInstance.get()).thenReturn(newTreeItem);
    when(newTreeItem.setup(item, childrenTree)).thenReturn(treeItem);
    when(treeItem.getElement()).thenReturn(htmlElement);
    when(util.asHTMLElement(htmlElement)).thenReturn(expectedHtmlElement);
    final Element actualHtmlElement = treeView.makeTreeItemElement(item);
    assertEquals(expectedHtmlElement, actualHtmlElement);
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) 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 2 with DecisionNavigatorItem

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

the class DecisionNavigatorTreeViewTest method testTreeItemGetCSSClass.

@Test
public void testTreeItemGetCSSClass() {
    final String uuid = "uuid";
    final String label = "label";
    final DecisionNavigatorItem.Type subItem = CONTEXT;
    final Command onClick = () -> {
    /* Nothing. */
    };
    final String expectedCSSClass = "kie-context";
    final DecisionNavigatorItem item = new DecisionNavigatorItemBuilder().withUUID(uuid).withLabel(label).withType(subItem).withOnClick(onClick).build();
    final String actualCSSClass = treeItem.getCSSClass(item);
    assertEquals(expectedCSSClass, actualCSSClass);
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) DecisionNavigatorItemBuilder(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItemBuilder) Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Example 3 with DecisionNavigatorItem

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

the class DecisionNavigatorTreeViewTest method testTreeItemOnTextContentClick.

@Test
public void testTreeItemOnTextContentClick() {
    final ClickEvent event = mock(ClickEvent.class);
    final DecisionNavigatorItem item = mock(DecisionNavigatorItem.class);
    doReturn(item).when(treeItem).getItem();
    treeItem.onTextContentClick(event);
    verify(item).onClick();
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Test(org.junit.Test)

Example 4 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 5 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)

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