Search in sources :

Example 1 with DMNDiagramTuple

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

the class DRDContextMenuServiceTest method testAddToExistingDRD.

@Test
public void testAddToExistingDRD() {
    final DMNDiagramTuple diagramTuple = mockDmnDiagramTuple();
    final Diagram diagram = mock(Diagram.class);
    final Node graphNode = mock(Node.class);
    final View graphNodeDefinition = mock(View.class);
    final DMNDiagram dmnDiagram = spy(new DMNDiagram());
    final Collection<Node<? extends Definition<?>, Edge>> selectedNodes = mockNodes();
    selectedNodes.add(graphNode);
    when(diagramTuple.getStunnerDiagram()).thenReturn(diagram);
    when(diagram.getGraph()).thenReturn(graph);
    when(graph.nodes()).thenReturn(selectedNodes);
    when(graphNode.getContent()).thenReturn(graphNodeDefinition);
    when(graphNodeDefinition.getDefinition()).thenReturn(dmnDiagram);
    drdContextMenuService.addToExistingDRD(diagramTuple, selectedNodes);
    verify(graph).addNode(Mockito.<Node>any());
    verify(selectedEvent, times(1)).fire(Mockito.<DMNDiagramSelected>any());
}
Also used : DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram) DMNDiagramTuple(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple) Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram) Test(org.junit.Test)

Example 2 with DMNDiagramTuple

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

the class DRDContextMenuServiceTest method testGetDiagrams.

@Test
public void testGetDiagrams() {
    final DMNDiagramTuple dmnDiagramTuple = mock(DMNDiagramTuple.class);
    when(dmnDiagramsSession.getDMNDiagrams()).thenReturn(Collections.singletonList(dmnDiagramTuple));
    final List<DMNDiagramTuple> diagrams = drdContextMenuService.getDiagrams();
    assertThat(diagrams).isNotEmpty();
    assertThat(diagrams).hasSize(1);
    assertThat(diagrams).contains(dmnDiagramTuple);
}
Also used : DMNDiagramTuple(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple) Test(org.junit.Test)

Example 3 with DMNDiagramTuple

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

the class DRDContextMenuServiceTest method mockDmnDiagramTuple.

private DMNDiagramTuple mockDmnDiagramTuple() {
    final DMNDiagramTuple dmnDiagramTuple = mock(DMNDiagramTuple.class);
    final Diagram diagram = mock(Diagram.class);
    final DMNDiagramElement dmnDiagram = mock(DMNDiagramElement.class);
    final Id diagramId = new Id("DIAGRAM_ID");
    when(dmnDiagramTuple.getStunnerDiagram()).thenReturn(diagram);
    when(dmnDiagramTuple.getDMNDiagram()).thenReturn(dmnDiagram);
    when(dmnDiagram.getId()).thenReturn(diagramId);
    return dmnDiagramTuple;
}
Also used : DMNDiagramTuple(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)

Example 4 with DMNDiagramTuple

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

the class DRDContextMenuTest method testContextMenuHandler.

