@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); }
@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 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 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); }
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(); }
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();  }