Search in sources :

Example 1 with ResourceDeletedEvent

use of org.uberfire.workbench.events.ResourceDeletedEvent 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));
    verify(moduleFactory, times(1)).simpleModuleInstance(any(org.uberfire.java.nio.file.Path.class));
}
Also used : Path(org.uberfire.backend.vfs.Path) HashMap(java.util.HashMap) SessionInfo(org.uberfire.rpc.SessionInfo) URI(java.net.URI) ResourceDeletedEvent(org.uberfire.workbench.events.ResourceDeletedEvent) POM(org.guvnor.common.services.project.model.POM) FileSystemNotFoundException(org.uberfire.java.nio.file.FileSystemNotFoundException) DeleteModuleEvent(org.guvnor.common.services.project.events.DeleteModuleEvent) AbstractModuleService(org.guvnor.common.services.project.backend.server.AbstractModuleService) Test(org.junit.Test)

Aggregations

URI (java.net.URI)1 HashMap (java.util.HashMap)1 AbstractModuleService (org.guvnor.common.services.project.backend.server.AbstractModuleService)1 DeleteModuleEvent (org.guvnor.common.services.project.events.DeleteModuleEvent)1 POM (org.guvnor.common.services.project.model.POM)1 Test (org.junit.Test)1 Path (org.uberfire.backend.vfs.Path)1 FileSystemNotFoundException (org.uberfire.java.nio.file.FileSystemNotFoundException)1 SessionInfo (org.uberfire.rpc.SessionInfo)1 ResourceDeletedEvent (org.uberfire.workbench.events.ResourceDeletedEvent)1