@Test public void testResourceDeletedEventPomFile() { final Path path = mock(Path.class); final org.uberfire.java.nio.file.Path nioPath = mock(org.uberfire.java.nio.file.Path.class); when(path.getFileName()).thenReturn("pom.xml"); when(path.toURI()).thenReturn("file://project1/pom.xml"); when(ioService.get(any(URI.class))).thenReturn(nioPath); bridge.onBatchResourceChanges(new ResourceDeletedEvent(path, "message", sessionInfo)); verify(deleteProjectEvent, times(1)).fire(any(DeleteProjectEvent.class)); }
@Test public void testResourceDeletedEventPomFile() { final Path path = mock(Path.class); final org.uberfire.java.nio.file.Path nioPath = mock(org.uberfire.java.nio.file.Path.class); when(path.getFileName()).thenReturn("pom.xml"); when(path.toURI()).thenReturn("file://module1/pom.xml"); when(ioService.get(any(URI.class))).thenReturn(nioPath); bridge.onBatchResourceChanges(new ResourceDeletedEvent(path, "message", sessionInfo)); verify(deleteModuleEvent, times(1)).fire(any(DeleteModuleEvent.class)); }
@Test public void testResourceDeletedEventNonPomFile() { final Path path = mock(Path.class); final org.uberfire.java.nio.file.Path nioPath = mock(org.uberfire.java.nio.file.Path.class); when(path.getFileName()).thenReturn("cheese.drl"); when(path.toURI()).thenReturn("file://module1/cheese.drl"); when(ioService.get(any(URI.class))).thenReturn(nioPath); bridge.onBatchResourceChanges(new ResourceDeletedEvent(path, "message", sessionInfo)); verify(deleteModuleEvent, times(0)).fire(any(DeleteModuleEvent.class)); }
@Test public void testResourceDeletedEventPomFile() { final Path path = mock(Path.class); final org.uberfire.java.nio.file.Path nioPath = mock(org.uberfire.java.nio.file.Path.class); when(path.getFileName()).thenReturn("pom.xml"); when(path.toURI()).thenReturn("file://module1/pom.xml"); when(ioService.get(any(URI.class))).thenReturn(nioPath); bridge.onBatchResourceChanges(new ResourceDeletedEvent(path, "message", sessionInfo)); verify(deleteModuleEvent, times(1)).fire(any(DeleteModuleEvent.class)); }
@Test public void testResourceDeletedEventNonPomFile() { final Path path = mock(Path.class); final org.uberfire.java.nio.file.Path nioPath = mock(org.uberfire.java.nio.file.Path.class); when(path.getFileName()).thenReturn("cheese.drl"); when(path.toURI()).thenReturn("file://project1/cheese.drl"); when(ioService.get(any(URI.class))).thenReturn(nioPath); bridge.onBatchResourceChanges(new ResourceDeletedEvent(path, "message", sessionInfo)); verify(deleteProjectEvent, times(0)).fire(any(DeleteProjectEvent.class)); }
@Test public void testResourceDeletedEventNonPomFile() { final Path path = mock(Path.class); final org.uberfire.java.nio.file.Path nioPath = mock(org.uberfire.java.nio.file.Path.class); when(path.getFileName()).thenReturn("cheese.drl"); when(path.toURI()).thenReturn("file://module1/cheese.drl"); when(ioService.get(any(URI.class))).thenReturn(nioPath); bridge.onBatchResourceChanges(new ResourceDeletedEvent(path, "message", sessionInfo)); verify(deleteModuleEvent, times(0)).fire(any(DeleteModuleEvent.class)); }
@Test public void testResourceDeleteEvent() { doReturn(createPath()).when(pathPlaceRequest).getPath(); observablePathImpl.onResourceDeleted(new ResourceDeletedEvent(pathPlaceRequest.getPath(), MESSAGE, createSessionInfo())); verify(onDelete).execute(any()); verify(observablePathImpl).executeConcurrentDeleteCommand(pathPlaceRequest.getPath(), RESOURCE_SESSION_ID, identityUser); }
@Test public void testResourceDeleteEvent() { doReturn(createPath()).when(pathPlaceRequest).getPath(); observablePathImpl.onResourceDeleted(new ResourceDeletedEvent(pathPlaceRequest.getPath(), MESSAGE, createSessionInfo())); verify(onDelete).execute(any()); verify(observablePathImpl).executeConcurrentDeleteCommand(pathPlaceRequest.getPath(), RESOURCE_SESSION_ID, identityUser); }
moduleFactory); bridge.onBatchResourceChanges(new ResourceDeletedEvent(path, "message", sessionInfo));
@Test public void testResourceDeleted() 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/delete.drl" ); final org.kie.commons.java.nio.file.Path nioResourcePath = fs.getPath( resourceUrl.toURI() ); final Path resourcePath = paths.convert( nioResourcePath ); final ResourceDeletedEvent event = new ResourceDeletedEvent( resourcePath ); buildChangeListener.deleteResource( 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() ); }
} else if (event.kind().equals(StandardWatchEventKind.ENTRY_DELETE)) { _affectedPath = convert(context.getOldPath()); result = (T) new ResourceDeletedEvent(_affectedPath, context.getMessage(), sessionInfo(context));
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; }