@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()); }
@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()); }
repositoryRemovedEvent.fire(new RepositoryRemovedEvent(repo)); ioService.delete(convert(repo.getRoot()).getFileSystem().getPath(null));
@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); }
@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); }
@Test public void testRemoveRepository() throws Exception { context.onRepositoryRemoved(new RepositoryRemovedEvent(makeRepository("your-repo"))); assertNull(context.getCurrentBranch("your-repo")); }
@Test public void testRemoveRepository() throws Exception { context.onRepositoryRemoved(new RepositoryRemovedEvent(makeRepository("your-repo"))); assertNull(context.getCurrentBranch("your-repo")); }