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();
}
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());
}
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());
}
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);
}
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);
}
Aggregations