use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class PointUtilsTest method testConvertToRelativeBoundsWhenChild.
@Test
public void testConvertToRelativeBoundsWhenChild() {
final Node<View, Edge> parent = new NodeImpl<>(UUID.uuid());
final View parentView = new ViewImpl<>(new Decision(), Bounds.create(100, 200, 1000, 2000));
parent.setContent(parentView);
final Node<View, Edge> child = new NodeImpl<>(UUID.uuid());
final View childView = new ViewImpl<>(new Decision(), Bounds.create(110, 220, 150, 260));
child.setContent(childView);
final Edge<Child, Node> edge = new EdgeImpl<>(UUID.uuid());
edge.setContent(new Child());
edge.setSourceNode(parent);
edge.setTargetNode(child);
parent.getOutEdges().add(edge);
child.getInEdges().add(edge);
PointUtils.convertToRelativeBounds(child);
final Bound ulBound = child.getContent().getBounds().getUpperLeft();
final Bound lrBound = child.getContent().getBounds().getLowerRight();
assertThat(ulBound.getX()).isEqualTo(10);
assertThat(ulBound.getY()).isEqualTo(20);
assertThat(lrBound.getX()).isEqualTo(50);
assertThat(lrBound.getY()).isEqualTo(60);
}
use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class DMNIncludedNodeFactoryTest method makeDecision.
private Decision makeDecision(final String id, final String name, final String type) {
final Decision decision = new Decision();
decision.setId(new Id(id));
decision.setName(new Name(name));
decision.setVariable(makeInformationItemPrimary(type));
return decision;
}
use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class DecisionConverterTest method testWBFromDMN.
@Test
@SuppressWarnings("unchecked")
public void testWBFromDMN() {
final Node<View<Decision>, ?> factoryNode = new NodeImpl<>(UUID.uuid());
final View<Decision> view = new ViewImpl<>(new Decision(), Bounds.create());
factoryNode.setContent(view);
when(factoryManager.newElement(Mockito.<String>any(), eq(getDefinitionId(Decision.class)))).thenReturn(element);
when(element.asNode()).thenReturn(factoryNode);
final org.kie.dmn.model.api.Decision dmn = new TDecision();
final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem();
literalExpression.setId(EXPRESSION_UUID);
dmn.setId(DECISION_UUID);
dmn.setName(DECISION_NAME);
dmn.setDescription(DECISION_DESCRIPTION);
dmn.setVariable(informationItem);
dmn.setExpression(literalExpression);
final Node<View<Decision>, ?> node = converter.nodeFromDMN(dmn, hasComponentWidthsConsumer);
final Decision wb = (Decision) DefinitionUtils.getElementDefinition(node);
assertThat(wb).isNotNull();
assertThat(wb.getId()).isNotNull();
assertThat(wb.getId().getValue()).isEqualTo(DECISION_UUID);
assertThat(wb.getName()).isNotNull();
assertThat(wb.getName().getValue()).isEqualTo(DECISION_NAME);
assertThat(wb.getDescription()).isNotNull();
assertThat(wb.getDescription().getValue()).isEqualTo(DECISION_DESCRIPTION);
assertThat(wb.getVariable()).isNotNull();
assertThat(wb.getVariable().getName().getValue()).isEqualTo(DECISION_NAME);
assertThat(wb.getExpression()).isNotNull();
assertThat(wb.getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
assertThat(hasComponentWidths).isNotNull();
assertThat(hasComponentWidths).isEqualTo(wb.getExpression());
}
use of org.kie.workbench.common.dmn.api.definition.model.Decision 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.definition.model.Decision in project kie-wb-common by kiegroup.
the class DMNDiagramUtilsTest method testGetDefinitionsWithMultipleRootNodes.
@Test
public void testGetDefinitionsWithMultipleRootNodes() {
final Decision definition1 = new Decision();
final DMNDiagram definition2 = new DMNDiagram();
graph.addNode(newNode(definition1));
graph.addNode(newNode(definition2));
final Definitions definitions = utils.getDefinitions(diagram);
assertNotNull(definitions);
assertEquals(definition2.getDefinitions(), definitions);
}
Aggregations