Search in sources :

Example 1 with DMNDiagramElement

use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.

the class ObserverBuilderControlTest method testUpdateDMNDiagramIdFromSelectedDMNDiagram.

@Test
public void testUpdateDMNDiagramIdFromSelectedDMNDiagram() {
    final DRGElement newDefinition = mock(DRGElement.class);
    final Element element = mock(Element.class);
    final View elementContent = mock(View.class);
    final Object definition = mock(Object.class);
    final String selectedDiagramId = "selected diagram id";
    final DMNDiagramElement selectedDiagram = mock(DMNDiagramElement.class);
    final Id id = mock(Id.class);
    when(id.getValue()).thenReturn(selectedDiagramId);
    when(selectedDiagram.getId()).thenReturn(id);
    when(dmnDiagramsSession.getCurrentDMNDiagramElement()).thenReturn(Optional.of(selectedDiagram));
    when(elementContent.getDefinition()).thenReturn(newDefinition);
    when(element.getContent()).thenReturn(elementContent);
    observerBuilderControl.updateElementFromDefinition(element, definition);
    verify(newDefinition).setDiagramId(selectedDiagramId);
}
Also used : DMNElement(org.kie.workbench.common.dmn.api.definition.model.DMNElement) Element(org.kie.workbench.common.stunner.core.graph.Element) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) ArgumentMatchers.anyObject(org.mockito.ArgumentMatchers.anyObject) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) View(org.kie.workbench.common.stunner.core.graph.content.view.View) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 2 with DMNDiagramElement

use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.

the class DRDContextMenuServiceTest method testAddToNewDRD.

@Test
public void testAddToNewDRD() {
    final Collection<Node<? extends Definition<?>, Edge>> nodes = mock(Collection.class);
    final Definitions definitions = mock(Definitions.class);
    final Diagram drgDiagram = mock(Diagram.class);
    final List<DMNDiagramElement> diagramElements = mock(List.class);
    when(dmnDiagramsSession.getDRGDiagram()).thenReturn(drgDiagram);
    when(dmnDiagramUtils.getDefinitions(drgDiagram)).thenReturn(definitions);
    when(definitions.getDiagramElements()).thenReturn(diagramElements);
    drdContextMenuService.addToNewDRD(nodes);
    verify(diagramElements, times(1)).add(Mockito.<DMNDiagramElement>any());
    verify(dmnDiagramsSession, times(1)).add(Mockito.<DMNDiagramElement>any(), Mockito.<Diagram>any());
    verify(selectedEvent, times(1)).fire(Mockito.<DMNDiagramSelected>any());
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) 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) Test(org.junit.Test)

Example 3 with DMNDiagramElement

use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement 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 DMNDiagramElement

use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.

the class DRDContextMenuService method addToNewDRD.

public void addToNewDRD(final Collection<Node<? extends Definition<?>, Edge>> selectedNodes) {
    final DMNDiagramElement dmnElement = makeDmnDiagramElement();
    final Diagram stunnerElement = buildStunnerElement(dmnElement);
    selectedNodes.forEach(addNodesToDRD(dmnElement, stunnerElement));
    addDmnDiagramElementToDRG(dmnElement);
    dmnDiagramsSession.add(dmnElement, stunnerElement);
    selectedEvent.fire(new DMNDiagramSelected(dmnElement));
}
Also used : DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) DMNDiagramSelected(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramSelected) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)

Example 5 with DMNDiagramElement

use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement 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)

Aggregations

DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)35 Test (org.junit.Test)23 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)21 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)13 DMNDiagram (org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)10 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)8 Node (org.kie.workbench.common.stunner.core.graph.Node)7 View (org.kie.workbench.common.stunner.core.graph.content.view.View)6 DMNDiagramTuple (org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple)5 Graph (org.kie.workbench.common.stunner.core.graph.Graph)5 DecisionNavigatorItem (org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem)4 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)3 HasContentDefinitionId (org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId)3 JSONString (com.google.gwt.json.client.JSONString)2 QName (javax.xml.namespace.QName)2 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)2 DMNElement (org.kie.workbench.common.dmn.api.definition.model.DMNElement)2