public void onBatchResourceChanges(final ResourceBatchChangesEvent resourceBatchChangesEvent) { for (final Map.Entry<org.uberfire.backend.vfs.Path, Collection<ResourceChange>> entry : resourceBatchChangesEvent.getBatch().entrySet()) { if (entry.getKey().getFileName().equals("pom.xml") && isDelete(entry.getValue())) { fireDeleteEvent(entry.getKey()); } } }
private void fireDeleteEvent(final org.uberfire.backend.vfs.Path _path) { final Path path = ioService.get(URI.create(_path.toURI())); final T project = getProject(path.getParent()); deleteProjectEvent.fire(new DeleteProjectEvent(project)); }
@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)); }
public void onBatchResourceChanges(final ResourceDeletedEvent event) { if (event.getPath().getFileName().equals("pom.xml")) { fireDeleteEvent(event.getPath()); } }
@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 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://project1/pom.xml"); 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(deleteProjectEvent, times(0)).fire(any(DeleteProjectEvent.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://project1/cheese.drl"); 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(deleteProjectEvent, times(0)).fire(any(DeleteProjectEvent.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://project1/pom.xml"); 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(deleteProjectEvent, times(1)).fire(any(DeleteProjectEvent.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://project1/cheese.drl"); 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(deleteProjectEvent, times(0)).fire(any(DeleteProjectEvent.class)); } }