AbstractDeleteModuleObserverBridge { public void onBatchResourceChanges(final ResourceDeletedEvent event) { if (event.getPath().getFileName().equals("pom.xml")) { fireDeleteEvent(event.getPath()); } } AbstractDeleteModuleObserverBridge();  AbstractDeleteModuleObserverBridge(final IOService ioService,
                                              final Event<DeleteModuleEvent> deleteModuleEvent); void onBatchResourceChanges(final ResourceDeletedEvent event); void onBatchResourceChanges(final ResourceBatchChangesEvent resourceBatchChangesEvent);  }
@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: 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: 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 testResourceBatchChangesEventUpdatePomFile() { 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: when(ioService.get(any(URI.class))).thenReturn(nioPath); final Map<Path, Collection<ResourceChange>> batch = new HashMap<Path, Collection<ResourceChange>>() {{ put(path, new ArrayList<ResourceChange>() {{ add(new ResourceUpdated("")); }}); }}; bridge.onBatchResourceChanges(new ResourceBatchChangesEvent(batch, "message", sessionInfo)); verify(deleteModuleEvent, times(0)).fire(any(DeleteModuleEvent.class)); }
@Test public void testResourceBatchChangesEventUpdateNonPomFile() { 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: when(ioService.get(any(URI.class))).thenReturn(nioPath); final Map<Path, Collection<ResourceChange>> batch = new HashMap<Path, Collection<ResourceChange>>() {{ put(path, new ArrayList<ResourceChange>() {{ add(new ResourceUpdated("")); }}); }}; bridge.onBatchResourceChanges(new ResourceBatchChangesEvent(batch, "message", sessionInfo)); verify(deleteModuleEvent, times(0)).fire(any(DeleteModuleEvent.class)); }
@Test public void testResourceBatchChangesEventDeletePomFile() { 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: when(ioService.get(any(URI.class))).thenReturn(nioPath); final Map<Path, Collection<ResourceChange>> batch = new HashMap<Path, Collection<ResourceChange>>() {{ put(path, new ArrayList<ResourceChange>() {{ add(new ResourceDeleted("")); }}); }}; bridge.onBatchResourceChanges(new ResourceBatchChangesEvent(batch, "message", sessionInfo)); verify(deleteModuleEvent, times(1)).fire(any(DeleteModuleEvent.class)); }
@Test public void testResourceBatchChangesEventDeleteNonPomFile() { 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: when(ioService.get(any(URI.class))).thenReturn(nioPath); final Map<Path, Collection<ResourceChange>> batch = new HashMap<Path, Collection<ResourceChange>>() {{ put(path, new ArrayList<ResourceChange>() {{ add(new ResourceDeleted("")); }}); }}; bridge.onBatchResourceChanges(new ResourceBatchChangesEvent(batch, "message", sessionInfo)); verify(deleteModuleEvent, times(0)).fire(any(DeleteModuleEvent.class)); }