Search in sources :

Example 6 with ArchetypeListUpdatedEvent

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

the class ArchetypeServiceImplTest method validateWhenExecuteMavenThrowsExceptionTest.

@Test
public void validateWhenExecuteMavenThrowsExceptionTest() 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());
    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.validate(COMMON_ARCHETYPE_ALIAS);
    verify(archetypePreferencesManager).enableArchetype(Mockito.<String>any(), eq(false), eq(true));
    verify(archetypePreferencesManager).addArchetype(Mockito.<String>any());
    verify(archetypeConfigStorage).loadArchetype(Mockito.<String>any());
    verify(archetypeConfigStorage).saveArchetype(any(Archetype.class));
    verify(archetypeListUpdatedEvent).fire(new ArchetypeListUpdatedEvent(ArchetypeListOperation.VALIDATE));
}
Also used : Path(org.uberfire.java.nio.file.Path) 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) ArchetypeListUpdatedEvent(org.kie.workbench.common.screens.archetype.mgmt.shared.events.ArchetypeListUpdatedEvent) Test(org.junit.Test)

Example 7 with ArchetypeListUpdatedEvent

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

the class ArchetypeServiceImplTest method deleteSuccessTest.

@Test
public void deleteSuccessTest() {
    mockArchetypesOrgUnit();
    service.delete(COMMON_ARCHETYPE_ALIAS);
    verify(repositoryService).removeRepository(Mockito.<Space>any(), eq(COMMON_ARCHETYPE_ALIAS));
    verify(archetypeConfigStorage).deleteArchetype(COMMON_ARCHETYPE_ALIAS);
    verify(archetypePreferencesManager).removeArchetype(COMMON_ARCHETYPE_ALIAS);
    verify(archetypeListUpdatedEvent).fire(new ArchetypeListUpdatedEvent(ArchetypeListOperation.DELETE));
}
Also used : ArchetypeListUpdatedEvent(org.kie.workbench.common.screens.archetype.mgmt.shared.events.ArchetypeListUpdatedEvent) Test(org.junit.Test)

Example 8 with ArchetypeListUpdatedEvent

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

the class ArchetypeServiceImpl method delete.

@Override
public void delete(final String alias) {
    checkNotEmpty(ALIAS_PARAM, alias);
    final OrganizationalUnit archetypesOU = resolveOU();
    if (archetypesOU != null) {
        repositoryService.removeRepository(archetypesOU.getSpace(), alias);
        archetypeConfigStorage.deleteArchetype(alias);
        archetypePreferencesManager.removeArchetype(alias);
        archetypeListUpdatedEvent.fire(new ArchetypeListUpdatedEvent(ArchetypeListOperation.DELETE));
        LOGGER.info("Archetype {} successfully deleted.", alias);
    } else {
        throw new IllegalStateException("Cannot delete an archetype when there is no archetype space available.");
    }
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ArchetypeListUpdatedEvent(org.kie.workbench.common.screens.archetype.mgmt.shared.events.ArchetypeListUpdatedEvent)

Example 9 with ArchetypeListUpdatedEvent

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

the class ArchetypeServiceImplTest method addSuccessTest.

@Test
public void addSuccessTest() throws MavenEmbedderException {
    doReturn(mock(KieModule.class)).when(moduleService).resolveModule(any());
    doNothing().when(service).executeMaven(any(AbstractMavenCommand.class));
    final Repository repository = mock(Repository.class);
    doReturn("myRepository").when(repository).getAlias();
    doReturn(repository).when(service).createArchetypeRepository(any(GAV.class), Mockito.<String>any());
    service.add(createGav());
    verify(archetypeConfigStorage).saveArchetype(any(Archetype.class));
    verify(archetypePreferencesManager).addArchetype(Mockito.<String>any());
    verify(archetypeListUpdatedEvent).fire(new ArchetypeListUpdatedEvent(ArchetypeListOperation.ADD));
}
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) ArchetypeListUpdatedEvent(org.kie.workbench.common.screens.archetype.mgmt.shared.events.ArchetypeListUpdatedEvent) AbstractMavenCommand(org.kie.workbench.common.screens.archetype.mgmt.backend.maven.AbstractMavenCommand) GAV(org.guvnor.common.services.project.model.GAV) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Test(org.junit.Test)

Example 10 with ArchetypeListUpdatedEvent

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

the class ArchetypesSectionPresenterTest method onArchetypeListUpdatedEventTest.

@Test
public void onArchetypeListUpdatedEventTest() {
    doReturn(true).when(archetypeTablePresenter).isSetup();
    final ArchetypeListUpdatedEvent event = mock(ArchetypeListUpdatedEvent.class);
    presenter.onArchetypeListUpdatedEvent(event);
    verify(settingsSectionChangeEvent).fire(any());
    verify(notificationEvent).fire(any());
}
Also used : ArchetypeListUpdatedEvent(org.kie.workbench.common.screens.archetype.mgmt.shared.events.ArchetypeListUpdatedEvent) Test(org.junit.Test)

Aggregations

ArchetypeListUpdatedEvent (org.kie.workbench.common.screens.archetype.mgmt.shared.events.ArchetypeListUpdatedEvent)11 Test (org.junit.Test)7 Repository (org.guvnor.structure.repositories.Repository)3 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)3 Archetype (org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype)3 File (java.io.File)1 GAV (org.guvnor.common.services.project.model.GAV)1 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)1 AbstractMavenCommand (org.kie.workbench.common.screens.archetype.mgmt.backend.maven.AbstractMavenCommand)1 KieModule (org.kie.workbench.common.services.shared.project.KieModule)1 Path (org.uberfire.java.nio.file.Path)1 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)1