use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList in project kie-wb-common by kiegroup.
the class ArchetypeServiceImplTest method listAllWithFilterTest.
@Test
public void listAllWithFilterTest() {
mockArchetypesOrgUnit();
final Archetype archetype1 = createArchetypeWithAlias("findme");
final Archetype archetype2 = createArchetypeWithAlias("hidden");
final List<Archetype> archetypes = new ArrayList<>();
archetypes.addAll(Collections.nCopies(26, archetype1));
archetypes.addAll(Collections.nCopies(30, archetype2));
final List<Repository> repositories = new ArrayList<>();
archetypes.forEach(archetype -> {
doReturn(archetype).when(archetypeConfigStorage).loadArchetype(archetype.getAlias());
final Repository repository = mock(Repository.class);
doReturn(archetype.getAlias()).when(repository).getAlias();
repositories.add(repository);
});
doReturn(repositories).when(repositoryService).getAllRepositories(Mockito.<Space>any());
final PaginatedArchetypeList result = service.list(0, 0, "findme");
assertThat(result.getTotal()).isEqualTo(26);
assertThat(result.getArchetypes()).hasSize(26);
assertThat(result.getPageNumber()).isZero();
assertThat(result.getPageSize()).isZero();
}
use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList in project kie-wb-common by kiegroup.
the class ArchetypeServiceImplTest method listAllWithFilterAndStatusPaginatedTest.
@Test
public void listAllWithFilterAndStatusPaginatedTest() {
mockArchetypesOrgUnit();
final Archetype archetype1 = createArchetypeWithFields("findme", ArchetypeStatus.VALID);
final Archetype archetype2 = createArchetypeWithFields("tryfindme", ArchetypeStatus.INVALID);
final Archetype archetype3 = createArchetypeWithFields("hidden", ArchetypeStatus.VALID);
final Archetype archetype4 = createArchetypeWithFields("hidden", ArchetypeStatus.INVALID);
final List<Archetype> archetypes = new ArrayList<>();
archetypes.addAll(Collections.nCopies(13, archetype1));
archetypes.addAll(Collections.nCopies(5, archetype2));
archetypes.addAll(Collections.nCopies(7, archetype3));
archetypes.addAll(Collections.nCopies(9, archetype4));
final List<Repository> repositories = new ArrayList<>();
archetypes.forEach(archetype -> {
doReturn(archetype).when(archetypeConfigStorage).loadArchetype(archetype.getAlias());
final Repository repository = mock(Repository.class);
doReturn(archetype.getAlias()).when(repository).getAlias();
repositories.add(repository);
});
doReturn(repositories).when(repositoryService).getAllRepositories(Mockito.<Space>any());
PaginatedArchetypeList result = service.list(0, 5, "findme", ArchetypeStatus.VALID);
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, "findme", ArchetypeStatus.VALID);
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, "findme", ArchetypeStatus.VALID);
assertThat(result.getTotal()).isEqualTo(13);
assertThat(result.getArchetypes()).hasSize(3);
assertThat(result.getPageNumber()).isEqualTo(2);
assertThat(result.getPageSize()).isEqualTo(5);
}
use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList in project kie-wb-common by kiegroup.
the class ArchetypeServiceImplTest method listAllWithStatusTest.
@Test
public void listAllWithStatusTest() {
mockArchetypesOrgUnit();
final Archetype archetype1 = createArchetypeWithFields("findme", ArchetypeStatus.VALID);
final Archetype archetype2 = createArchetypeWithFields("hidden", ArchetypeStatus.INVALID);
final List<Archetype> archetypes = new ArrayList<>();
archetypes.addAll(Collections.nCopies(12, archetype1));
archetypes.addAll(Collections.nCopies(13, archetype2));
final List<Repository> repositories = new ArrayList<>();
archetypes.forEach(archetype -> {
doReturn(archetype).when(archetypeConfigStorage).loadArchetype(archetype.getAlias());
final Repository repository = mock(Repository.class);
doReturn(archetype.getAlias()).when(repository).getAlias();
repositories.add(repository);
});
doReturn(repositories).when(repositoryService).getAllRepositories(Mockito.<Space>any());
final PaginatedArchetypeList result = service.list(0, 0, "", ArchetypeStatus.VALID);
assertThat(result.getTotal()).isEqualTo(12);
assertThat(result.getArchetypes()).hasSize(12);
assertThat(result.getPageNumber()).isZero();
assertThat(result.getPageSize()).isZero();
}
use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList in project kie-wb-common by kiegroup.
the class ArchetypeServiceImplTest method listAllWithFilterAndStatusTest.
@Test
public void listAllWithFilterAndStatusTest() {
mockArchetypesOrgUnit();
final Archetype archetype1 = createArchetypeWithFields("findme", ArchetypeStatus.VALID);
final Archetype archetype2 = createArchetypeWithFields("tryfindme", ArchetypeStatus.INVALID);
final Archetype archetype3 = createArchetypeWithFields("hidden", ArchetypeStatus.VALID);
final Archetype archetype4 = createArchetypeWithFields("hidden", ArchetypeStatus.INVALID);
final List<Archetype> archetypes = new ArrayList<>();
archetypes.addAll(Collections.nCopies(12, archetype1));
archetypes.addAll(Collections.nCopies(13, archetype2));
archetypes.addAll(Collections.nCopies(14, archetype3));
archetypes.addAll(Collections.nCopies(15, archetype4));
final List<Repository> repositories = new ArrayList<>();
archetypes.forEach(archetype -> {
doReturn(archetype).when(archetypeConfigStorage).loadArchetype(archetype.getAlias());
final Repository repository = mock(Repository.class);
doReturn(archetype.getAlias()).when(repository).getAlias();
repositories.add(repository);
});
doReturn(repositories).when(repositoryService).getAllRepositories(Mockito.<Space>any());
final PaginatedArchetypeList result = service.list(0, 0, "findme", ArchetypeStatus.VALID);
assertThat(result.getTotal()).isEqualTo(12);
assertThat(result.getArchetypes()).hasSize(12);
assertThat(result.getPageNumber()).isZero();
assertThat(result.getPageSize()).isZero();
}
Aggregations