### Question:
ArchetypeServiceImpl implements ArchetypeService { Path unpackArchetype(final Repository repository) { try { final Path targetDirectoryPath = createTempDirectory(TEMPLATE); final File targetDirectory = new File(targetDirectoryPath.toString()); final File repositoryDirectory = resolveRepositoryDirectory(repository); cloneRepository(repositoryDirectory, targetDirectory.getAbsoluteFile()); return targetDirectoryPath; } catch (Exception e) { final String msg = String.format("Failed to unpack the repository %s", repository.getAlias()); LOGGER.error(msg, e); throw new IllegalStateException(msg); } } 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 public void unpackArchetypeTest() throws GitAPIException { mockArchetypesOrgUnit(); final Path tempPath = mock(Path.class); doReturn(tempPath).when(service).createTempDirectory(anyString()); final Repository repository = mock(Repository.class); doReturn(repository).when(repositoryService).getRepositoryFromSpace(any(Space.class), anyString()); final Git git = mock(Git.class); final org.eclipse.jgit.lib.Repository gitRepository = mock(org.eclipse.jgit.lib.Repository.class); doReturn(mock(File.class)).when(gitRepository).getDirectory(); doReturn(gitRepository).when(git).getRepository(); doReturn(git).when(service).getGitFromRepository(any(Repository.class)); doNothing().when(service).cloneRepository(any(File.class), any(File.class)); final Path unpackedPath = service.unpackArchetype(repository); assertEquals(tempPath, unpackedPath); }