use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList in project kie-wb-common by kiegroup.
the class AbstractArchetypeTablePresenterTest method finishLoadListTest.
@Test
public void finishLoadListTest() {
final List<Archetype> archetypes = new ArrayList<>();
archetypes.add(createArchetypeWithAlias("archetype 1"));
archetypes.add(createArchetypeWithAlias("archetype 2"));
archetypes.add(createArchetypeWithAlias("archetype 3"));
final Map<String, Boolean> selectionMap = new HashMap<>();
selectionMap.put("archetype 1", true);
selectionMap.put("archetype 2", true);
selectionMap.put("archetype 3", true);
final PaginatedArchetypeList paginatedArchetypeList = new PaginatedArchetypeList(archetypes, 0, 10, 3);
doReturn(selectionMap).when(archetypePreferences).getArchetypeSelectionMap();
doReturn("archetype 1").when(archetypePreferences).getDefaultSelection();
presenter.finishLoadList(paginatedArchetypeList);
verify(archetypeListPresenter).setup(any(), any(), any());
verify(view).setSelectionCounter(Mockito.<String>any());
verify(busyIndicatorView).hideBusyIndicator();
verify(view).show(true);
}
use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList in project kie-wb-common by kiegroup.
the class AbstractArchetypeTablePresenterTest method configureViewWhenEmptyTest.
@Test
public void configureViewWhenEmptyTest() {
final ArchetypeTableConfiguration config = new ArchetypeTableConfiguration.Builder().withAddAction().withIncludeColumn().withStatusColumn().build();
doReturn(config).when(presenter).getConfiguration();
final PaginatedArchetypeList paginatedArchetypeList = new PaginatedArchetypeList(Collections.emptyList(), 0, 0, 0);
presenter.configureView(paginatedArchetypeList);
verify(view).showAddAction(true);
verify(view).showIncludeHeader(true);
verify(view).showStatusHeader(true);
verify(view).showSelectionCounter(true);
verify(view).showNoResults(false);
verify(view).showPagination(false);
verify(view).showToolbar(false);
verify(view).showEmpty(true);
}
use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList in project kie-wb-common by kiegroup.
the class AbstractArchetypeTablePresenter method loadList.
protected Promise<Void> loadList(boolean isRefresh) {
if (!isRefresh) {
view.show(false);
}
showBusyIndicator(ts.getTranslation(ArchetypeManagementConstants.ArchetypeManagement_Loading));
return promises.create((resolve, reject) -> archetypeService.call((final PaginatedArchetypeList paginatedList) -> {
setupCounters(paginatedList.getTotal());
configureView(paginatedList);
if (isRefresh) {
finishLoadList(paginatedList);
resolve.onInvoke(promises.resolve());
} else {
resolve.onInvoke(loadPreferences(paginatedList));
}
}, new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)).list(Math.max(0, currentPage - 1), PAGE_SIZE, searchFilter));
}
use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList in project kie-wb-common by kiegroup.
the class ArchetypeServiceImplTest method listAllTest.
@Test
public void listAllTest() {
mockArchetypesOrgUnit();
doReturn(Collections.nCopies(10, mock(Repository.class))).when(repositoryService).getAllRepositories(Mockito.<Space>any());
doReturn(createArchetype()).when(archetypeConfigStorage).loadArchetype(Mockito.<String>any());
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();
}
use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList in project kie-wb-common by kiegroup.
the class ArchetypeServiceImplTest method listAllWithStatusPaginatedTest.
@Test
public void listAllWithStatusPaginatedTest() {
mockArchetypesOrgUnit();
final Archetype archetype1 = createArchetypeWithFields("findme", ArchetypeStatus.VALID);
final Archetype archetype2 = createArchetypeWithFields("tryfindme", ArchetypeStatus.INVALID);
final List<Archetype> archetypes = new ArrayList<>();
archetypes.addAll(Collections.nCopies(13, archetype1));
archetypes.addAll(Collections.nCopies(5, 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());
PaginatedArchetypeList result = service.list(0, 5, "", 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, "", 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, "", ArchetypeStatus.VALID);
assertThat(result.getTotal()).isEqualTo(13);
assertThat(result.getArchetypes()).hasSize(3);
assertThat(result.getPageNumber()).isEqualTo(2);
assertThat(result.getPageSize()).isEqualTo(5);
}
Aggregations