### Question:
AbstractCanvasGraphCommand extends AbstractCanvasCommand implements HasGraphCommand<AbstractCanvasHandler> { @Override public CommandResult<CanvasViolation> allow(final AbstractCanvasHandler context) { final CommandResult<CanvasViolation> result = performOperationOnGraph(context, CommandOperation.ALLOW); if (canDoNexOperation(result)) { return performOperationOnCanvas(context, CommandOperation.ALLOW); } return result; }  @Override Command<GraphCommandExecutionContext, RuleViolation> getGraphCommand(final AbstractCanvasHandler context); Command<AbstractCanvasHandler, CanvasViolation> getCanvasCommand(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> allow(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context);  }### Answer:
@Test @SuppressWarnings("unchecked") public void testAllow() { CommandResult<CanvasViolation> result = tested.allow(canvasHandler); verify(graphCommand, times(1)).allow(eq(graphContext)); verify(canvasCommand, times(1)).allow(eq(canvasHandler)); assertEquals(CommandResult.Type.INFO, result.getType()); assertFalse(result.getViolations().iterator().hasNext()); }
@Test @SuppressWarnings("unchecked") public void testCanvasCommandNotAllowed() { when(canvasCommand.allow(eq(canvasHandler))).thenReturn(CANVAS_COMMAND_FAILED); CommandResult<CanvasViolation> result = tested.allow(canvasHandler); verify(graphCommand, times(1)).allow(eq(graphContext)); verify(canvasCommand, times(1)).allow(eq(canvasHandler)); assertEquals(CommandResult.Type.ERROR, result.getType()); }
@Test @SuppressWarnings("unchecked") public void testGraphCommandNotAllowed() { when(graphCommand.allow(eq(graphContext))).thenReturn(GRAPH_COMMAND_FAILED); CommandResult<CanvasViolation> result = tested.allow(canvasHandler); verify(graphCommand, times(1)).allow(eq(graphContext)); verify(canvasCommand, never()).allow(eq(canvasHandler)); assertEquals(CommandResult.Type.ERROR, result.getType()); }