@Test public void testCheckBatch() { inboxBackend = new InboxBackendImpl( ioService, systemFS, userServicesBackend, mailboxService, securitySpy ); inboxBackend.recordOpeningEvent( new ResourceOpenedEvent( resourcePath, sessionInfo ) ); verify( ioService, times( 1 ) ).startBatch( mockedFSId ); verify( ioService, times( 1 ) ).endBatch(); inboxBackend.recordUserEditEvent( new ResourceUpdatedEvent( resourcePath, "message", sessionInfo ) ); verify( ioService, times( 2 ) ).startBatch( mockedFSId ); verify( ioService, times( 2 ) ).endBatch(); }
@Test public void releaseOwnedLockOnly() { lockManager.acquireLockOnDemand(); simulateLockFailure(); simulateLockDemand(); lockManager.onResourceUpdated(new ResourceUpdatedEvent(path, "", new SessionInfoImpl(user))); verify(lockService, never()).releaseLock(any(Path.class), any(ParameterizedCommand.class)); }
@Test public void testResourceUpdateEvent() { doReturn(createPath()).when(pathPlaceRequest).getPath(); observablePathImpl.onResourceUpdated(new ResourceUpdatedEvent(pathPlaceRequest.getPath(), MESSAGE, createSessionInfo())); verify(onUpdate).execute(any()); verify(observablePathImpl).executeConcurrentUpdateCommand(pathPlaceRequest.getPath(), RESOURCE_SESSION_ID, identityUser); }
@Test public void testResourceUpdateEvent() { doReturn(createPath()).when(pathPlaceRequest).getPath(); observablePathImpl.onResourceUpdated(new ResourceUpdatedEvent(pathPlaceRequest.getPath(), MESSAGE, createSessionInfo())); verify(onUpdate).execute(any()); verify(observablePathImpl).executeConcurrentUpdateCommand(pathPlaceRequest.getPath(), RESOURCE_SESSION_ID, identityUser); }
@Test public void releaseLockOnUpdate() { lockManager.acquireLockOnDemand(); simulateLockSuccess(); simulateLockDemand(); lockManager.onResourceUpdated(new ResourceUpdatedEvent(path, "", new SessionInfoImpl(user))); verify(lockService, times(1)).releaseLock(any(Path.class), any(ParameterizedCommand.class)); }
@Test public void releaseOwnedLockOnly() { lockManager.acquireLockOnDemand(); simulateLockFailure(); simulateLockDemand(); lockManager.onResourceUpdated(new ResourceUpdatedEvent(path, "", new SessionInfoImpl(user))); verify(lockService, never()).releaseLock(any(Path.class), any(ParameterizedCommand.class)); }
@Test public void releaseLockOnUpdate() { lockManager.acquireLockOnDemand(); simulateLockSuccess(); simulateLockDemand(); lockManager.onResourceUpdated(new ResourceUpdatedEvent(path, "", new SessionInfoImpl(user))); verify(lockService, times(1)).releaseLock(any(Path.class), any(ParameterizedCommand.class)); }
@Override public Path save( final Path path, final POM content, final Metadata metadata, final String comment ) { try { if ( metadata == null ) { ioService.write( paths.convert( path ), pomContentHandler.toString( content ), makeCommentedOption( comment ) ); } else { ioService.write( paths.convert( path ), pomContentHandler.toString( content ), metadataService.setUpAttributes( path, metadata ), makeCommentedOption( comment ) ); } //The pom.xml, kmodule.xml and project.imports are all saved from ProjectScreenPresenter //We only raise InvalidateDMOProjectCacheEvent and ResourceUpdatedEvent(pom.xml) events once //to avoid duplicating events (and re-construction of DMO). //Invalidate Project-level DMO cache as POM has changed. invalidateDMOProjectCache.fire( new InvalidateDMOProjectCacheEvent( path ) ); //Signal update to interested parties resourceUpdatedEvent.fire( new ResourceUpdatedEvent( path ) ); return path; } catch ( Exception e ) { throw ExceptionUtilities.handleException( e ); } }
@Test public void testRemoveModuleRepository() { final ResourceUpdatedEvent event = new ResourceUpdatedEvent(pomPath, "", sessionInfo); final Set<ModuleRepositories.ModuleRepository> repositories = new HashSet<ModuleRepositories.ModuleRepository>() {{ add(new ModuleRepositories.ModuleRepository(true, new MavenRepositoryMetadata("local-id", "local-url", MavenRepositorySource.LOCAL))); }}; final ModuleRepositories moduleRepositories = new ModuleRepositories(repositories); when(moduleRepositoriesService.load(moduleRepositoriesPath)).thenReturn(moduleRepositories); synchronizer.onResourceUpdated(event); final ArgumentCaptor<ModuleRepositories> moduleRepositoriesArgumentCaptor = ArgumentCaptor.forClass(ModuleRepositories.class); verify(moduleRepositoriesService, times(1)).save(eq(moduleRepositoriesPath), moduleRepositoriesArgumentCaptor.capture(), any(String.class)); final ModuleRepositories saved = moduleRepositoriesArgumentCaptor.getValue(); assertNotNull(saved); assertEquals(0, saved.getRepositories().size()); }
@Test public void testResourceUpdated() throws Exception { final Bean buildChangeListenerBean = (Bean) beanManager.getBeans( BuildChangeListener.class ).iterator().next(); final CreationalContext cc = beanManager.createCreationalContext( buildChangeListenerBean ); final BuildChangeListener buildChangeListener = (BuildChangeListener) beanManager.getReference( buildChangeListenerBean, BuildChangeListener.class, cc ); final URL resourceUrl = this.getClass().getResource( "/BuildChangeListenerRepo/src/main/resources/update.drl" ); final org.kie.commons.java.nio.file.Path nioResourcePath = fs.getPath( resourceUrl.toURI() ); final Path resourcePath = paths.convert( nioResourcePath ); final ResourceUpdatedEvent event = new ResourceUpdatedEvent( resourcePath ); buildChangeListener.updateResource( event ); final BuildResults buildResults = buildResultsObserver.getBuildResults(); assertNotNull( buildResults ); assertEquals( 0, buildResults.getMessages().size() ); final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults(); assertNotNull( incrementalBuildResults ); assertEquals( 0, incrementalBuildResults.getAddedMessages().size() ); assertEquals( 0, incrementalBuildResults.getRemovedMessages().size() ); }
@Test public void testAddModuleRepository() { final ResourceUpdatedEvent event = new ResourceUpdatedEvent(pomPath, "", sessionInfo);
@Test public void reloadEditorOnUpdateFromDifferentUser() { lockManager.onResourceUpdated(new ResourceUpdatedEvent(path, "", new SessionInfoImpl(user))); assertEquals(0, reloads); lockManager.onResourceUpdated(new ResourceUpdatedEvent(path, "", new SessionInfoImpl(new UserImpl("differentUser")))); assertEquals(1, reloads); }
@Test public void reloadEditorOnUpdateFromDifferentUser() { lockManager.onResourceUpdated(new ResourceUpdatedEvent(path, "", new SessionInfoImpl(user))); assertEquals(0, reloads); lockManager.onResourceUpdated(new ResourceUpdatedEvent(path, "", new SessionInfoImpl(new UserImpl("differentUser")))); assertEquals(1, reloads); }
if (event.kind().equals(StandardWatchEventKind.ENTRY_MODIFY)) { _affectedPath = convert(context.getOldPath()); result = (T) new ResourceUpdatedEvent(_affectedPath, context.getMessage(), sessionInfo(context));
@Test public void testAddAndRemoveModuleRepository() { final ResourceUpdatedEvent event = new ResourceUpdatedEvent(pomPath, "", sessionInfo);
private ResourceEvent toEvent(final Path path, final ResourceChange change, final WatchContext context) { if (change instanceof ResourceUpdated) { return new ResourceUpdatedEvent(path, context.getMessage(), sessionInfo(context)); } else if (change instanceof ResourceAdded) { return new ResourceAddedEvent(path, context.getMessage(), sessionInfo(context)); } else if (change instanceof ResourceRenamed) { return new ResourceRenamedEvent(path, ((ResourceRenamed) change).getDestinationPath(), context.getMessage(), sessionInfo(context)); } else if (change instanceof ResourceDeleted) { return new ResourceDeletedEvent(path, context.getMessage(), sessionInfo(context)); } return null; }