public void onRepositoryRemoved(final @Observes RepositoryRemovedEvent event) { aliasBranch.remove(event.getRepository().getAlias()); for (final GuvnorStructureContextChangeHandler handler : handlers.values()) { handler.onRepositoryDeleted(event.getRepository()); } }
@Override public void removeRepository(final Space space, final String alias) { final ConfigGroup thisRepositoryConfig = findRepositoryConfig(alias, space.getName()); try { configurationService.startBatch(); OrganizationalUnit orgUnit = Optional .ofNullable(organizationalUnitService.getOrganizationalUnit(space.getName())) .orElseThrow(() -> new IllegalArgumentException(String .format("The given space [%s] does not exist.", space.getName()))); doRemoveRepository(orgUnit, alias, thisRepositoryConfig, repo -> repositoryRemovedEvent.fire(new RepositoryRemovedEvent(repo))); } catch (final Exception e) { logger.error("Error during remove repository", e); throw new RuntimeException(e); } finally { configurationService.endBatch(); } }
@Test public void onClosedProjectDeleted() { doReturn(PlaceStatus.OPEN).when(placeManager).getStatus(anyString()); final Repository anotherRepository = mock(Repository.class); doReturn("anotherRepository").when(anotherRepository).getIdentifier(); libraryPlaces.onProjectDeleted(new RepositoryRemovedEvent(anotherRepository)); verify(projectContextChangeEvent, never()).fire(any()); verify(libraryPlaces, never()).closeAllPlaces(); verify(libraryPlaces, never()).goToLibrary(); verify(notificationEvent, never()).fire(any()); }
public void onRepositoryRemoved(final @Observes RepositoryRemovedEvent event) { aliasBranch.remove(event.getRepository().getAlias()); for (final GuvnorStructureContextChangeHandler handler : handlers.values()) { handler.onRepositoryDeleted(event.getRepository()); } }
@Test public void onOpenedProjectDeleted() { doReturn(PlaceStatus.OPEN).when(placeManager).getStatus(anyString()); libraryPlaces.onProjectDeleted(new RepositoryRemovedEvent(activeRepository)); final InOrder inOrder = inOrder(projectContextChangeEvent, libraryPlaces, notificationEvent); inOrder.verify(projectContextChangeEvent).fire(any()); inOrder.verify(libraryPlaces).closeAllPlaces(); inOrder.verify(libraryPlaces).goToLibrary(); inOrder.verify(notificationEvent).fire(any()); }
void onRepositoryRemoved(final @Observes RepositoryRemovedEvent event) { Optional.ofNullable(workbenchContext) .flatMap(context -> context.getActiveWorkspaceProject()) .filter(proj -> event.getRepository() != null && proj.getRepository().equals(event.getRepository())) .ifPresent(repo -> enableMenus(false)); }
repositoryRemovedEvent.fire(new RepositoryRemovedEvent(repo)); ioService.delete(convert(repo.getRoot()).getFileSystem().getPath(null));
public void onRepositoryRemoved(final @Observes RepositoryRemovedEvent event) { Optional.ofNullable(workbenchContext) .flatMap(context -> context.getActiveWorkspaceProject()) .filter(proj -> event.getRepository() != null && proj.getRepository().equals(event.getRepository())) .ifPresent(proj -> { for (MenuItem mi : menus.getItemsMap().values()) { mi.setEnabled(false); } }); }
@Test public void testHandler() throws Exception { final GuvnorStructureContextChangeHandler handler1 = mock(GuvnorStructureContextChangeHandler.class); final GuvnorStructureContextChangeHandler handler2 = mock(GuvnorStructureContextChangeHandler.class); final GuvnorStructureContextChangeHandler.HandlerRegistration handlerRegistration1 = context.addGuvnorStructureContextChangeHandler(handler1); final GuvnorStructureContextChangeHandler.HandlerRegistration handlerRegistration2 = context.addGuvnorStructureContextChangeHandler(handler2); assertNotNull(handlerRegistration1); assertNotNull(handlerRegistration2); context.removeHandler(handlerRegistration2); final GitRepository newRepository = new GitRepository(); context.onRepositoryRemoved(new RepositoryRemovedEvent(newRepository)); verify(handler1).onRepositoryDeleted(newRepository); verify(handler2, never()).onRepositoryDeleted(newRepository); }
public void onRepositoryRemovedEvent(@Observes RepositoryRemovedEvent event) { if (alias.equals(event.getRepository().getAlias())) { placeManager.closePlace(place); } } }
@Test public void testHandler() throws Exception { final GuvnorStructureContextChangeHandler handler1 = mock(GuvnorStructureContextChangeHandler.class); final GuvnorStructureContextChangeHandler handler2 = mock(GuvnorStructureContextChangeHandler.class); final GuvnorStructureContextChangeHandler.HandlerRegistration handlerRegistration1 = context.addGuvnorStructureContextChangeHandler(handler1); final GuvnorStructureContextChangeHandler.HandlerRegistration handlerRegistration2 = context.addGuvnorStructureContextChangeHandler(handler2); assertNotNull(handlerRegistration1); assertNotNull(handlerRegistration2); context.removeHandler(handlerRegistration2); final GitRepository newRepository = new GitRepository(); context.onRepositoryRemoved(new RepositoryRemovedEvent(newRepository)); verify(handler1).onRepositoryDeleted(newRepository); verify(handler2, never()).onRepositoryDeleted(newRepository); }
public void onRepositoryRemovedEvent(@Observes RepositoryRemovedEvent event) { if (alias.equals(event.getRepository().getAlias())) { placeManager.closePlace(place); } } }
@Test public void testRemoveRepository() throws Exception { context.onRepositoryRemoved(new RepositoryRemovedEvent(makeRepository("your-repo"))); assertNull(context.getCurrentBranch("your-repo")); }
public void onProjectDeleted(@Observes RepositoryRemovedEvent deletedEvent) { String target = ServiceTaskUtils.extractTargetInfo(deletedEvent.getRepository().getUri()); logger.debug("{} has been removed, removing any references to it on service tasks", target); services.stream() .filter(service -> service.getInstalledOn().contains(target)) .forEach(service -> { service.uninstall(target); logger.debug("Service {} uninstalled from deleted target {}", service.getName(), target); }); }
@Test public void testRemoveRepository() throws Exception { context.onRepositoryRemoved(new RepositoryRemovedEvent(makeRepository("your-repo"))); assertNull(context.getCurrentBranch("your-repo")); }
public void onProjectDeleted(@Observes RepositoryRemovedEvent deletedEvent) { String target = ServiceTaskUtils.extractTargetInfo(deletedEvent.getRepository().getUri()); logger.debug("{} has been removed, removing any references to it on service tasks", target); services.stream() .filter(service -> service.getInstalledOn().contains(target)) .forEach(service -> { service.uninstall(target); logger.debug("Service {} uninstalled from deleted target {}", service.getName(), target); }); }
private boolean isRepoForActiveProject(RepositoryRemovedEvent repositoryRemovedEvent) { return projectContext.getActiveWorkspaceProject() .filter(project -> { Repository activeRepo = project.getRepository(); Repository eventRepo = repositoryRemovedEvent.getRepository(); return activeRepo.getIdentifier().equals(eventRepo.getIdentifier()); }) .isPresent(); }
public void onRepositoryRemovedEvent(@Observes RepositoryRemovedEvent e) { projectContext.getActiveOrganizationalUnit().ifPresent(p -> { if (eventOnCurrentSpace(p, e.getRepository().getSpace())) { showProjects(); } }); }
public void onRepositoryRemovedEvent(@Observes RepositoryRemovedEvent e) { projectContext.getActiveOrganizationalUnit().ifPresent(p -> { if (eventOnCurrentSpace(p, e.getRepository().getSpace())) { refreshProjects(); } }); }
private RepositoryRemovedEvent createRepositoryRemovedEvent(String spaceName) { RepositoryRemovedEvent repositoryRemovedEvent = mock(RepositoryRemovedEvent.class); Repository repository = mock(Repository.class); when(repository.getSpace()).thenReturn(new Space(spaceName)); when(repositoryRemovedEvent.getRepository()).thenReturn(repository); return repositoryRemovedEvent; } }