Search in sources :

Example 1 with DecisionNavigatorItemBuilder

use of org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItemBuilder 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 2 with DecisionNavigatorItemBuilder

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

the class DecisionNavigatorBaseItemFactoryTest method testMakeItem.

@Test
@SuppressWarnings("unchecked")
public void testMakeItem() {
    final String itemUUID = "itemUUID";
    final String childUUID = "childUUID";
    final String graphUUID = "graphUUID";
    final String label = "label";
    final Command onClick = mock(Command.class);
    final Node<Definition, Edge> diagramNode = mock(Node.class);
    final Definition diagramDefinition = mock(Definition.class);
    final DMNDiagram diagram = mock(DMNDiagram.class);
    final DecisionNavigatorItem child = new DecisionNavigatorItemBuilder().withUUID(childUUID).build();
    final List<DecisionNavigatorItem> nestedItems = singletonList(child);
    when(node.getUUID()).thenReturn(itemUUID);
    doReturn(label).when(factory).getLabel(node);
    doReturn(onClick).when(factory).makeOnClickCommand(node);
    doReturn(nestedItems).when(factory).makeNestedItems(node);
    when(graph.nodes()).thenReturn(Collections.singletonList(diagramNode));
    when(diagramNode.getContent()).thenReturn(diagramDefinition);
    when(diagramDefinition.getDefinition()).thenReturn(diagram);
    when(diagramNode.getUUID()).thenReturn(graphUUID);
    final DecisionNavigatorItem item = factory.makeItem(node, ITEM);
    assertEquals(itemUUID, item.getUUID());
    assertEquals(label, item.getLabel());
    assertTrue(item.getOnClick().isPresent());
    assertEquals(onClick, item.getOnClick().get());
    assertEquals(asTreeSet(child), item.getChildren());
    assertEquals(itemUUID, child.getParentUUID());
}
Also used : DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram) 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) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 DecisionNavigatorItem (org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem)2 DecisionNavigatorItemBuilder (org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItemBuilder)2 Command (org.uberfire.mvp.Command)2 DMNDiagram (org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)1 Edge (org.kie.workbench.common.stunner.core.graph.Edge)1 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)1