Search in sources :

Example 16 with DecisionService

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());
}
Also used : DecisionServiceSVGShapeView(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService)

Example 17 with DecisionService

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));
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) Node(org.kie.workbench.common.stunner.core.graph.Node) List(java.util.List) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Test(org.junit.Test)

Example 18 with DecisionService

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");
}
Also used : KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Test(org.junit.Test)

Example 19 with DecisionService

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);
}
Also used : Maps(org.kie.soup.commons.util.Maps) SVGShapeView(org.kie.workbench.common.stunner.svg.client.shape.view.SVGShapeView) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Test(org.junit.Test)

Example 20 with DecisionService

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());
}
Also used : ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) SVGShapeView(org.kie.workbench.common.stunner.svg.client.shape.view.SVGShapeView) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Test(org.junit.Test)

Aggregations

DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)38 Test (org.junit.Test)19 View (org.kie.workbench.common.stunner.core.graph.content.view.View)19 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)13 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)13 Node (org.kie.workbench.common.stunner.core.graph.Node)13 ArrayList (java.util.ArrayList)12 List (java.util.List)12 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)12 Edge (org.kie.workbench.common.stunner.core.graph.Edge)12 DecisionServiceDividerLineY (org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY)11 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)9 InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)9 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)9 Child (org.kie.workbench.common.stunner.core.graph.content.relationship.Child)9 Optional (java.util.Optional)7 DMNElementReference (org.kie.workbench.common.dmn.api.definition.model.DMNElementReference)7 KnowledgeRequirement (org.kie.workbench.common.dmn.api.definition.model.KnowledgeRequirement)7 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)7 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)6