### Question:
DeferredCompositeCommand extends AbstractCompositeCommand<T, V> { @Override public CommandResult<V> execute(final T context) { return executeCommands(context); } DeferredCompositeCommand(final @MapsTo("reverse") boolean reverse); @Override CommandResult<V> allow(final T context); @Override CommandResult<V> execute(final T context); @Override boolean isUndoReverse();  }### Answer:
@Test @SuppressWarnings("unchecked") public void testExecuteSuccessful() { Command c1 = mockCommand(SUCCESS, SUCCESS); Command c2 = mockCommand(SUCCESS, SUCCESS); Command c3 = mockCommand(SUCCESS, SUCCESS); Command c4 = mockCommand(SUCCESS, SUCCESS); compositeCommand = buildCompositeCommand(c1, c2, c3, c4); compositeCommand.execute(commandExecutionContext); verifyAllowedAndExecuted(c1); verifyAllowedAndExecuted(c2); verifyAllowedAndExecuted(c3); verifyAllowedAndExecuted(c4); }
@Test @SuppressWarnings("unchecked") public void testExecuteWithExecutionFailure() { Command c1 = mockCommand(SUCCESS, SUCCESS); Command c2 = mockCommand(SUCCESS, failed()); Command c3 = mockCommand(SUCCESS, SUCCESS); Command c4 = mockCommand(SUCCESS, SUCCESS); compositeCommand = buildCompositeCommand(c1, c2, c3, c4); compositeCommand.execute(commandExecutionContext); verifyAllowedExecutedAndUnDone(c1); verifyAllowedAndExecuted(c2); verifyNeverUsed(c3); verifyNeverUsed(c4); }