Search in sources :

Example 36 with DRGElement

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

the class DecisionServiceParametersListWidgetTest method testGetTargetDRGElement_WhenTargetIsDRGElement.

@Test
public void testGetTargetDRGElement_WhenTargetIsDRGElement() {
    final Edge edge = mock(Edge.class);
    final Node targetNode = mock(Node.class);
    final View targetNodeView = mock(View.class);
    final DRGElement drgElement = mock(DRGElement.class);
    when(edge.getTargetNode()).thenReturn(targetNode);
    when(targetNode.getContent()).thenReturn(targetNodeView);
    when(targetNodeView.getDefinition()).thenReturn(drgElement);
    final Optional<DRGElement> actual = widget.getTargetDRGElement(edge);
    assertTrue(actual.isPresent());
    assertEquals(drgElement, actual.get());
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Edge(org.kie.workbench.common.stunner.core.graph.Edge) 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 37 with DRGElement

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

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

the class HrefBuilderTest method testGetHrefForImportedDRGElement.

@Test
public void testGetHrefForImportedDRGElement() {
    final DRGElement drgElement = mock(DRGElement.class);
    final Name drgElementName = mock(Name.class);
    final Name importName = mock(Name.class);
    final Id id = mock(Id.class);
    final Definitions definitions = mock(Definitions.class);
    final Import anImport = mock(Import.class);
    final List<Import> imports = singletonList(anImport);
    final String includedModelName = "includedModel";
    when(importName.getValue()).thenReturn(includedModelName);
    when(anImport.getName()).thenReturn(importName);
    when(anImport.getNamespace()).thenReturn("https://github.com/kiegroup/dmn/something");
    when(id.getValue()).thenReturn("0000-1111-2222");
    when(drgElementName.getValue()).thenReturn(includedModelName + ".Decision");
    when(drgElement.getId()).thenReturn(id);
    when(drgElement.getName()).thenReturn(drgElementName);
    when(drgElement.getParent()).thenReturn(definitions);
    when(definitions.getImport()).thenReturn(imports);
    final String actual = HrefBuilder.getHref(drgElement);
    final String expected = "https://github.com/kiegroup/dmn/something#0000-1111-2222";
    assertEquals(expected, actual);
}
Also used : Import(org.kie.workbench.common.dmn.api.definition.model.Import) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 39 with DRGElement

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

the class DMNDiagramHelperTest method testGetNodes.

@Test
public void testGetNodes() {
    final DRGElement drgElement = mock(DRGElement.class);
    final List<DRGElement> expectedNodes = singletonList(drgElement);
    when(dmnDiagramUtils.getDRGElements(diagram)).thenReturn(expectedNodes);
    final List<DRGElement> actualNodes = helper.getNodes(diagram);
    assertEquals(expectedNodes, actualNodes);
}
Also used : DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 40 with DRGElement

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

the class DMNIncludedNodesFilterTest method testGetNodesFromImports.

@Test
public void testGetNodesFromImports() {
    final Path path = mock(Path.class);
    final DMNIncludedModel includedModel1 = mock(DMNIncludedModel.class);
    final DMNIncludedModel includedModel2 = mock(DMNIncludedModel.class);
    final DMNIncludedModel includedModel3 = mock(DMNIncludedModel.class);
    final List<DMNIncludedModel> imports = asList(includedModel1, includedModel2, includedModel3);
    final DMNIncludedNode dmnNode1 = mock(DMNIncludedNode.class);
    final DMNIncludedNode dmnNode2 = mock(DMNIncludedNode.class);
    final Decision node1 = new Decision();
    final InputData node2 = new InputData();
    final List<DRGElement> diagramNodes = asList(node1, node2);
    when(includedModel1.getNamespace()).thenReturn("://namespace1");
    when(includedModel2.getNamespace()).thenReturn("://namespace2");
    when(includedModel3.getNamespace()).thenReturn("://namespace3");
    when(diagramHelper.getDiagramByPath(path)).thenReturn(diagram);
    when(diagramHelper.getNodes(diagram)).thenReturn(diagramNodes);
    when(diagramHelper.getNamespace(diagram)).thenReturn("://namespace1");
    when(factory.makeDMNIncludeModel(path, includedModel1, node1)).thenReturn(dmnNode1);
    when(factory.makeDMNIncludeModel(path, includedModel1, node2)).thenReturn(dmnNode2);
    final List<DMNIncludedNode> actualNodes = filter.getNodesFromImports(path, imports);
    final List<DMNIncludedNode> expectedNodes = asList(dmnNode1, dmnNode2);
    assertEquals(expectedNodes, actualNodes);
}
Also used : Path(org.uberfire.backend.vfs.Path) DMNIncludedNode(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DMNIncludedModel(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Aggregations

DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)72 Test (org.junit.Test)45 Node (org.kie.workbench.common.stunner.core.graph.Node)27 ArrayList (java.util.ArrayList)25 Edge (org.kie.workbench.common.stunner.core.graph.Edge)17 View (org.kie.workbench.common.stunner.core.graph.content.view.View)17 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)16 List (java.util.List)15 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)15 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)15 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)15 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)14 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)13 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)10 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)9 Import (org.kie.workbench.common.dmn.api.definition.model.Import)9 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)8 KnowledgeRequirement (org.kie.workbench.common.dmn.api.definition.model.KnowledgeRequirement)7 JSITDefinitions (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)7 Optional (java.util.Optional)6