use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype in project kie-wb-common by kiegroup.
the class ArchetypeServiceImplTest method listAllWithStatusTest.
@Test
public void listAllWithStatusTest() {
mockArchetypesOrgUnit();
final Archetype archetype1 = createArchetypeWithFields("findme", ArchetypeStatus.VALID);
final Archetype archetype2 = createArchetypeWithFields("hidden", ArchetypeStatus.INVALID);
final List<Archetype> archetypes = new ArrayList<>();
archetypes.addAll(Collections.nCopies(12, archetype1));
archetypes.addAll(Collections.nCopies(13, 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, "", 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 ArchetypeServiceImplTest method addWhenArchetypeAlreadyExistsTest.
@Test(expected = ArchetypeAlreadyExistsException.class)
public void addWhenArchetypeAlreadyExistsTest() {
final GAV gav = createGav();
mockArchetypesOrgUnit();
doReturn(Collections.nCopies(10, mock(Repository.class))).when(repositoryService).getAllRepositories(Mockito.<Space>any());
final Archetype archetype = createArchetype();
doReturn(archetype).when(archetypeConfigStorage).loadArchetype(Mockito.<String>any());
service.add(gav);
}
use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype in project kie-wb-common by kiegroup.
the class ArchetypeServiceImplTest method validateAllWhenManyAvailableTest.
@Test
public void validateAllWhenManyAvailableTest() throws MavenEmbedderException {
mockArchetypesOrgUnit();
doReturn(Collections.nCopies(10, mock(Repository.class))).when(repositoryService).getAllRepositories(Mockito.<Space>any());
doReturn(mock(Path.class)).when(service).unpackArchetype(Mockito.<Repository>any());
doNothing().when(service).executeMaven(Mockito.<BuildProjectCommand>any());
final Archetype archetype = createArchetypeWithStatus(ArchetypeStatus.VALID);
doReturn(archetype).when(archetypeConfigStorage).loadArchetype(Mockito.<String>any());
doNothing().when(archetypeConfigStorage).saveArchetype(archetype);
service.validateAll();
verify(archetypePreferencesManager, times(10)).enableArchetype(Mockito.<String>any(), eq(true), eq(false));
verify(archetypePreferencesManager, never()).setDefaultArchetype(Mockito.<String>any());
verify(archetypePreferencesManager, times(10)).addArchetype(Mockito.<String>any());
verify(archetypeConfigStorage, times(10)).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 validateSuccessTest.
@Test
public void validateSuccessTest() throws MavenEmbedderException {
mockArchetypesOrgUnit();
doReturn(mock(Repository.class)).when(repositoryService).getRepositoryFromSpace(Mockito.<Space>any(), eq(COMMON_ARCHETYPE_ALIAS));
doReturn(mock(Path.class)).when(service).unpackArchetype(Mockito.<Repository>any());
doNothing().when(service).executeMaven(Mockito.<BuildProjectCommand>any());
final Archetype archetype = createArchetypeWithStatus(ArchetypeStatus.VALID);
doReturn(archetype).when(archetypeConfigStorage).loadArchetype(Mockito.<String>any());
doNothing().when(archetypeConfigStorage).saveArchetype(archetype);
service.validate(COMMON_ARCHETYPE_ALIAS);
verify(archetypePreferencesManager).enableArchetype(Mockito.<String>any(), eq(true), eq(false));
verify(archetypePreferencesManager).addArchetype(Mockito.<String>any());
verify(archetypeConfigStorage).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 validateAllWhenOnlyOneAvailableTest.
@Test
public void validateAllWhenOnlyOneAvailableTest() 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());
doNothing().when(service).executeMaven(Mockito.<BuildProjectCommand>any());
final Archetype archetype = createArchetypeWithStatus(ArchetypeStatus.VALID);
doReturn(archetype).when(archetypeConfigStorage).loadArchetype(Mockito.<String>any());
doNothing().when(archetypeConfigStorage).saveArchetype(archetype);
service.validateAll();
verify(archetypePreferencesManager).enableArchetype(Mockito.<String>any(), eq(true), eq(true));
verify(archetypePreferencesManager).setDefaultArchetype(Mockito.<String>any());
verify(archetypePreferencesManager).addArchetype(Mockito.<String>any());
verify(archetypeConfigStorage).saveArchetype(any(Archetype.class));
}
Aggregations