BuildProjectCommandMode extends AbstractCommand { @Override public void execute() throws Exception { initialize(); final BuildDetails buildDetails = build(project); handle(buildDetails); this.lastBuildResult = buildDetails; }  @Override void execute();  }
@Test @PrepareForTest(BuildProjectCommandMode.class) public void testExecute() throws Exception { final Builder builder = mock(Builder.class); final BuildDetails buildDetails = new BuildDetails(); buildDetails.setResult(randomUUID().toString()); final WriteProjectTarget targetWriter = mock(WriteProjectTarget.class); whenNew(Builder.class).withAnyArguments().thenReturn(builder); when(builder.build(anyString())).thenReturn(buildDetails); final ProjectFile projectFile = new ProjectFile(); projectFile.setSource(randomUUID().toString()); projectFile.setTarget(randomUUID().toString()); final BuildProjectCommandMode buildProject = new BuildProjectCommandMode() { @Override public ProjectFile readProject() throws IOException { return projectFile; } }; buildProject.setTargetWriter(targetWriter); buildProject.execute(); final BuildDetails lastBuildDetails = buildProject.getLastBuildResult(); logger.debug("Error: {}", lastBuildDetails.getError()); verify(targetWriter).execute(); }