use of org.uberfire.java.nio.file.FileSystemNotFoundException in project kie-wb-common by kiegroup.
the class ModuleServiceImplNewModuleTest method testDeleteModuleObserverBridge.
@Test
public void testDeleteModuleObserverBridge() throws URISyntaxException {
final URI fs = new URI("git://test");
try {
FileSystems.getFileSystem(fs);
} catch (FileSystemNotFoundException e) {
FileSystems.newFileSystem(fs, new HashMap<String, Object>());
}
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("git://test/p0/pom.xml");
when(nioPath.getParent()).thenReturn(nioPath);
when(nioPath.resolve(any(String.class))).thenReturn(nioPath);
when(nioPath.toUri()).thenReturn(URI.create("git://test/p0/pom.xml"));
when(nioPath.getFileSystem()).thenReturn(FileSystems.getFileSystem(fs));
when(ioService.get(any(URI.class))).thenReturn(nioPath);
final SessionInfo sessionInfo = mock(SessionInfo.class);
final Event<DeleteModuleEvent> deleteModuleEvent = mock(Event.class);
final AbstractModuleService moduleServiceSpy = spy(moduleService);
final DeleteKieModuleObserverBridge bridge = new DeleteKieModuleObserverBridge(ioService, deleteModuleEvent, moduleFactory);
bridge.onBatchResourceChanges(new ResourceDeletedEvent(path, "message", sessionInfo));
verify(deleteModuleEvent, times(1)).fire(any(DeleteModuleEvent.class));
verify(moduleServiceSpy, times(0)).newModule(any(Path.class), any(POM.class), any(String.class));
verify(moduleFactory, times(1)).simpleModuleInstance(any(org.uberfire.java.nio.file.Path.class));
}
Aggregations