@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(any(Class.class))).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), anyObject())).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)); }
@Override @SuppressWarnings("unchecked") public void register(final Element element) { if (checkNotRegistered(element)) { final Object definition = ((Definition) element.getContent()).getDefinition(); if (!isDecisionServiceDefinition(definition)) { return; } final Canvas<?> canvas = canvasHandler.getCanvas(); final Shape<?> shape = canvas.getShape(element.getUUID()); final ShapeView<?> shapeView = shape.getShapeView(); if (!isDecisionServiceShapeView(shapeView)) { return; } final DecisionServiceSVGShapeView decisionServiceShapeView = (DecisionServiceSVGShapeView) shapeView; final DragHandler dragHandler = new DragHandler() { @Override public void end(final DragEvent event) { final CommandResult<CanvasViolation> result = doMoveDivider(element, decisionServiceShapeView.getDividerLineY()); if (CommandUtils.isError(result)) { LOGGER.log(Level.WARNING, "Command failed at resize end [result=" + result + "]"); } } }; decisionServiceShapeView.addDividerDragHandler(dragHandler); registerHandler(element.getUUID(), dragHandler); } }
DecisionServiceMoveDividerControl extends AbstractCanvasHandlerRegistrationControl<AbstractCanvasHandler> implements RequiresCommandManager<AbstractCanvasHandler>,
                                                                                                                                  RequiresCommandManager.CommandManagerProvider<AbstractCanvasHandler> { @Override @SuppressWarnings("unchecked") public void register(final Element element) { if (checkNotRegistered(element)) { final Object definition = ((Definition) element.getContent()).getDefinition(); if (!isDecisionServiceDefinition(definition)) { return; } final Canvas<?> canvas = canvasHandler.getCanvas(); final Shape<?> shape = canvas.getShape(element.getUUID()); final ShapeView<?> shapeView = shape.getShapeView(); if (!isDecisionServiceShapeView(shapeView)) { return; } final DecisionServiceSVGShapeView decisionServiceShapeView = (DecisionServiceSVGShapeView) shapeView; final DragHandler dragHandler = new DragHandler() { @Override public void end(final DragEvent event) { final CommandResult<CanvasViolation> result = doMoveDivider(element, decisionServiceShapeView.getDividerLineY()); if (CommandUtils.isError(result)) { LOGGER.log(Level.WARNING, "Command failed at resize end [result=" + result + "]"); } } }; decisionServiceShapeView.addDividerDragHandler(dragHandler); registerHandler(element.getUUID(), dragHandler); } } }
DecisionServiceMoveDividerControl extends AbstractCanvasHandlerRegistrationControl<AbstractCanvasHandler> implements RequiresCommandManager<AbstractCanvasHandler>,
                                                                                                                                  RequiresCommandManager.CommandManagerProvider<AbstractCanvasHandler> { @Override @SuppressWarnings("unchecked") public void register(final Element element) { if (checkNotRegistered(element)) { final Object definition = ((Definition) element.getContent()).getDefinition(); if (!isDecisionServiceDefinition(definition)) { return; } final Canvas<?> canvas = canvasHandler.getCanvas(); final Shape<?> shape = canvas.getShape(element.getUUID()); final ShapeView<?> shapeView = shape.getShapeView(); if (!isDecisionServiceShapeView(shapeView)) { return; } final DecisionServiceSVGShapeView decisionServiceShapeView = (DecisionServiceSVGShapeView) shapeView; final DragHandler dragHandler = new DragHandler() { @Override public void end(final DragEvent event) { final CommandResult<CanvasViolation> result = doMoveDivider(element, decisionServiceShapeView.getDividerLineY()); if (CommandUtils.isError(result)) { LOGGER.log(Level.WARNING, "Command failed at resize end [result=" + result + "]"); } } }; decisionServiceShapeView.addDividerDragHandler(dragHandler); registerHandler(element.getUUID(), dragHandler); } } protected  DecisionServiceMoveDividerControl(); @Inject  DecisionServiceMoveDividerControl(final @DMNEditor DefaultCanvasCommandFactory canvasCommandFactory); }
