### Question:
BuildProjectCommand extends AbstractMavenCommand { @Override public MavenExecutionResult execute() throws MavenEmbedderException { final MavenExecutionResult result = new DefaultMavenExecutionResult(); final MavenEmbedder mavenEmbedder = createMavenEmbedder(); final String pomPath = baseDirectory + FileSystems.getDefault().getSeparator() + POMServiceImpl.POM_XML; try { final File pomFile = new File(pomPath); mavenEmbedder.buildProjects(pomFile, false); } catch (ProjectBuildingException e) { result.addException(e); } finally { mavenEmbedder.dispose(); } return result; } BuildProjectCommand(final String baseDirectory); @Override MavenRequest buildMavenRequest(); @Override Properties buildUserProperties(); @Override MavenExecutionResult execute();  }### Answer:
@Test public void executeSuccessTest() throws MavenEmbedderException, ProjectBuildingException { final BuildProjectCommand command = spy(new BuildProjectCommand(BASE_DIRECTORY)); final MavenEmbedder mavenEmbedder = mock(MavenEmbedder.class); doReturn(Collections.emptyList()).when(mavenEmbedder).buildProjects(any(File.class), eq(false)); doReturn(mavenEmbedder).when(command).createMavenEmbedder(); final MavenExecutionResult executionResult = command.execute(); assertFalse(executionResult.hasExceptions()); }
@Test public void executeFailedTest() throws MavenEmbedderException, ProjectBuildingException { final BuildProjectCommand command = spy(new BuildProjectCommand(BASE_DIRECTORY)); final MavenEmbedder mavenEmbedder = mock(MavenEmbedder.class); doThrow(ProjectBuildingException.class).when(mavenEmbedder).buildProjects(any(File.class), eq(false)); doReturn(mavenEmbedder).when(command).createMavenEmbedder(); final MavenExecutionResult executionResult = command.execute(); assertTrue(executionResult.hasExceptions()); }