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());
}
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);
}
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));
}
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;
}
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);
}
Aggregations