Search in sources :

Example 26 with Definitions

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

the class DMNMarshallerTest method testConnect.

@Test
public void testConnect() {
    final DMNMarshaller dmnMarshaller = new DMNMarshaller();
    final JSIDMNDiagram diagram = mock(JSIDMNDiagram.class);
    final List<String> dmnDiagramElementIds = mock(List.class);
    final Definitions definitionsStunnerPojo = mock(Definitions.class);
    final List<JSIDMNEdge> dmnEdges = new ArrayList<>();
    final Node<?, ?> node = mock(Node.class);
    final List inEdges = new ArrayList<>();
    final Edge edge = mock(Edge.class);
    final Node sourceNode = mock(Node.class);
    final View sourceView = mock(View.class);
    final ViewConnector viewConnector = mock(ViewConnector.class);
    final DiscreteConnection sourceConnection = mock(DiscreteConnection.class);
    final DiscreteConnection targetConnection = mock(DiscreteConnection.class);
    final View<?> view = mock(View.class);
    inEdges.add(edge);
    when(edge.getSourceNode()).thenReturn(sourceNode);
    when(sourceNode.getContent()).thenReturn(sourceView);
    when(node.getInEdges()).thenReturn(inEdges);
    when(edge.getContent()).thenReturn(viewConnector);
    when(viewConnector.getControlPoints()).thenReturn(new ControlPoint[] {});
    when(sourceConnection.isAuto()).thenReturn(true);
    when(targetConnection.isAuto()).thenReturn(true);
    when(diagram.getName()).thenReturn("dmnEdge");
    when(definitionsStunnerPojo.getDefaultNamespace()).thenReturn("org.edge");
    when(viewConnector.getSourceConnection()).thenReturn(Optional.of(sourceConnection));
    when(viewConnector.getTargetConnection()).thenReturn(Optional.of(targetConnection));
    dmnMarshaller.connect(diagram, dmnDiagramElementIds, definitionsStunnerPojo, dmnEdges, node, view);
    when(viewConnector.getSourceConnection()).thenReturn(Optional.empty());
    when(viewConnector.getTargetConnection()).thenReturn(Optional.empty());
    dmnMarshaller.connect(diagram, dmnDiagramElementIds, definitionsStunnerPojo, dmnEdges, node, view);
    when(viewConnector.getSourceConnection()).thenReturn(Optional.of(sourceConnection));
    when(viewConnector.getTargetConnection()).thenReturn(Optional.empty());
    dmnMarshaller.connect(diagram, dmnDiagramElementIds, definitionsStunnerPojo, dmnEdges, node, view);
    verify(sourceConnection).isAuto();
    verify(targetConnection).isAuto();
}
Also used : ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) DiscreteConnection(org.kie.workbench.common.stunner.core.graph.content.view.DiscreteConnection) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) JSITDefinitions(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) View(org.kie.workbench.common.stunner.core.graph.content.view.View) JSIDMNDiagram(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNDiagram) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge) Edge(org.kie.workbench.common.stunner.core.graph.Edge) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge) Test(org.junit.Test)

Example 27 with Definitions

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

the class DataTypesPageTest method testCurrentDMNModelNamespace.

@Test
public void testCurrentDMNModelNamespace() {
    final Definitions definitions = mock(Definitions.class);
    final Text text = mock(Text.class);
    final String expected = "currentDMNModelNamespace";
    when(text.getValue()).thenReturn(expected);
    when(definitions.getNamespace()).thenReturn(text);
    when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
    final String actual = page.currentDMNModelNamespace();
    assertEquals(expected, actual);
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) Text(org.kie.workbench.common.dmn.api.property.dmn.Text) Test(org.junit.Test)

Example 28 with Definitions

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

the class DataTypesPageTest method testCurrentDMNModelNamespaceWhenNamespaceIsNull.

@Test
public void testCurrentDMNModelNamespaceWhenNamespaceIsNull() {
    final Definitions definitions = mock(Definitions.class);
    when(definitions.getNamespace()).thenReturn(null);
    when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
    final String actual = page.currentDMNModelNamespace();
    final String expected = "";
    assertEquals(expected, actual);
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) Test(org.junit.Test)

Example 29 with Definitions

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

the class DataTypeUtilsTest method makeModelDefinitions.

private Definitions makeModelDefinitions() {
    final Definitions definitions = mock(Definitions.class);
    final List<Import> imports = singletonList(makeImport());
    when(definitions.getImport()).thenReturn(imports);
    return definitions;
}
Also used : Import(org.kie.workbench.common.dmn.api.definition.model.Import) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions)

Example 30 with Definitions

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

the class IncludedModelsPageStateProviderImplTest method testGetCurrentDiagramNamespace.

@Test
public void testGetCurrentDiagramNamespace() {
    final Definitions definitions = mock(Definitions.class);
    final String expectedNamespace = "://namespace";
    when(dmnGraphUtils.getDefinitions(diagram)).thenReturn(definitions);
    when(definitions.getNamespace()).thenReturn(new Text(expectedNamespace));
    final String actualNamespace = stateProvider.getCurrentDiagramNamespace();
    assertEquals(expectedNamespace, actualNamespace);
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) Text(org.kie.workbench.common.dmn.api.property.dmn.Text) Test(org.junit.Test)

Aggregations

Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)70 Test (org.junit.Test)41 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)24 Node (org.kie.workbench.common.stunner.core.graph.Node)23 DMNDiagram (org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)22 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)19 ArrayList (java.util.ArrayList)18 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)18 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)15 Import (org.kie.workbench.common.dmn.api.definition.model.Import)15 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)14 View (org.kie.workbench.common.stunner.core.graph.content.view.View)14 List (java.util.List)13 Objects (java.util.Objects)12 Optional (java.util.Optional)12 PMMLDocumentMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata)12 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)12 JSITDefinitions (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)12 Edge (org.kie.workbench.common.stunner.core.graph.Edge)12 Map (java.util.Map)11