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));
}
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));
}
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.");
}
}
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));
}
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());
}
Aggregations