### Question:
ArchetypeServiceImpl implements ArchetypeService { @Override public void delete(final String alias) { checkNotEmpty(ALIAS_PARAM, alias); final OrganizationalUnit archetypesOU = resolveOU(); if (archetypesOU != null) { repositoryService.removeRepository(archetypesOU.getSpace(), alias); archetypeConfigStorage.deleteArchetype(alias); archetypePreferencesManager.removeArchetype(alias); archetypeListUpdatedEvent.fire(new ArchetypeListUpdatedEvent(ArchetypeListOperation.DELETE)); LOGGER.info("Archetype {} successfully deleted.", alias); } else { throw new IllegalStateException("Cannot delete an archetype when there is no archetype space available."); } } 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 deleteWhenInvalidAliasTest() { service.delete(null); }
@Test(expected = IllegalStateException.class) public void deleteWhenArchetypesOrgUnitIsNotAvailableTest() { doReturn(null) .when(ouService).getOrganizationalUnit(ArchetypeConfigStorageImpl.ARCHETYPES_SPACE_NAME); service.delete(COMMON_ARCHETYPE_ALIAS); }
@Test public void deleteSuccessTest() { mockArchetypesOrgUnit(); service.delete(COMMON_ARCHETYPE_ALIAS); verify(repositoryService).removeRepository(any(Space.class), eq(COMMON_ARCHETYPE_ALIAS)); verify(archetypeConfigStorage).deleteArchetype(COMMON_ARCHETYPE_ALIAS); verify(archetypePreferencesManager).removeArchetype(COMMON_ARCHETYPE_ALIAS); verify(archetypeListUpdatedEvent).fire(new ArchetypeListUpdatedEvent(ArchetypeListOperation.DELETE)); }