Search in sources :

Example 6 with PaginatedArchetypeList

use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList in project kie-wb-common by kiegroup.

the class AbstractArchetypeTablePresenterTest method configureViewWhenSearchEmptyTest.

@Test
public void configureViewWhenSearchEmptyTest() {
    setPresenterPrivateField("searchFilter", "keyword");
    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(true);
    verify(view).showPagination(false);
    verify(view).showToolbar(true);
    verify(view).showEmpty(false);
}
Also used : PaginatedArchetypeList(org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList) ArchetypeTableConfiguration(org.kie.workbench.common.screens.archetype.mgmt.client.table.config.ArchetypeTableConfiguration) Test(org.junit.Test)

Example 7 with PaginatedArchetypeList

use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList in project kie-wb-common by kiegroup.

the class AbstractArchetypeTablePresenterTest method configureViewWhenPopulatedTest.

@Test
public void configureViewWhenPopulatedTest() {
    final ArchetypeTableConfiguration config = new ArchetypeTableConfiguration.Builder().withAddAction().withIncludeColumn().withStatusColumn().build();
    doReturn(config).when(presenter).getConfiguration();
    final PaginatedArchetypeList paginatedArchetypeList = new PaginatedArchetypeList(Collections.nCopies(10, mock(Archetype.class)), 0, 10, 10);
    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(true);
    verify(view).showToolbar(true);
    verify(view).showEmpty(false);
}
Also used : PaginatedArchetypeList(org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList) ArchetypeTableConfiguration(org.kie.workbench.common.screens.archetype.mgmt.client.table.config.ArchetypeTableConfiguration) Test(org.junit.Test)

Example 8 with PaginatedArchetypeList

use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList in project kie-wb-common by kiegroup.

the class AbstractArchetypeTablePresenterTest method loadPreferencesSuccessCallbackTest.

@Test
public void loadPreferencesSuccessCallbackTest() {
    final PaginatedArchetypeList paginatedArchetypeList = mock(PaginatedArchetypeList.class);
    doNothing().when(presenter).finishLoadList(paginatedArchetypeList);
    presenter.loadPreferencesSuccessCallback(paginatedArchetypeList, mock(Promise.PromiseExecutorCallbackFn.ResolveCallbackFn.class)).execute(archetypePreferences);
    verify(presenter).finishLoadList(paginatedArchetypeList);
}
Also used : PaginatedArchetypeList(org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList) Test(org.junit.Test)

Example 9 with PaginatedArchetypeList

use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList in project kie-wb-common by kiegroup.

the class ArchetypeServiceImplTest method listAllPaginatedTest.

@Test
public void listAllPaginatedTest() {
    mockArchetypesOrgUnit();
    doReturn(Collections.nCopies(13, mock(Repository.class))).when(repositoryService).getAllRepositories(Mockito.<Space>any());
    doReturn(createArchetype()).when(archetypeConfigStorage).loadArchetype(Mockito.<String>any());
    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);
}
Also used : PaginatedArchetypeList(org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList) Test(org.junit.Test)

Example 10 with PaginatedArchetypeList

use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList in project kie-wb-common by kiegroup.

the class ArchetypeServiceImplTest method listAllWithFilterPaginatedTest.

@Test
public void listAllWithFilterPaginatedTest() {
    mockArchetypesOrgUnit();
    final Archetype archetype1 = createArchetypeWithAlias("findme");
    final Archetype archetype2 = createArchetypeWithAlias("hidden");
    final List<Archetype> archetypes = new ArrayList<>();
    archetypes.addAll(Collections.nCopies(13, 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);
    });
    final String filterText = "findme";
    doReturn(repositories).when(repositoryService).getAllRepositories(Mockito.<Space>any());
    PaginatedArchetypeList result = service.list(0, 5, filterText);
    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, filterText);
    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, filterText);
    assertThat(result.getTotal()).isEqualTo(13);
    assertThat(result.getArchetypes()).hasSize(3);
    assertThat(result.getPageNumber()).isEqualTo(2);
    assertThat(result.getPageSize()).isEqualTo(5);
}
Also used : PaginatedArchetypeList(org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) Archetype(org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

PaginatedArchetypeList (org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList)14 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)7 Archetype (org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype)7 Repository (org.guvnor.structure.repositories.Repository)6 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)6 ArchetypeTableConfiguration (org.kie.workbench.common.screens.archetype.mgmt.client.table.config.ArchetypeTableConfiguration)3 HashMap (java.util.HashMap)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 HasBusyIndicatorDefaultErrorCallback (org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback)1