### Question:
ArchetypeServiceImpl implements ArchetypeService { void executeMaven(final AbstractMavenCommand command) throws MavenEmbedderException { final MavenExecutionResult result = command.execute(); if (result.hasExceptions()) { throwMavenExecutionException(result.getExceptions()); } } ArchetypeServiceImpl(); @Inject  ArchetypeServiceImpl(final @Named("ioStrategy") IOService ioService,
                                final RepositoryService repositoryService,
                                final OrganizationalUnitService ouService,
                                final Event<ArchetypeListUpdatedEvent> archetypeListUpdatedEvent,
                                final ArchetypeConfigStorage archetypeConfigStorage,
                                final PathUtil pathUtil,
                                final ArchetypePreferencesManager archetypePreferencesManager,
                                final KieModuleService moduleService,
                                final POMService pomService); void onNewOrganizationalUnitEvent(final @Observes NewOrganizationalUnitEvent newOrganizationalUnitEvent); @Override void add(final GAV archetypeGav); @Override void add(final GAV archetypeGav,
                    final GAV templateGav); @Override PaginatedArchetypeList list(final Integer page,
                                       final Integer pageSize,
                                       final String filter); @Override PaginatedArchetypeList list(final Integer page,
                                       final Integer pageSize,
                                       final String filter,
                                       final ArchetypeStatus status); @Override void delete(final String alias); @Override void validateAll(); @Override void validate(final String alias); @Override Repository getTemplateRepository(final String alias); @Override Optional<Repository> getBaseKieTemplateRepository(); @Override Optional<Archetype> getBaseKieArchetype();  }### Answer:
@Test(expected = MavenExecutionException.class) public void executeMavenWhenHasExceptionsTest() throws MavenEmbedderException { final AbstractMavenCommand command = mock(AbstractMavenCommand.class); final MavenExecutionResult result = mock(MavenExecutionResult.class); doReturn(true).when(result).hasExceptions(); doReturn(result).when(command).execute(); service.executeMaven(command); }
@Test public void executeMavenSuccessTest() throws MavenEmbedderException { final AbstractMavenCommand command = mock(AbstractMavenCommand.class); doReturn(mock(MavenExecutionResult.class)).when(command).execute(); try { service.executeMaven(command); } catch (Exception e) { fail("Should not have thrown any exception"); } }