DecisionServiceMoveDividerControl extends AbstractCanvasHandlerRegistrationControl<AbstractCanvasHandler> implements RequiresCommandManager<AbstractCanvasHandler>,
                                                                                                                                  RequiresCommandManager.CommandManagerProvider<AbstractCanvasHandler> { @Override @SuppressWarnings("unchecked") public void register(final Element element) { if (checkNotRegistered(element)) { final Object definition = ((Definition) element.getContent()).getDefinition(); if (!isDecisionServiceDefinition(definition)) { return; } final Canvas<?> canvas = canvasHandler.getCanvas(); final Shape<?> shape = canvas.getShape(element.getUUID()); final ShapeView<?> shapeView = shape.getShapeView(); if (!isDecisionServiceShapeView(shapeView)) { return; } final DecisionServiceSVGShapeView decisionServiceShapeView = (DecisionServiceSVGShapeView) shapeView; final DragHandler dragHandler = new DragHandler() { @Override public void end(final DragEvent event) { final CommandResult<CanvasViolation> result = doMoveDivider(element, decisionServiceShapeView.getDividerLineY()); if (CommandUtils.isError(result)) { LOGGER.log(Level.WARNING, "Command failed at resize end [result=" + result + "]"); } } }; decisionServiceShapeView.addDividerDragHandler(dragHandler); registerHandler(element.getUUID(), dragHandler); } } protected  DecisionServiceMoveDividerControl(); @Inject  DecisionServiceMoveDividerControl(final @DMNEditor DefaultCanvasCommandFactory canvasCommandFactory); @Override @SuppressWarnings("unchecked") void register(final Element element); @Override //Override to increase visibility for Unit Tests void registerHandler(final String uuid,
                                final ViewHandler<?> handler); @Override void setCommandManagerProvider(final RequiresCommandManager.CommandManagerProvider<AbstractCanvasHandler> provider); @Override CanvasCommandManager<AbstractCanvasHandler> getCommandManager(); }
DecisionServiceMoveDividerControl extends AbstractCanvasHandlerRegistrationControl<AbstractCanvasHandler> implements RequiresCommandManager<AbstractCanvasHandler>,
                                                                                                                                  RequiresCommandManager.CommandManagerProvider<AbstractCanvasHandler> { @Override @SuppressWarnings("unchecked") public void register(final Element element) { if (checkNotRegistered(element)) { final Object definition = ((Definition) element.getContent()).getDefinition(); if (!isDecisionServiceDefinition(definition)) { return; } final Canvas<?> canvas = canvasHandler.getCanvas(); final Shape<?> shape = canvas.getShape(element.getUUID()); final ShapeView<?> shapeView = shape.getShapeView(); if (!isDecisionServiceShapeView(shapeView)) { return; } final DecisionServiceSVGShapeView decisionServiceShapeView = (DecisionServiceSVGShapeView) shapeView; final DragHandler dragHandler = new DragHandler() { @Override public void end(final DragEvent event) { final CommandResult<CanvasViolation> result = doMoveDivider(element, decisionServiceShapeView.getDividerLineY()); if (CommandUtils.isError(result)) { LOGGER.log(Level.WARNING, "Command failed at resize end [result=" + result + "]"); } } }; decisionServiceShapeView.addDividerDragHandler(dragHandler); registerHandler(element.getUUID(), dragHandler); } } protected  DecisionServiceMoveDividerControl(); @Inject  DecisionServiceMoveDividerControl(final @DMNEditor DefaultCanvasCommandFactory canvasCommandFactory); @Override @SuppressWarnings("unchecked") void register(final Element element); @Override //Override to increase visibility for Unit Tests void registerHandler(final String uuid,
                                final ViewHandler<?> handler); @Override void setCommandManagerProvider(final RequiresCommandManager.CommandManagerProvider<AbstractCanvasHandler> provider); @Override CanvasCommandManager<AbstractCanvasHandler> getCommandManager();  }