Search in sources :

Example 1 with DMNGraphsProvider

use of org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNGraphsProvider in project kie-wb-common by kiegroup.

the class DMNDeleteElementsCommandTest method testNewGraphCommand.

@Test
public void testNewGraphCommand() {
    final DMNGraphsProvider selectedDiagramProvider = mock(DMNGraphsProvider.class);
    final ArrayList<Element> elements = new ArrayList<>();
    final Element element = mock(Element.class);
    when(element.getUUID()).thenReturn("uuid");
    elements.add(element);
    final DMNDeleteElementsCommand cmd = new DMNDeleteElementsCommand(elements, selectedDiagramProvider);
    final Command<GraphCommandExecutionContext, RuleViolation> actual = cmd.newGraphCommand(null);
    assertTrue(actual instanceof DMNDeleteElementsGraphCommand);
    assertEquals(cmd.getGraphsProvider(), ((DMNDeleteElementsGraphCommand) actual).getGraphsProvider());
}
Also used : Element(org.kie.workbench.common.stunner.core.graph.Element) ArrayList(java.util.ArrayList) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) DMNDeleteElementsGraphCommand(org.kie.workbench.common.dmn.client.commands.factory.graph.DMNDeleteElementsGraphCommand) DMNGraphsProvider(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNGraphsProvider) Test(org.junit.Test)

Example 2 with DMNGraphsProvider

use of org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNGraphsProvider in project kie-wb-common by kiegroup.

the class DMNDeleteNodeCommandTest method testNewGraphCommand.

@Test
public void testNewGraphCommand() {
    final DMNGraphsProvider selectedDiagramProvider = mock(DMNGraphsProvider.class);
    final Node candidate = mock(Node.class);
    when(candidate.getUUID()).thenReturn("uuid");
    final DMNDeleteNodeCommand cmd = new DMNDeleteNodeCommand(candidate, selectedDiagramProvider);
    final Command<GraphCommandExecutionContext, RuleViolation> actual = cmd.newGraphCommand(null);
    assertTrue(actual instanceof DMNSafeDeleteNodeCommand);
    final DMNSafeDeleteNodeCommand safeCmd = (DMNSafeDeleteNodeCommand) actual;
    assertEquals(cmd.getCandidate(), safeCmd.getNode());
    assertEquals(cmd.getDeleteProcessor(), safeCmd.getSafeDeleteCallback().get());
    assertEquals(cmd.getOptions(), safeCmd.getOptions());
    assertEquals(cmd.getGraphsProvider(), safeCmd.getGraphsProvider());
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) DMNGraphsProvider(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNGraphsProvider) Test(org.junit.Test)

Example 3 with DMNGraphsProvider

use of org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNGraphsProvider 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)

Aggregations

Test (org.junit.Test)3 DMNGraphsProvider (org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNGraphsProvider)3 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)2 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)2 ArrayList (java.util.ArrayList)1 DMNSafeDeleteNodeCommand (org.kie.workbench.common.dmn.client.commands.factory.canvas.DMNSafeDeleteNodeCommand)1 DMNDeleteElementsGraphCommand (org.kie.workbench.common.dmn.client.commands.factory.graph.DMNDeleteElementsGraphCommand)1 Edge (org.kie.workbench.common.stunner.core.graph.Edge)1 Element (org.kie.workbench.common.stunner.core.graph.Element)1 Node (org.kie.workbench.common.stunner.core.graph.Node)1 DeleteElementsCommand (org.kie.workbench.common.stunner.core.graph.command.impl.DeleteElementsCommand)1 SafeDeleteNodeCommand (org.kie.workbench.common.stunner.core.graph.command.impl.SafeDeleteNodeCommand)1