use of org.kie.workbench.common.dmn.api.definition.model.DecisionService in project kie-wb-common by kiegroup.
the class DMNDecisionServiceSVGMutableShapeImpl method applyCustomProperties.
@Override
protected void applyCustomProperties(final Node<View<DecisionService>, Edge> element, final MutationContext mutationContext) {
final DecisionService instance = getDefinition(element);
final DecisionServiceSVGShapeView decisionServiceSVGShapeView = (DecisionServiceSVGShapeView) getShapeView();
decisionServiceSVGShapeView.setDividerLineY(instance.getDividerLineY().getValue());
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionService 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.DecisionService 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.DecisionService in project kie-wb-common by kiegroup.
the class DMNDecisionServiceSVGShapeDefImplTest method testNewFontHandler.
@Test
@SuppressWarnings("unchecked")
public void testNewFontHandler() {
final DecisionService decisionService = new DecisionService();
final SVGShapeView<?> shapeView = mock(SVGShapeView.class);
final FontHandler<DecisionService, SVGShapeView> handler = shapeDef.newFontHandler();
handler.handle(decisionService, shapeView);
verify(shapeView).setTitlePosition(HasTitle.VerticalAlignment.TOP, HasTitle.HorizontalAlignment.CENTER, HasTitle.ReferencePosition.INSIDE, HasTitle.Orientation.HORIZONTAL);
verify(shapeView).setMargins(new Maps.Builder().put(HasTitle.VerticalAlignment.TOP, 20.0).build());
verify(shapeView).setTextWrapper(TextWrapperStrategy.TRUNCATE);
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionService in project kie-wb-common by kiegroup.
the class DMNDecisionServiceSVGShapeDefImplTest method testNewSizeHandler.
@Test
@SuppressWarnings("unchecked")
public void testNewSizeHandler() {
final DecisionService decisionService = new DecisionService();
final View<DecisionService> view = new ViewImpl<>(decisionService, Bounds.create(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT));
final SVGShapeView<?> shapeView = mock(SVGShapeView.class);
final SizeHandler<DecisionService, SVGShapeView> handler = shapeDef.newSizeHandler();
handler.handle(view, shapeView);
verify(shapeView).setMinWidth(decisionService.getDimensionsSet().getMinimumWidth());
verify(shapeView).setMaxWidth(decisionService.getDimensionsSet().getMaximumWidth());
verify(shapeView).setMinHeight(decisionService.getDividerLineY().getValue() + GeneralRectangleDimensionsSet.DEFAULT_HEIGHT);
verify(shapeView).setMaxHeight(decisionService.getDimensionsSet().getMaximumHeight());
}
Aggregations