Search in sources :

Example 16 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 getTemplateRepositorySuccessTest.

@Test
public void getTemplateRepositorySuccessTest() {
    mockArchetypesOrgUnit();
    final Archetype archetype = mock(Archetype.class);
    doReturn(ArchetypeStatus.VALID).when(archetype).getStatus();
    doReturn(archetype).when(archetypeConfigStorage).loadArchetype(Mockito.<String>any());
    final Repository expectedRepository = mock(Repository.class);
    doReturn(expectedRepository).when(repositoryService).getRepositoryFromSpace(Mockito.<Space>any(), eq(COMMON_ARCHETYPE_ALIAS));
    final Repository repository = service.getTemplateRepository(COMMON_ARCHETYPE_ALIAS);
    assertSame(expectedRepository, repository);
}
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 17 with Archetype

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

the class LibraryServiceImpl method createProject.

@Override
public WorkspaceProject createProject(final OrganizationalUnit organizationalUnit, final String remoteRepositoryUrl, final String repositoryAlias) {
    final String projectName = repositoryAlias != null ? repositoryAlias : DEFAULT_PROJECT_NAME;
    final Optional<Archetype> baseArchetype = archetypeService.getBaseKieArchetype();
    final String baseArchetypeAlias = baseArchetype.map(Archetype::getAlias).orElse(null);
    final GAV gav = createGAV(projectName, organizationalUnit);
    final POM pom = createPOM(projectName, projectName, gav);
    return createProject(organizationalUnit, pom, DeploymentMode.VALIDATED, baseArchetypeAlias, remoteRepositoryUrl);
}
Also used : Archetype(org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype) GAV(org.guvnor.common.services.project.model.GAV) POM(org.guvnor.common.services.project.model.POM)

Example 18 with Archetype

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

the class ArchetypeConfigStorageTest method saveArchetypeTest.

@Test
public void saveArchetypeTest() {
    final Archetype archetype = mock(Archetype.class);
    doReturn(ARCHETYPE_ALIAS).when(archetype).getAlias();
    archetypeConfigStorage.saveArchetype(archetype);
    verify(objectStorage).write(eq(ARCHETYPE_PATH), same(archetype));
}
Also used : Archetype(org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype) Test(org.junit.Test)

Example 19 with Archetype

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

the class ArchetypeListingPredicatesTest method matchGavTest.

@Test
public void matchGavTest() {
    final Function<GAV, Archetype> createArchetypeMock = gav -> {
        final Archetype archetype = mock(Archetype.class);
        doReturn(gav).when(archetype).getGav();
        return archetype;
    };
    final GAV expectedGav = createGav("myArtifact1");
    final List<Archetype> archetypes = Arrays.asList(createArchetypeMock.apply(expectedGav), createArchetypeMock.apply(createGav("myArtifact2")), createArchetypeMock.apply(createGav("myArtifact3")), createArchetypeMock.apply(createGav("myArtifact4")));
    final List<Archetype> filteredList = archetypes.stream().filter(ArchetypeListingPredicates.matchGav(expectedGav)).collect(Collectors.toList());
    assertThat(filteredList).hasSize(1);
    assertThat(filteredList.get(0).getGav()).isSameAs(expectedGav);
}
Also used : Arrays(java.util.Arrays) BiFunction(java.util.function.BiFunction) GAV(org.guvnor.common.services.project.model.GAV) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) List(java.util.List) ArchetypeStatus(org.kie.workbench.common.screens.archetype.mgmt.shared.model.ArchetypeStatus) Archetype(org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype) Collections(java.util.Collections) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Mockito.doReturn(org.mockito.Mockito.doReturn) Mockito.mock(org.mockito.Mockito.mock) Archetype(org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype) GAV(org.guvnor.common.services.project.model.GAV) Test(org.junit.Test)

Example 20 with Archetype

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

the class ArchetypeServiceImpl method validateAll.

@Override
public void validateAll() {
    getRepositories(matchAllRepositories()).forEach(item -> {
        validateArchetype(item);
        final Archetype archetype = archetypeConfigStorage.loadArchetype(item.getAlias());
        if (archetype.isInternal().equals(Boolean.FALSE)) {
            archetypePreferencesManager.addArchetype(archetype.getAlias());
        }
    });
}
Also used : Archetype(org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype)

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