@Test public void testBuildUpdateCommand() { final Decision drgElement = makeDecision("model1.tUUID", "string", true); final String newName = "model2.tUUID"; final String nameId = "nameId"; final AbstractCanvasHandler context = mock(AbstractCanvasHandler.class); final Node node = mock(Node.class); final Definition definition = mock(Definition.class); final Object definitionObject = mock(Object.class); when(node.getContent()).thenReturn(definition); when(definition.getDefinition()).thenReturn(definitionObject); when(definitionUtils.getNameIdentifier(definitionObject)).thenReturn(nameId); when(canvasCommandFactory.updatePropertyValue(eq(node), eq(nameId), any(Name.class))).thenReturn(canvasCommand); doReturn(node).when(handler).getNode(drgElement); final Command<AbstractCanvasHandler, CanvasViolation> command = handler.buildUpdateCommand(drgElement, newName).getCommands().get(0); command.execute(context); assertEquals(canvasCommand, command); }
CompositeCommand<AbstractCanvasHandler, CanvasViolation> buildUpdateCommand(final DRGElement drgElement, final String newName) { final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> commandBuilder = new CompositeCommand.Builder<>(); final Node node = getNode(drgElement); if (node.getContent() instanceof Definition) { final Definition definition = (Definition) node.getContent(); final String nameId = definitionUtils.getNameIdentifier(definition.getDefinition()); if (nameId != null) { commandBuilder.addCommand(canvasCommandFactory.updatePropertyValue(node, nameId, new Name(newName))); } } return commandBuilder.build(); }
DMNIncludedModelHandler implements DRGElementHandler { CompositeCommand<AbstractCanvasHandler, CanvasViolation> buildUpdateCommand(final DRGElement drgElement, final String newName) { final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> commandBuilder = new CompositeCommand.Builder<>(); final Node node = getNode(drgElement); if (node.getContent() instanceof Definition) { final Definition definition = (Definition) node.getContent(); final String nameId = definitionUtils.getNameIdentifier(definition.getDefinition()); if (nameId != null) { commandBuilder.addCommand(canvasCommandFactory.updatePropertyValue(node, nameId, new Name(newName))); } } return commandBuilder.build(); } }
DMNIncludedModelHandler implements DRGElementHandler { CompositeCommand<AbstractCanvasHandler, CanvasViolation> buildUpdateCommand(final DRGElement drgElement, final String newName) { final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> commandBuilder = new CompositeCommand.Builder<>(); final Node node = getNode(drgElement); if (node.getContent() instanceof Definition) { final Definition definition = (Definition) node.getContent(); final String nameId = definitionUtils.getNameIdentifier(definition.getDefinition()); if (nameId != null) { commandBuilder.addCommand(canvasCommandFactory.updatePropertyValue(node, nameId, new Name(newName))); } } return commandBuilder.build(); } @Inject  DMNIncludedModelHandler(final DMNGraphUtils dmnGraphUtils,
                                   final @DMNEditor DefaultCanvasCommandFactory canvasCommandFactory,
                                   final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                                   final DefinitionUtils definitionUtils); }
DMNIncludedModelHandler implements DRGElementHandler { CompositeCommand<AbstractCanvasHandler, CanvasViolation> buildUpdateCommand(final DRGElement drgElement, final String newName) { final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> commandBuilder = new CompositeCommand.Builder<>(); final Node node = getNode(drgElement); if (node.getContent() instanceof Definition) { final Definition definition = (Definition) node.getContent(); final String nameId = definitionUtils.getNameIdentifier(definition.getDefinition()); if (nameId != null) { commandBuilder.addCommand(canvasCommandFactory.updatePropertyValue(node, nameId, new Name(newName))); } } return commandBuilder.build(); } @Inject  DMNIncludedModelHandler(final DMNGraphUtils dmnGraphUtils,
                                   final @DMNEditor DefaultCanvasCommandFactory canvasCommandFactory,
                                   final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                                   final DefinitionUtils definitionUtils); @Override void update(final String oldModelName,
                       final String newModelName); @Override void destroy(final String oldModelName); }
DMNIncludedModelHandler implements DRGElementHandler { CompositeCommand<AbstractCanvasHandler, CanvasViolation> buildUpdateCommand(final DRGElement drgElement, final String newName) { final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> commandBuilder = new CompositeCommand.Builder<>(); final Node node = getNode(drgElement); if (node.getContent() instanceof Definition) { final Definition definition = (Definition) node.getContent(); final String nameId = definitionUtils.getNameIdentifier(definition.getDefinition()); if (nameId != null) { commandBuilder.addCommand(canvasCommandFactory.updatePropertyValue(node, nameId, new Name(newName))); } } return commandBuilder.build(); } @Inject  DMNIncludedModelHandler(final DMNGraphUtils dmnGraphUtils,
                                   final @DMNEditor DefaultCanvasCommandFactory canvasCommandFactory,
                                   final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                                   final DefinitionUtils definitionUtils); @Override void update(final String oldModelName,
                       final String newModelName); @Override void destroy(final String oldModelName);  }