use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype in project kie-wb-common by kiegroup.
the class ArchetypeServiceImplTest method validateAllWhenExecuteMavenThrowsExceptionTest.
@Test
public void validateAllWhenExecuteMavenThrowsExceptionTest() throws MavenEmbedderException {
mockArchetypesOrgUnit();
doReturn(Collections.singletonList(mock(Repository.class))).when(repositoryService).getAllRepositories(Mockito.<Space>any());
doReturn(mock(Path.class)).when(service).unpackArchetype(Mockito.<Repository>any());
doThrow(MavenEmbedderException.class).when(service).executeMaven(Mockito.<BuildProjectCommand>any());
final Archetype archetype = createArchetypeWithStatus(ArchetypeStatus.INVALID);
doReturn(archetype).when(archetypeConfigStorage).loadArchetype(Mockito.<String>any());
doNothing().when(archetypeConfigStorage).saveArchetype(archetype);
service.validateAll();
verify(archetypePreferencesManager).enableArchetype(Mockito.<String>any(), eq(false), eq(true));
verify(archetypePreferencesManager).addArchetype(Mockito.<String>any());
verify(archetypeConfigStorage, times(2)).loadArchetype(Mockito.<String>any());
verify(archetypeConfigStorage).saveArchetype(any(Archetype.class));
}
use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype 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();
}
use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method createProjectFromBaseKieTemplateWithRemoteUrlTest.
@Test
public void createProjectFromBaseKieTemplateWithRemoteUrlTest() {
final String remoteRepositoryUrl = "myRemoteUrl";
final List<Contributor> spaceContributors = new ArrayList<>();
spaceContributors.add(new Contributor("user1", ContributorType.OWNER));
spaceContributors.add(new Contributor("user2", ContributorType.ADMIN));
spaceContributors.add(new Contributor("admin", ContributorType.CONTRIBUTOR));
final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
doReturn("ou").when(organizationalUnit).getName();
doReturn("org.ou").when(organizationalUnit).getDefaultGroupId();
doReturn(spaceContributors).when(organizationalUnit).getContributors();
doReturn(organizationalUnit).when(ouService).getOrganizationalUnit("ou");
final Repository kieBaseTemplate = mock(Repository.class);
doReturn(Optional.of(kieBaseTemplate)).when(archetypeService).getBaseKieTemplateRepository();
final Archetype baseKieArchetype = mock(Archetype.class);
doReturn(Optional.of(baseKieArchetype)).when(archetypeService).getBaseKieArchetype();
libraryService.createProject(organizationalUnit, remoteRepositoryUrl, "myRemoteRepository");
final List<Contributor> projectContributors = new ArrayList<>();
projectContributors.add(new Contributor("user1", ContributorType.OWNER));
projectContributors.add(new Contributor("user2", ContributorType.ADMIN));
projectContributors.add(new Contributor("admin", ContributorType.OWNER));
verify(archetypeService).getBaseKieArchetype();
verify(projectService).newProject(eq(organizationalUnit), any(POM.class), eq(DeploymentMode.VALIDATED), eq(projectContributors), eq(kieBaseTemplate), eq(remoteRepositoryUrl));
}
Aggregations