Search in sources :

Example 26 with Archetype

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

the class ArchetypeServiceImplTest method getTemplateRepositoryWhenInvalidStatusTest.

@Test(expected = IllegalStateException.class)
public void getTemplateRepositoryWhenInvalidStatusTest() {
    mockArchetypesOrgUnit();
    final Archetype archetype = mock(Archetype.class);
    doReturn(ArchetypeStatus.INVALID).when(archetype).getStatus();
    doReturn(archetype).when(archetypeConfigStorage).loadArchetype(Mockito.<String>any());
    service.getTemplateRepository(COMMON_ARCHETYPE_ALIAS);
}
Also used : Archetype(org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype) Test(org.junit.Test)

Example 27 with Archetype

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

the class ArchetypeServiceImplTest method getTemplateRepositoryWhenArchetypeIsInvalidTest.

@Test(expected = IllegalStateException.class)
public void getTemplateRepositoryWhenArchetypeIsInvalidTest() {
    mockArchetypesOrgUnit();
    final Archetype archetype = mock(Archetype.class);
    doReturn(ArchetypeStatus.INVALID).when(archetype).getStatus();
    doReturn(archetype).when(archetypeConfigStorage).loadArchetype(Mockito.<String>any());
    doReturn(mock(Repository.class)).when(repositoryService).getRepositoryFromSpace(Mockito.<Space>any(), Mockito.<String>any());
    service.getTemplateRepository(COMMON_ARCHETYPE_ALIAS);
}
Also used : 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) Test(org.junit.Test)

Example 28 with Archetype

use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype 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)

Example 29 with Archetype

use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype 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();
}
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)

Example 30 with Archetype

use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype 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);
}
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

Archetype (org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype)38 Test (org.junit.Test)31 Repository (org.guvnor.structure.repositories.Repository)14 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)13 ArrayList (java.util.ArrayList)8 ArchetypeItem (org.kie.workbench.common.screens.archetype.mgmt.client.table.item.model.ArchetypeItem)8 PaginatedArchetypeList (org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList)7 Path (org.uberfire.java.nio.file.Path)5 GAV (org.guvnor.common.services.project.model.GAV)3 POM (org.guvnor.common.services.project.model.POM)2 ArchetypeListUpdatedEvent (org.kie.workbench.common.screens.archetype.mgmt.shared.events.ArchetypeListUpdatedEvent)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 File (java.io.File)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 BiFunction (java.util.function.BiFunction)1 Function (java.util.function.Function)1