Search in sources :

Example 1 with DMNIncludedNode

use of org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode in project kie-wb-common by kiegroup.

the class DecisionComponentsTest method testGetNodesConsumerWhenNodeListIsNotEmpty.

@Test
public void testGetNodesConsumerWhenNodeListIsNotEmpty() {
    final DMNIncludedNode dmnIncludedNode1 = mock(DMNIncludedNode.class);
    final DMNIncludedNode dmnIncludedNode2 = mock(DMNIncludedNode.class);
    final DecisionComponent drgDecisionComponent1 = mock(DecisionComponent.class);
    final DecisionComponent drgDecisionComponent2 = mock(DecisionComponent.class);
    final List<DMNIncludedNode> includedNodes = asList(dmnIncludedNode1, dmnIncludedNode2);
    final List<DecisionComponent> includedDRGElements = spy(new ArrayList<>());
    doReturn(includedDRGElements).when(decisionComponents).getIncludedDRGElements();
    doReturn(drgDecisionComponent1).when(decisionComponents).makeDecisionComponent(dmnIncludedNode1);
    doReturn(drgDecisionComponent2).when(decisionComponents).makeDecisionComponent(dmnIncludedNode2);
    doNothing().when(decisionComponents).refreshView();
    decisionComponents.getNodesConsumer().accept(includedNodes);
    verify(view).hideLoading();
    verify(includedDRGElements).clear();
    verify(includedDRGElements).add(drgDecisionComponent1);
    verify(includedDRGElements).add(drgDecisionComponent2);
    verify(decisionComponents).refreshView();
}
Also used : DMNIncludedNode(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode) Test(org.junit.Test)

Example 2 with DMNIncludedNode

use of org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode in project kie-wb-common by kiegroup.

the class DMNIncludedNodeFactoryTest method testMakeDMNIncludeModel.

@Test
public void testMakeDMNIncludeModel() {
    final Path path = mock(Path.class);
    final IncludedModel includedModel = mock(IncludedModel.class);
    final String drgElementId = "0000-1111-3333-4444";
    final String drgElementName = "Can Drive?";
    final String expectedFileName = "file.dmn";
    final String expectedModelName = "model";
    final String expectedImportedElementId = "0000-1111-3333-4444";
    final String expectedImportedElementName = "model.Can Drive?";
    final String expectedImportedItemDefinitionName = "model.tCustomBoolean";
    final DRGElement importedElementId = makeDecision(drgElementId, drgElementName, "tCustomBoolean");
    when(path.getFileName()).thenReturn(expectedFileName);
    when(includedModel.getModelName()).thenReturn(expectedModelName);
    final DMNIncludedNode node = factory.makeDMNIncludeModel(path, includedModel, importedElementId);
    final Decision drgElement = (Decision) node.getDrgElement();
    assertEquals(expectedImportedElementId, drgElement.getId().getValue());
    assertEquals(expectedImportedElementName, drgElement.getName().getValue());
    assertEquals(expectedImportedItemDefinitionName, drgElement.getVariable().getTypeRef().getLocalPart());
    assertEquals(expectedFileName, node.getFileName());
    assertTrue(drgElement.isAllowOnlyVisualChange());
}
Also used : Path(org.uberfire.backend.vfs.Path) DMNIncludedNode(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode) IncludedModel(org.kie.workbench.common.dmn.api.editors.included.IncludedModel) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 3 with DMNIncludedNode

use of org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode in project kie-wb-common by kiegroup.

the class DMNIncludedNodeFactoryTest method testMakeDMNIncludedModel.

@Test
public void testMakeDMNIncludedModel() {
    final DMNIncludedNodeFactory factory = mock(DMNIncludedNodeFactory.class);
    final String path = "path";
    final IncludedModel includedModel = mock(IncludedModel.class);
    final DRGElement drgElement = mock(DRGElement.class);
    final DRGElement elementWithNamespace = mock(DRGElement.class);
    doCallRealMethod().when(factory).makeDMNIncludeNode(path, includedModel, drgElement);
    when(factory.drgElementWithNamespace(drgElement, includedModel)).thenReturn(elementWithNamespace);
    final DMNIncludedNode includedNode = factory.makeDMNIncludeNode(path, includedModel, drgElement);
    verify(factory).drgElementWithNamespace(drgElement, includedModel);
    assertEquals(path, includedNode.getFileName());
    assertEquals(elementWithNamespace, includedNode.getDrgElement());
}
Also used : DMNIncludedNode(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode) IncludedModel(org.kie.workbench.common.dmn.api.editors.included.IncludedModel) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 4 with DMNIncludedNode

use of org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode 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)

Example 5 with DMNIncludedNode

use of org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode in project kie-wb-common by kiegroup.

the class DMNIncludedNodesFilterTest method testGetNodesFromImportsWhenPathDoesNotRepresentsAnImportedDiagram.

@Test
public void testGetNodesFromImportsWhenPathDoesNotRepresentsAnImportedDiagram() {
    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);
    when(includedModel1.getNamespace()).thenReturn("://namespace1");
    when(includedModel2.getNamespace()).thenReturn("://namespace2");
    when(includedModel3.getNamespace()).thenReturn("://namespace3");
    when(diagramHelper.getDiagramByPath(path)).thenReturn(diagram);
    when(diagramHelper.getNamespace(diagram)).thenReturn("://namespace4");
    final List<DMNIncludedNode> actualNodes = filter.getNodesFromImports(path, imports);
    final List<DMNIncludedNode> expectedNodes = emptyList();
    assertEquals(expectedNodes, actualNodes);
}
Also used : Path(org.uberfire.backend.vfs.Path) DMNIncludedNode(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode) DMNIncludedModel(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel) Test(org.junit.Test)

Aggregations

DMNIncludedNode (org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode)7 Test (org.junit.Test)6 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)4 DMNIncludedModel (org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel)4 Path (org.uberfire.backend.vfs.Path)4 IncludedModel (org.kie.workbench.common.dmn.api.editors.included.IncludedModel)3 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)2 Promise (elemental2.promise.Promise)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1