### Question:
ArchetypeServiceImpl implements ArchetypeService { @Override public void add(final GAV archetypeGav) { checkNotNull("archetypeGav", archetypeGav); add(archetypeGav, copyGav(archetypeGav)); } 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 = IllegalArgumentException.class) public void addWhenInvalidArchetypeGavTest() { service.add(null); }
@Test public void addWhenShouldDuplicateGavForTemplateTest() { final GAV gav = createGav(); doNothing().when(service).add(any(GAV.class), any(GAV.class)); service.add(gav); verify(service).add(gav, gav); }
@Test(expected = IllegalArgumentException.class) public void addWhenInvalidTemplateGavTest() { service.add(createGav(), null); }
@Test(expected = ArchetypeAlreadyExistsException.class) public void addWhenArchetypeAlreadyExistsTest() { final GAV gav = createGav(); mockArchetypesOrgUnit(); doReturn(Collections.nCopies(10, mock(Repository.class))) .when(repositoryService).getAllRepositories(any(Space.class)); final Archetype archetype = createArchetype(); doReturn(archetype).when(archetypeConfigStorage).loadArchetype(anyString()); service.add(gav); }