Search in sources :

Example 6 with SimpleFileSystemProvider

use of org.uberfire.java.nio.fs.file.SimpleFileSystemProvider in project kie-wb-common by kiegroup.

the class JavaRoasterModelDriverTest method initTest.

@Before
public void initTest() throws Exception {
    simpleFileSystemProvider = new SimpleFileSystemProvider();
    simpleFileSystemProvider.forceAsDefault();
    rootPath = getRootPath();
}
Also used : SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) Before(org.junit.Before)

Example 7 with SimpleFileSystemProvider

use of org.uberfire.java.nio.fs.file.SimpleFileSystemProvider in project kie-wb-common by kiegroup.

the class ExplorerServiceHelperTest method setUp.

@Before
public void setUp() throws Exception {
    fileSystemProvider = new SimpleFileSystemProvider();
    // Ensure URLs use the default:// scheme
    fileSystemProvider.forceAsDefault();
    path = fileSystemProvider.getPath(this.getClass().getResource("myfile.file").toURI());
    when(srcPath.toURI()).thenReturn(path.toUri().toString());
    when(srcTestPath.toURI()).thenReturn(path.toUri().toString());
    when(srcResourcesPath.toURI()).thenReturn(path.toUri().toString());
    when(testResourcesPath.toURI()).thenReturn(path.toUri().toString());
    when(pkg.getPackageMainSrcPath()).thenReturn(srcPath);
    when(pkg.getPackageTestSrcPath()).thenReturn(srcTestPath);
    when(pkg.getPackageMainResourcesPath()).thenReturn(srcResourcesPath);
    when(pkg.getPackageTestResourcesPath()).thenReturn(testResourcesPath);
    when(metadataService.getTags(any(Path.class))).thenReturn(tags);
    when(ioService.newDirectoryStream(any(org.uberfire.java.nio.file.Path.class), any(LinkedFilter.class))).thenReturn(new DirectoryStreamMock() {

        private List<org.uberfire.java.nio.file.Path> items = new ArrayList<org.uberfire.java.nio.file.Path>() {

            {
                add(path);
            }
        };

        @Override
        public Iterator<org.uberfire.java.nio.file.Path> iterator() {
            return items.iterator();
        }
    });
    ExecutorService executorService = Executors.newCachedThreadPool(new DescriptiveThreadFactory());
    helper = spy(new ExplorerServiceHelper(moduleService, folderListingResolver, ioService, ioServiceConfig, lockService, metadataService, userServices, deleteService, renameService, copyService, executorService));
}
Also used : Path(org.uberfire.backend.vfs.Path) ArrayList(java.util.ArrayList) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) LinkedFilter(org.guvnor.common.services.backend.file.LinkedFilter) Iterator(java.util.Iterator) ExecutorService(java.util.concurrent.ExecutorService) DescriptiveThreadFactory(org.uberfire.commons.async.DescriptiveThreadFactory) Before(org.junit.Before)

Example 8 with SimpleFileSystemProvider

use of org.uberfire.java.nio.fs.file.SimpleFileSystemProvider in project kie-wb-common by kiegroup.

the class BPMNVFSFormDefinitionGeneratorServiceTest method setup.

@Before
public void setup() throws IOException {
    when(projectService.resolveModule(any())).thenReturn(module);
    when(projectClassLoaderHelper.getModuleClassLoader(module)).thenReturn(this.getClass().getClassLoader());
    source = mock(Path.class);
    simpleFileSystemProvider = new SimpleFileSystemProvider();
    simpleFileSystemProvider.forceAsDefault();
    when(source.toURI()).thenReturn("default:///src/main/resources/test.frm");
    when(commentedOptionFactory.makeCommentedOption(anyString())).then(invocationOnMock -> new CommentedOption("1", invocationOnMock.getArguments()[0].toString()));
    formModelHandlerManager = new TestFormModelHandlerManager(projectService, projectClassLoaderHelper, fieldManager, dataObjectFinderService);
    service = new BPMNVFSFormDefinitionGeneratorService(fieldManager, formModelHandlerManager, formFinderService, formSerializer, ioService, commentedOptionFactory, new FormModelSynchronizationUtilImpl(fieldManager, templateGenerator));
}
Also used : Path(org.uberfire.backend.vfs.Path) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) TestFormModelHandlerManager(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.test.TestFormModelHandlerManager) FormModelSynchronizationUtilImpl(org.kie.workbench.common.forms.editor.service.shared.model.impl.FormModelSynchronizationUtilImpl) Before(org.junit.Before)

Example 9 with SimpleFileSystemProvider

