Search in sources :

Example 11 with DecisionService

use of org.kie.workbench.common.dmn.api.definition.model.DecisionService in project kie-wb-common by kiegroup.

the class DMNDeepCloneProcessTest method testCloneWhenSourceIsDecisionService.

@Test
public void testCloneWhenSourceIsDecisionService() {
    final DecisionService source = buildDecisionService();
    final DecisionService cloned = dmnDeepCloneProcess.clone(source, new DecisionService());
    assertThat(cloned).isNotNull();
    assertThat(cloned.getId().getValue()).isNotEqualTo(SOURCE_ID);
    assertThat(cloned.getName().getValue()).isEqualTo(DECISION_SERVICE_NAME + FIRST_INDEX_IN_SUFFIX);
    assertThat(cloned.getVariable().getTypeRef()).isEqualTo(BuiltInType.BOOLEAN.asQName());
}
Also used : DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) AbstractCloneProcessTest(org.kie.workbench.common.stunner.core.definition.clone.AbstractCloneProcessTest) Test(org.junit.Test)

Example 12 with DecisionService

use of org.kie.workbench.common.dmn.api.definition.model.DecisionService in project kie-wb-common by kiegroup.

the class DMNCommonActionsToolboxFactoryTest method testIsAllowed.

@Test
public void testIsAllowed() {
    final Node node = mock(Node.class);
    final Definition content = mock(Definition.class);
    final DecisionService decisionService = mock(DecisionService.class);
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(decisionService);
    final boolean actual = tested.isAllowed(canvasHandler, node);
    assertTrue(actual);
    verify(tested, never()).superIsAllowed(canvasHandler, node);
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Test(org.junit.Test)

Example 13 with DecisionService

use of org.kie.workbench.common.dmn.api.definition.model.DecisionService in project kie-wb-common by kiegroup.

the class DecisionServiceMoveDividerControlTest method testRegisterDecisionServiceElementDragEnd.

@Test
@SuppressWarnings("unchecked")
public void testRegisterDecisionServiceElementDragEnd() {
    final DefinitionManager definitionManager = mock(DefinitionManager.class);
    final AdapterManager adapterManager = mock(AdapterManager.class);
    final AdapterRegistry adapterRegistry = mock(AdapterRegistry.class);
    final PropertyAdapter<Object, Object> propertyAdapter = mock(PropertyAdapter.class);
    final DefinitionAdapter<Object> definitionAdapter = mock(DefinitionAdapter.class);
    final DecisionServiceDividerLineY dividerLineY = new DecisionServiceDividerLineY();
    final Optional dividerYProperty = Optional.of(dividerLineY);
    final UpdateElementPropertyCommand updateElementPropertyCommand = mock(UpdateElementPropertyCommand.class);
    final DecisionService decisionService = mock(DecisionService.class);
    final DecisionServiceSVGShapeView decisionServiceShapeView = mock(DecisionServiceSVGShapeView.class);
    final DragEvent dragEvent = mock(DragEvent.class);
    when(canvasHandler.getDefinitionManager()).thenReturn(definitionManager);
    when(definitionManager.adapters()).thenReturn(adapterManager);
    when(adapterManager.registry()).thenReturn(adapterRegistry);
    when(adapterManager.forProperty()).thenReturn(propertyAdapter);
    when(adapterRegistry.getDefinitionAdapter(Mockito.<Class>any())).thenReturn(definitionAdapter);
    when(definitionAdapter.getProperty(decisionService, DIVIDER_Y_PROPERTY_ID)).thenReturn(dividerYProperty);
    when(propertyAdapter.getId(dividerLineY)).thenReturn(DIVIDER_Y_PROPERTY_ID);
    when(canvasCommandFactory.updatePropertyValue(eq(element), eq(DIVIDER_Y_PROPERTY_ID), Mockito.<Object>any())).thenReturn(updateElementPropertyCommand);
    when(definition.getDefinition()).thenReturn(decisionService);
    when(shape.getShapeView()).thenReturn(decisionServiceShapeView);
    control.register(element);
    verify(decisionServiceShapeView).addDividerDragHandler(dragHandlerCaptor.capture());
    when(decisionServiceShapeView.getDividerLineY()).thenReturn(DIVIDER_Y);
    final DragHandler dragHandler = dragHandlerCaptor.getValue();
    dragHandler.end(dragEvent);
    verify(canvasCommandFactory).updatePropertyValue(eq(element), eq(DIVIDER_Y_PROPERTY_ID), eq(DIVIDER_Y));
    verify(commandManager).execute(eq(canvasHandler), eq(updateElementPropertyCommand));
}
Also used : Optional(java.util.Optional) DragHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.DragHandler) AdapterRegistry(org.kie.workbench.common.stunner.core.registry.definition.AdapterRegistry) UpdateElementPropertyCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) DragEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.DragEvent) DecisionServiceDividerLineY(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY) DefinitionManager(org.kie.workbench.common.stunner.core.api.DefinitionManager) AdapterManager(org.kie.workbench.common.stunner.core.definition.adapter.AdapterManager) DecisionServiceSVGShapeView(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView) Test(org.junit.Test)

Example 14 with DecisionService

use of org.kie.workbench.common.dmn.api.definition.model.DecisionService in project kie-wb-common by kiegroup.

the class DMNGraphProcessor method getNodes.

@Override
public Iterable<? extends Node> getNodes(final Graph<?, ?> graph) {
    final List<Node> nodes = new ArrayList();
    graph.nodes().forEach(nodes::add);
    for (final Node n : graph.nodes()) {
        final Definition def = (Definition) n.getContent();
        if (def.getDefinition() instanceof DecisionService) {
            final List<Node> childNodes = getChildNodes(n);
            nodes.removeAll(childNodes);
            // All edges that points to nodes inside DS now points to DS
            for (final Node o : childNodes) {
                replacedNodes.put(o.getUUID(), n.getUUID());
            }
        }
    }
    return nodes;
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService)

Example 15 with DecisionService

use of org.kie.workbench.common.dmn.api.definition.model.DecisionService in project kie-wb-common by kiegroup.

the class DMNSafeDeleteNodeCommandTest method testShouldKeepChildren.

@Test
public void testShouldKeepChildren() {
    final DecisionService decisionService = mock(DecisionService.class);
    final Node<Definition<?>, Edge> candidate = mock(Node.class);
    final DMNSafeDeleteNodeCommand cmd = createMock(decisionService, candidate);
    final boolean actual = cmd.shouldKeepChildren(candidate);
    assertTrue(actual);
}
Also used : Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Edge(org.kie.workbench.common.stunner.core.graph.Edge) 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