Search in sources :

Example 11 with Definition

use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.

the class TextAnnotationTextPropertyProviderImplTest method checkSupportsTextAnnotationElements.

@Test
@SuppressWarnings("unchecked")
public void checkSupportsTextAnnotationElements() {
    assertTrue(provider.supports(element));
    final Element other = mock(Element.class);
    final Definition otherContent = mock(Definition.class);
    final InputData otherDefinition = mock(InputData.class);
    when(other.getContent()).thenReturn(otherContent);
    when(otherContent.getDefinition()).thenReturn(otherDefinition);
    assertFalse(provider.supports(other));
}
Also used : Element(org.kie.workbench.common.stunner.core.graph.Element) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Test(org.junit.Test)

Example 12 with Definition

use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.

the class DMNGraphProcessor method getNodes.

@Override
public Iterable<? extends Node> getNodes(final Graph<?, ?> graph) {
    final List<Node> nodes = new ArrayList();
    graph.nodes().forEach(nodes::add);
    for (final Node n : graph.nodes()) {
        final Definition def = (Definition) n.getContent();
        if (def.getDefinition() instanceof DecisionService) {
            final List<Node> childNodes = getChildNodes(n);
            nodes.removeAll(childNodes);
            // All edges that points to nodes inside DS now points to DS
            for (final Node o : childNodes) {
                replacedNodes.put(o.getUUID(), n.getUUID());
            }
        }
    }
    return nodes;
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService)

Example 13 with Definition

use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.

the class DRGElementTextPropertyProviderImplTest method checkSupportsDRGElement.

@Test
@SuppressWarnings("unchecked")
public void checkSupportsDRGElement() {
    assertTrue(provider.supports(element));
    final Element other = mock(Element.class);
    final Definition otherContent = mock(Definition.class);
    final TextAnnotation otherDefinition = mock(TextAnnotation.class);
    when(other.getContent()).thenReturn(otherContent);
    when(otherContent.getDefinition()).thenReturn(otherDefinition);
    assertFalse(provider.supports(other));
}
Also used : Element(org.kie.workbench.common.stunner.core.graph.Element) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) Test(org.junit.Test)

Example 14 with Definition

use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.

the class DecisionTableEditorDefinitionEnricherTest method testModelEnrichmentWhenTopLevelDecisionTableWithoutInputData.

@Test
public void testModelEnrichmentWhenTopLevelDecisionTableWithoutInputData() {
    final String uuid = UUID.uuid();
    final Node<Definition, Edge> node = new NodeImpl<>(uuid);
    graph.addNode(node);
    final Optional<DecisionTable> oModel = definition.getModelClass();
    definition.enrich(Optional.of(uuid), decision, oModel);
    final DecisionTable model = oModel.get();
    assertBasicEnrichment(model);
    assertStandardInputClauseEnrichment(model);
    assertStandardOutputClauseEnrichment(model);
    assertStandardDecisionRuleEnrichment(model);
    assertParentHierarchyEnrichment(model);
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 15 with Definition

use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition 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)

Aggregations

Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)111 Node (org.kie.workbench.common.stunner.core.graph.Node)61 Test (org.junit.Test)46 Element (org.kie.workbench.common.stunner.core.graph.Element)31 Edge (org.kie.workbench.common.stunner.core.graph.Edge)25 Graph (org.kie.workbench.common.stunner.core.graph.Graph)20 ArrayList (java.util.ArrayList)16 Optional (java.util.Optional)14 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)14 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)14 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)14 View (org.kie.workbench.common.stunner.core.graph.content.view.View)12 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)11 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)10 List (java.util.List)9 Before (org.junit.Before)9 DMNDiagram (org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)9 HasContentDefinitionId (org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId)9 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)9 Stream (java.util.stream.Stream)8