@Test
public void testContextMenuHandler() {
    final DMNDiagramTuple diagramTuple1 = new DMNDiagramTuple(mock(Diagram.class), new DMNDiagramElement());
    final DMNDiagramTuple diagramTuple2 = new DMNDiagramTuple(mock(Diagram.class), new DMNDiagramElement());
    final List<DMNDiagramTuple> diagrams = asList(diagramTuple1, diagramTuple2);
    final DMNDiagramElement diagramElement = mock(DMNDiagramElement.class);
    when(translationService.getValue(Mockito.<String>any())).thenReturn(StringUtils.EMPTY);
    when(drdContextMenuService.getDiagrams()).thenReturn(diagrams);
    when(dmnDiagramsSession.getDRGDiagramElement()).thenReturn(diagramElement);
    when(dmnDiagramsSession.getCurrentDMNDiagramElement()).thenReturn(Optional.of(diagramElement));
    drdContextMenu.setDRDContextMenuHandler(contextMenu, Collections.singletonList(node));
    verify(contextMenu).setHeaderMenu(any(), any());
    verify(contextMenu, times(4)).addTextMenuItem(any(), anyBoolean(), any());
}
Also used : DMNDiagramTuple(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Example 5 with DMNDiagramTuple

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

the class DecisionNavigatorItemsProviderTest method testGetItems.

@Test
public void testGetItems() {
    final Diagram stunnerDiagram1 = mock(Diagram.class);
    final Diagram stunnerDiagram2 = mock(Diagram.class);
    final DMNDiagramElement dmnDiagramElement1 = mock(DMNDiagramElement.class);
    final DMNDiagramElement dmnDiagramElement2 = mock(DMNDiagramElement.class);
    final DMNDiagramTuple dmnDiagramTuple1 = new DMNDiagramTuple(stunnerDiagram1, dmnDiagramElement1);
    final DMNDiagramTuple dmnDiagramTuple2 = new DMNDiagramTuple(stunnerDiagram2, dmnDiagramElement2);
    final DecisionNavigatorItem decisionNavigatorItem1 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem2 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem3 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem4 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem5 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem6 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem7 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem8 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem9 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem10 = mock(DecisionNavigatorItem.class);
    final List<DMNDiagramTuple> diagramTuples = asList(dmnDiagramTuple1, dmnDiagramTuple2);
    final Node node1 = mockNode(new Decision());
    final Node node2 = mockNode(new InputData());
    final Node node3 = mockNode(new TextAnnotation());
    final Node node4 = mockNode(new BusinessKnowledgeModel());
    final Node node5 = mockNode(new KnowledgeSource());
    final Node node6 = mockNode(new TextAnnotation());
    final Stream<Node> stunnerNodes1 = Stream.of(node1, node2, node3);
    final Stream<Node> stunnerNodes2 = Stream.of(node4, node5, node6);
    when(dmnDiagramElement1.getName()).thenReturn(new Name("DRD"));
    when(dmnDiagramElement2.getName()).thenReturn(new Name("DRG"));
    when(dmnDiagramsSession.getDMNDiagrams()).thenReturn(diagramTuples);
    when(itemFactory.makeRoot(dmnDiagramTuple1)).thenReturn(decisionNavigatorItem1);
    when(itemFactory.makeRoot(dmnDiagramTuple2)).thenReturn(decisionNavigatorItem2);
    when(itemFactory.makeItem(node1)).thenReturn(decisionNavigatorItem5);
    when(itemFactory.makeItem(node2)).thenReturn(decisionNavigatorItem6);
    when(itemFactory.makeItem(node3)).thenReturn(decisionNavigatorItem7);
    when(itemFactory.makeItem(node4)).thenReturn(decisionNavigatorItem8);
    when(itemFactory.makeItem(node5)).thenReturn(decisionNavigatorItem9);
    when(itemFactory.makeItem(node6)).thenReturn(decisionNavigatorItem10);
    when(itemFactory.makeSeparator(DRG)).thenReturn(decisionNavigatorItem3);
    when(itemFactory.makeSeparator(DRDs)).thenReturn(decisionNavigatorItem4);
    when(dmnDiagramUtils.getNodeStream(stunnerDiagram1)).thenReturn(stunnerNodes1);
    when(dmnDiagramUtils.getNodeStream(stunnerDiagram2)).thenReturn(stunnerNodes2);
    final List<DecisionNavigatorItem> actualItems = itemsProvider.getItems();
    final List<DecisionNavigatorItem> expectedItems = asList(decisionNavigatorItem3, decisionNavigatorItem2, decisionNavigatorItem4, decisionNavigatorItem1);
    assertEquals(expectedItems, actualItems);
    verify(decisionNavigatorItem1).addChild(decisionNavigatorItem5);
    verify(decisionNavigatorItem1).addChild(decisionNavigatorItem6);
    verify(decisionNavigatorItem1).addChild(decisionNavigatorItem7);
    verify(decisionNavigatorItem2).addChild(decisionNavigatorItem8);
    verify(decisionNavigatorItem2).addChild(decisionNavigatorItem9);
    verify(decisionNavigatorItem2).addChild(decisionNavigatorItem10);
}
Also used : DMNDiagramTuple(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple) Node(org.kie.workbench.common.stunner.core.graph.Node) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) Test(org.junit.Test)

Aggregations

DMNDiagramTuple (org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple)7 Test (org.junit.Test)6 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)6 DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)5 DMNDiagram (org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)4 Node (org.kie.workbench.common.stunner.core.graph.Node)4 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)3 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)3 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)3 DecisionNavigatorItem (org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem)2 Graph (org.kie.workbench.common.stunner.core.graph.Graph)2 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)1 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)1 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)1 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)1 TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)1 View (org.kie.workbench.common.stunner.core.graph.content.view.View)1