### Question:
ArchetypeServiceImpl implements ArchetypeService { @Override public PaginatedArchetypeList list(final Integer page, final Integer pageSize, final String filter) { checkNotNull("page", page); checkNotNull("pageSize", pageSize); final List<Archetype> archetypes = listFilteredArchetypes(matchNotInternalRepositories(), ArchetypeListingPredicates.matchSearchFilter(filter, ArchetypeServiceImpl::composeSearchableElement)); return finishListArchetypes(archetypes, page, pageSize); } 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 listWhenInvalidPageTest() { service.list(null, 1, ""); }
@Test(expected = IllegalArgumentException.class) public void listWhenInvalidPageSizeTest() { service.list(0, null, ""); }
@Test(expected = IllegalArgumentException.class) public void listWhenInvalidStatusTest() { service.list(0, 1, "", null); }
@Test public void listAllTest() { mockArchetypesOrgUnit(); doReturn(Collections.nCopies(10, mock(Repository.class))) .when(repositoryService).getAllRepositories(any(Space.class)); doReturn(createArchetype()).when(archetypeConfigStorage).loadArchetype(anyString()); final PaginatedArchetypeList result = service.list(0, 0, ""); assertThat(result.getTotal()).isEqualTo(10); assertThat(result.getArchetypes()).hasSize(10); assertThat(result.getPageNumber()).isZero(); assertThat(result.getPageSize()).isZero(); }
@Test public void listAllPaginatedTest() { mockArchetypesOrgUnit(); doReturn(Collections.nCopies(13, mock(Repository.class))) .when(repositoryService).getAllRepositories(any(Space.class)); doReturn(createArchetype()).when(archetypeConfigStorage).loadArchetype(anyString()); PaginatedArchetypeList result = service.list(0, 5, ""); assertThat(result.getTotal()).isEqualTo(13); assertThat(result.getArchetypes()).hasSize(5); assertThat(result.getPageNumber()).isEqualTo(0); assertThat(result.getPageSize()).isEqualTo(5); result = service.list(1, 5, ""); assertThat(result.getTotal()).isEqualTo(13); assertThat(result.getArchetypes()).hasSize(5); assertThat(result.getPageNumber()).isEqualTo(1); assertThat(result.getPageSize()).isEqualTo(5); result = service.list(2, 5, ""); assertThat(result.getTotal()).isEqualTo(13); assertThat(result.getArchetypes()).hasSize(3); assertThat(result.getPageNumber()).isEqualTo(2); assertThat(result.getPageSize()).isEqualTo(5); }