use of org.uberfire.java.nio.fs.file.SimpleFileSystemProvider in project kie-wb-common by kiegroup.

the class BPMFinderServiceImplTest method initialize.

@Before
public void initialize() throws URISyntaxException, ClassNotFoundException {
    when(ioService.newDirectoryStream(any(), any())).thenAnswer(invocationOnMock -> Files.newDirectoryStream((Path) invocationOnMock.getArguments()[0], (DirectoryStream.Filter<Path>) invocationOnMock.getArguments()[1]));
    when(ioService.newInputStream(any())).thenAnswer(invocationOnMock -> new FileInputStream(((Path) invocationOnMock.getArguments()[0]).toFile()));
    simpleFileSystemProvider = new SimpleFileSystemProvider();
    simpleFileSystemProvider.forceAsDefault();
    rootPath = simpleFileSystemProvider.getPath(this.getClass().getResource(RESOURCES_PATH).toURI());
    when(moduleService.resolveModule(any())).thenReturn(module);
    when(module.getRootPath()).thenReturn(Paths.convert(rootPath));
    when(classLoader.loadClass(any())).thenAnswer((Answer<Class>) invocation -> String.class);
    when(moduleClassLoaderHelper.getModuleClassLoader(any())).thenReturn(classLoader);
    bpmnFormModelGenerator = new BPMNFormModelGeneratorImpl(moduleService, moduleClassLoaderHelper);
    finderService = new BPMFinderServiceImpl(ioService, moduleService, bpmnFormModelGenerator);
    finderService.init();
}
Also used : Path(org.uberfire.java.nio.file.Path) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) ModuleClassLoaderHelper(org.kie.workbench.common.services.backend.project.ModuleClassLoaderHelper) Mock(org.mockito.Mock) Path(org.uberfire.java.nio.file.Path) Assert.assertNotNull(org.junit.Assert.assertNotNull) URISyntaxException(java.net.URISyntaxException) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) KieModule(org.kie.workbench.common.services.shared.project.KieModule) FileInputStream(java.io.FileInputStream) Mockito.when(org.mockito.Mockito.when) JBPMProcessModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMProcessModel) Files(org.uberfire.java.nio.file.Files) Paths(org.uberfire.backend.server.util.Paths) Matchers.any(org.mockito.Matchers.any) Answer(org.mockito.stubbing.Answer) List(java.util.List) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) IOService(org.uberfire.io.IOService) DirectoryStream(org.uberfire.java.nio.file.DirectoryStream) Assert.fail(org.junit.Assert.fail) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) FileInputStream(java.io.FileInputStream) Before(org.junit.Before)

Example 10 with SimpleFileSystemProvider

use of org.uberfire.java.nio.fs.file.SimpleFileSystemProvider in project kie-wb-common by kiegroup.

the class BuilderTest method testBuilderKModuleHasSnapshotDependency.

@Test
public void testBuilderKModuleHasSnapshotDependency() throws Exception {
    URL url = this.getClass().getResource("/GuvnorM2RepoDependencyExample2Snapshot");
    SimpleFileSystemProvider p = new SimpleFileSystemProvider();
    org.uberfire.java.nio.file.Path path = p.getPath(url.toURI());
    final Module module = moduleService.resolveModule(Paths.convert(path));
    final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue);
    final BuildResults results = builder.build();
    // Debug output
    if (!results.getMessages().isEmpty()) {
        for (BuildMessage m : results.getMessages()) {
            logger.debug(m.getText());
        }
    }
    assertTrue(results.getMessages().isEmpty());
}
Also used : SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) BuildMessage(org.guvnor.common.services.project.builder.model.BuildMessage) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) Module(org.guvnor.common.services.project.model.Module) URL(java.net.URL) Test(org.junit.Test)

Aggregations

SimpleFileSystemProvider (org.uberfire.java.nio.fs.file.SimpleFileSystemProvider)16 Before (org.junit.Before)9 Test (org.junit.Test)8 Module (org.guvnor.common.services.project.model.Module)7 URL (java.net.URL)6 Path (org.uberfire.backend.vfs.Path)5 BuildMessage (org.guvnor.common.services.project.builder.model.BuildMessage)4 BuildResults (org.guvnor.common.services.project.builder.model.BuildResults)4 Paths (org.uberfire.backend.server.util.Paths)3 CreationalContext (javax.enterprise.context.spi.CreationalContext)2 Bean (javax.enterprise.inject.spi.Bean)2 KieModuleService (org.kie.workbench.common.services.shared.project.KieModuleService)2 IOService (org.uberfire.io.IOService)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1