Search in sources :

Example 21 with Definition

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

the class DMNMarshallerTest method testWithIncludedModelsWhenNodeAlreadyHasImports.

@Test
public void testWithIncludedModelsWhenNodeAlreadyHasImports() {
    final DMNMarshaller dmnMarshaller = spy(new DMNMarshaller());
    final Node node = mock(Node.class);
    final Definition nodeDefinition = mock(Definition.class);
    final DRGElement drgElement = mock(DRGElement.class);
    final Definitions definitionsStunnerPojo = mock(Definitions.class);
    final Import import1 = mock(Import.class);
    final Import import2 = mock(Import.class);
    final List<Import> diagramImports = new ArrayList<>(asList(import1, import2));
    final DMNDiagram nodeDiagram = mock(DMNDiagram.class);
    final Definitions nodeDiagramDefinitions = mock(Definitions.class);
    final List<Import> nodeDiagramImports = new ArrayList<>(asList(import1, import2));
    when(node.getContent()).thenReturn(nodeDefinition);
    when(nodeDefinition.getDefinition()).thenReturn(drgElement);
    when(definitionsStunnerPojo.getImport()).thenReturn(diagramImports);
    when(drgElement.getParent()).thenReturn(nodeDiagram);
    when(nodeDiagram.getDefinitions()).thenReturn(nodeDiagramDefinitions);
    when(nodeDiagramDefinitions.getImport()).thenReturn(nodeDiagramImports);
    dmnMarshaller.withIncludedModels(node, definitionsStunnerPojo);
    assertEquals(2, nodeDiagramImports.size());
    assertTrue(nodeDiagramImports.contains(import1));
    assertTrue(nodeDiagramImports.contains(import2));
}
Also used : JSIDMNDiagram(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNDiagram) DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram) Import(org.kie.workbench.common.dmn.api.definition.model.Import) Node(org.kie.workbench.common.stunner.core.graph.Node) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) JSITDefinitions(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) ArrayList(java.util.ArrayList) JSITDRGElement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDRGElement) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 22 with Definition

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

the class DMNMarshallerTest method testWithIncludedModelsWhenNodeParentIsDefinitions.

@Test
public void testWithIncludedModelsWhenNodeParentIsDefinitions() {
    final DMNMarshaller dmnMarshaller = spy(new DMNMarshaller());
    final Node node = mock(Node.class);
    final Definition nodeDefinition = mock(Definition.class);
    final DRGElement drgElement = mock(DRGElement.class);
    final Definitions definitionsStunnerPojo = mock(Definitions.class);
    final Import import1 = mock(Import.class);
    final Import import2 = mock(Import.class);
    final List<Import> diagramImports = new ArrayList<>(asList(import1, import2));
    final Definitions nodeDiagramDefinitions = mock(Definitions.class);
    final List<Import> nodeDiagramImports = new ArrayList<>();
    when(node.getContent()).thenReturn(nodeDefinition);
    when(nodeDefinition.getDefinition()).thenReturn(drgElement);
    when(definitionsStunnerPojo.getImport()).thenReturn(diagramImports);
    when(drgElement.getParent()).thenReturn(nodeDiagramDefinitions);
    when(nodeDiagramDefinitions.getImport()).thenReturn(nodeDiagramImports);
    dmnMarshaller.withIncludedModels(node, definitionsStunnerPojo);
    assertEquals(2, nodeDiagramImports.size());
    assertTrue(nodeDiagramImports.contains(import1));
    assertTrue(nodeDiagramImports.contains(import2));
}
Also used : Import(org.kie.workbench.common.dmn.api.definition.model.Import) Node(org.kie.workbench.common.stunner.core.graph.Node) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) JSITDefinitions(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) ArrayList(java.util.ArrayList) JSITDRGElement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDRGElement) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 23 with Definition

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

the class BaseExpressionGridGeneralTest method testSelectHeaderCellWithDomainObjectInStunnerGraph.

@Test
public void testSelectHeaderCellWithDomainObjectInStunnerGraph() {
    grid.getModel().appendColumn(new RowNumberColumn());
    grid.getModel().appendColumn(new RowNumberColumn());
    // Mock graph to contain decision
    final Definition definition = mock(Definition.class);
    when(node.getUUID()).thenReturn(NODE_UUID);
    when(node.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(decision);
    // Mock grid to dispatch header selection as a DomainObject
    doAnswer(i -> {
        grid.fireDomainObjectSelectionEvent(decision);
        return null;
    }).when(grid).doAfterHeaderSelectionChange(anyInt(), anyInt());
    grid.selectHeaderCell(0, 1, false, false);
    assertHeaderSelection();
    verify(refreshFormPropertiesEvent).fire(refreshFormPropertiesEventCaptor.capture());
    final RefreshFormPropertiesEvent refreshFormPropertiesEvent = refreshFormPropertiesEventCaptor.getValue();
    assertThat(refreshFormPropertiesEvent.getUuid()).isEqualTo(NODE_UUID);
    assertThat(refreshFormPropertiesEvent.getSession()).isEqualTo(session);
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent) Test(org.junit.Test)

Example 24 with Definition

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

the class DecisionServiceParametersListWidgetTest method createNodeWithContentDefinitionId.

private Node createNodeWithContentDefinitionId(final String contentDefinitionId) {
    final Node node = mock(Node.class);
    final Definition definition = mock(Definition.class);
    final DRGElement drgElement = mock(DRGElement.class);
    when(drgElement.getContentDefinitionId()).thenReturn(contentDefinitionId);
    when(definition.getDefinition()).thenReturn(drgElement);
    when(node.getContent()).thenReturn(definition);
    return node;
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement)

Example 25 with Definition

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

the class DMNCanvasHandlerTest method getElementForTestUpdateDiagramId.

private Element getElementForTestUpdateDiagramId(final String diagramId, final String currentDiagramId, final HasContentDefinitionId hasContentDefinitionId) {
    final Element element = mock(Element.class);
    final Definition definition = mock(Definition.class);
    final GraphsProvider graphsProvider = mock(GraphsProvider.class);
    when(graphsProvider.getCurrentDiagramId()).thenReturn(diagramId);
    when(definition.getDefinition()).thenReturn(hasContentDefinitionId);
    when(element.getContent()).thenReturn(definition);
    when(hasContentDefinitionId.getDiagramId()).thenReturn(currentDiagramId);
    when(canvasHandler.getGraphsProvider()).thenReturn(graphsProvider);
    return element;
}
Also used : Element(org.kie.workbench.common.stunner.core.graph.Element) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) GraphsProvider(org.kie.workbench.common.stunner.core.diagram.GraphsProvider)

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