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