use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class DMNGraphProcessorTest method testGetNodesWithDecisionServices.
@Test
public void testGetNodesWithDecisionServices() {
final String childId1 = "id1";
final String childId2 = "id2";
final String dsId = "dsId";
final String decisionNodeId = "decision1Node";
final DMNGraphProcessor processor = spy(new DMNGraphProcessor());
final Graph graph = mock(Graph.class);
final Decision decision1 = mock(Decision.class);
final Node decisionNode = createNode(decision1, decisionNodeId);
final DecisionService ds = mock(DecisionService.class);
final Node dsNode = createNode(ds, dsId);
final Decision child1 = mock(Decision.class);
final Node ch1 = createNode(child1, childId1);
final Decision child2 = mock(Decision.class);
final Node ch2 = createNode(child2, childId2);
final List<Node> children = Arrays.asList(ch1, ch2);
doReturn(children).when(processor).getChildNodes(dsNode);
final List<Node> graphNodes = createGraphNodes(dsNode, decisionNode);
when(graph.nodes()).thenReturn(graphNodes);
final List<Node> nodes = (List<Node>) processor.getNodes(graph);
assertEquals(2, nodes.size());
assertTrue(nodes.contains(dsNode));
assertTrue(nodes.contains(decisionNode));
assertTrue(processor.isReplacedByAnotherNode(childId1));
assertEquals(dsId, processor.getReplaceNodeId(childId1));
assertTrue(processor.isReplacedByAnotherNode(childId2));
assertEquals(dsId, processor.getReplaceNodeId(childId2));
}
use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class StunnerConverterTest method testDecision.
@Test
public void testDecision() {
final StylingSet decisionStylingSet = mock(StylingSet.class);
final Decision decision = spy(new Decision());
when(decision.getStylingSet()).thenReturn(decisionStylingSet);
final JSITDecision jsitDecision = mock(JSITDecision.class);
when(jsitDecision.getTYPE_NAME()).thenReturn(JSITDecision.TYPE);
final JSIStyle style = mock(JSIStyle.class);
final JSIDMNShape shape = mock(JSIDMNShape.class);
final JSIDMNStyle dmnStyleOfDrgShape = mock(JSIDMNStyle.class);
when(shape.getStyle()).thenReturn(style);
doReturn(style).when(converter).getUnwrappedJSIStyle(style);
doReturn(true).when(converter).isJSIDMNStyle(style);
doReturn(dmnStyleOfDrgShape).when(converter).getJSIDmnStyle(style);
final NodeEntry nodeEntry = mock(NodeEntry.class);
when(nodeEntry.getDmnElement()).thenReturn(jsitDecision);
when(nodeEntry.getId()).thenReturn("_id");
when(nodeEntry.getDmnShape()).thenReturn(shape);
final Element graphElement = mock(Element.class);
final Node graphNode = mock(Node.class);
final View content = mock(View.class);
when(factoryManager.newElement(anyString(), anyString())).thenReturn(graphElement);
when(graphElement.asNode()).thenReturn(graphNode);
when(graphNode.getContent()).thenReturn(content);
when(content.getDefinition()).thenReturn(decision);
final JSIColor randomColor = mock(JSIColor.class);
when(randomColor.getRed()).thenReturn(12);
when(randomColor.getGreen()).thenReturn(34);
when(randomColor.getBlue()).thenReturn(56);
when(dmnStyleOfDrgShape.getFontColor()).thenReturn(randomColor);
when(dmnStyleOfDrgShape.getStrokeColor()).thenReturn(randomColor);
when(dmnStyleOfDrgShape.getFillColor()).thenReturn(randomColor);
when(dmnStyleOfDrgShape.getFontSize()).thenReturn(11d);
converter.make(nodeEntry);
verify(decisionStylingSet).setFontSize(fontSizeArgumentCaptor.capture());
Assertions.assertThat(fontSizeArgumentCaptor.getValue().getValue()).isEqualTo(11d);
verify(decisionStylingSet).setBorderColour(borderColourArgumentCaptor.capture());
Assertions.assertThat(borderColourArgumentCaptor.getValue().getValue()).isEqualTo("#0c2238");
verify(decisionStylingSet).setBgColour(bgColourArgumentCaptor.capture());
Assertions.assertThat(bgColourArgumentCaptor.getValue().getValue()).isEqualTo("#0c2238");
verify(decisionStylingSet).setFontColour(fontColourArgumentCaptor.capture());
Assertions.assertThat(fontColourArgumentCaptor.getValue().getValue()).isEqualTo("#0c2238");
}
use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class DefaultValueUtilitiesTest method testUpdateNewNodeName_DecisionService.
@Test
public void testUpdateNewNodeName_DecisionService() {
// Add some existing nodes to ensure naming is not affected by existing content
graph.addNode(makeMockNode(new BusinessKnowledgeModel()));
graph.addNode(makeMockNode(new Decision()));
graph.addNode(makeMockNode(new InputData()));
graph.addNode(makeMockNode(new KnowledgeSource()));
final DecisionService decisionService1 = new DecisionService();
final DecisionService decisionService2 = new DecisionService();
final DecisionService decisionService3 = new DecisionService();
final DecisionService decisionService4 = new DecisionService();
assertUpdateNewNodeName(decisionService1, decisionService2, (decisionService) -> decisionService.getName().getValue(), () -> DecisionService.class.getSimpleName() + "-1", () -> DecisionService.class.getSimpleName() + "-2");
// Update existing names manually and add two more
decisionService1.getName().setValue("decisionService");
decisionService2.getName().setValue(DecisionService.class.getSimpleName() + "-5");
assertUpdateNewNodeName(decisionService3, decisionService4, (decisionService) -> decisionService.getName().getValue(), () -> DecisionService.class.getSimpleName() + "-6", () -> DecisionService.class.getSimpleName() + "-7");
}
use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class DefaultValueUtilitiesTest method testUpdateNewNodeName_InputData.
@Test
public void testUpdateNewNodeName_InputData() {
// Add some existing nodes to ensure naming is not affected by existing content
graph.addNode(makeMockNode(new BusinessKnowledgeModel()));
graph.addNode(makeMockNode(new Decision()));
graph.addNode(makeMockNode(new KnowledgeSource()));
graph.addNode(makeMockNode(new TextAnnotation()));
final InputData inputData1 = new InputData();
final InputData inputData2 = new InputData();
final InputData inputData3 = new InputData();
final InputData inputData4 = new InputData();
assertUpdateNewNodeName(inputData1, inputData2, (inputData) -> inputData.getName().getValue(), () -> InputData.class.getSimpleName() + "-1", () -> InputData.class.getSimpleName() + "-2");
// Update existing names manually and add two more
inputData1.getName().setValue("inputData");
inputData2.getName().setValue(InputData.class.getSimpleName() + "-5");
assertUpdateNewNodeName(inputData3, inputData4, (inputData) -> inputData.getName().getValue(), () -> InputData.class.getSimpleName() + "-6", () -> InputData.class.getSimpleName() + "-7");
}
use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class DefaultValueUtilitiesTest method testUpdateNewNodeName_TextAnnotation.
@Test
public void testUpdateNewNodeName_TextAnnotation() {
// Add some existing nodes to ensure naming is not affected by existing content
graph.addNode(makeMockNode(new BusinessKnowledgeModel()));
graph.addNode(makeMockNode(new Decision()));
graph.addNode(makeMockNode(new InputData()));
graph.addNode(makeMockNode(new KnowledgeSource()));
final TextAnnotation textAnnotation1 = new TextAnnotation();
final TextAnnotation textAnnotation2 = new TextAnnotation();
final TextAnnotation textAnnotation3 = new TextAnnotation();
final TextAnnotation textAnnotation4 = new TextAnnotation();
assertUpdateNewNodeName(textAnnotation1, textAnnotation2, (textAnnotation) -> textAnnotation.getText().getValue(), () -> TextAnnotation.class.getSimpleName() + "-1", () -> TextAnnotation.class.getSimpleName() + "-2");
// Update existing names manually and add two more
textAnnotation1.getText().setValue("textAnnotation");
textAnnotation2.getText().setValue(TextAnnotation.class.getSimpleName() + "-5");
assertUpdateNewNodeName(textAnnotation3, textAnnotation4, (textAnnotation) -> textAnnotation.getText().getValue(), () -> TextAnnotation.class.getSimpleName() + "-6", () -> TextAnnotation.class.getSimpleName() + "-7");
}
Aggregations