BuildProject extends AbstractCommand { @Override public void execute() throws Exception { logger.trace("Starting {}...", this); final Options options = parse(new Options()); final BuildProjectCommandMode buildProjectCommandMode = commandFactory.apply(options); buildProjectCommandMode.setPrinter(getPrinter()); buildProjectCommandMode.execute(); this.lastBuildResult = buildProjectCommandMode.getLastBuildResult(); }  @Override void execute();  }
@Test public void testExecute() throws Exception { final BuildProjectCommandMode buildProjectCommandMode = mock(BuildProjectCommandMode.class); final Function<Options, BuildProjectCommandMode> factory = options -> buildProjectCommandMode; final BuildProject buildProject = new BuildProject(); buildProject.setCommandFactory(factory); buildProject.execute(); verify(buildProjectCommandMode).execute(); }