### Question:
CaseManagementDrawCommand extends AbstractCanvasCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Diagram diagram = context.getDiagram(); final String shapeSetId = context.getDiagram().getMetadata().getShapeSetId(); this.sortNodes(diagram); final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> commandBuilder = new CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation>().forward(); childrenTraverseProcessor .traverse(diagram.getGraph(), new AbstractChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() { @Override public void startNodeTraversal(final Node<View, Edge> node) { super.startNodeTraversal(node); commandBuilder.addCommand(new AddCanvasNodeCommand((Node) node, shapeSetId)); } @Override public boolean startNodeTraversal(final List<Node<View, Edge>> parents, final Node<View, Edge> node) { super.startNodeTraversal(parents, node); if (isDrawable(parents.get(parents.size() - 1), node)) { commandBuilder.addCommand(new AddCanvasChildNodeCommand(parents.get(parents.size() - 1), node, shapeSetId)); } return true; } @Override public void endGraphTraversal() { super.endGraphTraversal(); } }); return executeCommands(context, commandBuilder); } CaseManagementDrawCommand(final ChildrenTraverseProcessor childrenTraverseProcessor); @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context);  }### Answer:
@Test public void testExecute() { tested.execute(context); verify(tested).executeCommands(eq(context), commandsCapture.capture()); final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> commands = commandsCapture.getValue(); assertEquals(5, commands.size()); Map<Class<?>, Long> commandsMap = IntStream.range(0, commands.size()) .mapToObj(commands::get).collect(Collectors.groupingBy(Object::getClass, Collectors.counting())); assertEquals(2, commandsMap.size()); assertEquals(1, commandsMap.get(AddCanvasNodeCommand.class).longValue()); assertEquals(4, commandsMap.get(AddCanvasChildNodeCommand.class).longValue()); }