Search in sources :

Example 1 with SafeDeleteNodeCommand

use of org.kie.workbench.common.stunner.core.graph.command.impl.SafeDeleteNodeCommand in project kie-wb-common by kiegroup.

the class MultipleEvaluationContextStatesTest method testExecuteShortcutWithRules.

@Test
@SuppressWarnings("unchecked")
public void testExecuteShortcutWithRules() {
    SafeDeleteNodeCommand deleteNodeCommand = new SafeDeleteNodeCommand(graph1Instance.intermNode);
    ContextualGraphCommandExecutionContext executionContext = createExecutionContext();
    CommandResult<RuleViolation> result = deleteNodeCommand.allow(executionContext);
    assertFalse(isError(result));
    assertFalse(isWarn(result));
    assertFalse(result.getViolations().iterator().hasNext());
}
Also used : SafeDeleteNodeCommand(org.kie.workbench.common.stunner.core.graph.command.impl.SafeDeleteNodeCommand) ContextualGraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext) Test(org.junit.Test)

Example 2 with SafeDeleteNodeCommand

use of org.kie.workbench.common.stunner.core.graph.command.impl.SafeDeleteNodeCommand in project kie-wb-common by kiegroup.

the class DMNDeleteElementsGraphCommandTest method testCreateSafeDeleteNodeCommand.

@Test
public void testCreateSafeDeleteNodeCommand() {
    final DMNGraphsProvider selectedDiagramProvider = mock(DMNGraphsProvider.class);
    final Node<?, Edge> node = mock(Node.class);
    final SafeDeleteNodeCommand.Options options = SafeDeleteNodeCommand.Options.defaults();
    final DeleteElementsCommand.DeleteCallback callback = mock(DeleteElementsCommand.DeleteCallback.class);
    final DMNDeleteElementsGraphCommand command = mock(DMNDeleteElementsGraphCommand.class);
    when(command.getGraphsProvider()).thenReturn(selectedDiagramProvider);
    when(node.getUUID()).thenReturn("uuid");
    when(command.createSafeDeleteNodeCommand(node, options, callback)).thenCallRealMethod();
    final SafeDeleteNodeCommand actual = command.createSafeDeleteNodeCommand(node, options, callback);
    assertTrue(actual instanceof DMNSafeDeleteNodeCommand);
    final DMNSafeDeleteNodeCommand dmnCommand = (DMNSafeDeleteNodeCommand) actual;
    assertEquals(dmnCommand.getNode(), node);
    assertEquals(dmnCommand.getOptions(), options);
    assertEquals(dmnCommand.getGraphsProvider(), selectedDiagramProvider);
}
Also used : DeleteElementsCommand(org.kie.workbench.common.stunner.core.graph.command.impl.DeleteElementsCommand) DMNSafeDeleteNodeCommand(org.kie.workbench.common.dmn.client.commands.factory.canvas.DMNSafeDeleteNodeCommand) DMNSafeDeleteNodeCommand(org.kie.workbench.common.dmn.client.commands.factory.canvas.DMNSafeDeleteNodeCommand) SafeDeleteNodeCommand(org.kie.workbench.common.stunner.core.graph.command.impl.SafeDeleteNodeCommand) Edge(org.kie.workbench.common.stunner.core.graph.Edge) DMNGraphsProvider(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNGraphsProvider) Test(org.junit.Test)

Example 3 with SafeDeleteNodeCommand

use of org.kie.workbench.common.stunner.core.graph.command.impl.SafeDeleteNodeCommand in project kie-wb-common by kiegroup.

the class MultipleEvaluationContextStatesTest method testValidShortcut.

@Test
@SuppressWarnings("unchecked")
public void testValidShortcut() {
    SafeDeleteNodeCommand deleteNodeCommand = new SafeDeleteNodeCommand(graph1Instance.intermNode);
    CommandResult<RuleViolation> result = deleteNodeCommand.allow(createExecutionContext());
    assertFalse(isError(result));
    assertFalse(isWarn(result));
    assertFalse(result.getViolations().iterator().hasNext());
}
Also used : SafeDeleteNodeCommand(org.kie.workbench.common.stunner.core.graph.command.impl.SafeDeleteNodeCommand) Test(org.junit.Test)

Example 4 with SafeDeleteNodeCommand

use of org.kie.workbench.common.stunner.core.graph.command.impl.SafeDeleteNodeCommand in project kie-wb-common by kiegroup.

the class MultipleEvaluationContextStatesTest method testAllowShortcutWithRules.

@Test
@SuppressWarnings("unchecked")
public void testAllowShortcutWithRules() {
    SafeDeleteNodeCommand deleteNodeCommand = new SafeDeleteNodeCommand(graph1Instance.intermNode);
    ContextualGraphCommandExecutionContext executionContext = createExecutionContext();
    CommandResult<RuleViolation> result = deleteNodeCommand.allow(executionContext);
    assertFalse(isError(result));
    assertFalse(isWarn(result));
    assertFalse(result.getViolations().iterator().hasNext());
}
Also used : SafeDeleteNodeCommand(org.kie.workbench.common.stunner.core.graph.command.impl.SafeDeleteNodeCommand) ContextualGraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 SafeDeleteNodeCommand (org.kie.workbench.common.stunner.core.graph.command.impl.SafeDeleteNodeCommand)4 ContextualGraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext)2 DMNSafeDeleteNodeCommand (org.kie.workbench.common.dmn.client.commands.factory.canvas.DMNSafeDeleteNodeCommand)1 DMNGraphsProvider (org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNGraphsProvider)1 Edge (org.kie.workbench.common.stunner.core.graph.Edge)1 DeleteElementsCommand (org.kie.workbench.common.stunner.core.graph.command.impl.DeleteElementsCommand)1