Search in sources :

Example 1 with SimpleFileSystemProvider

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

the class AbstractFormDefinitionGeneratorTest method init.

@Before
public void init() throws Exception {
    formDefinitionSerializer = new FormDefinitionSerializerImpl(new FieldSerializer(), new FormModelSerializer(), new TestMetaDataEntryManager());
    when(migrationServicesCDIWrapper.getIOService()).thenReturn(ioService);
    when(migrationServicesCDIWrapper.getFormDefinitionSerializer()).thenReturn(formDefinitionSerializer);
    simpleFileSystemProvider = new SimpleFileSystemProvider();
    simpleFileSystemProvider.forceAsDefault();
    when(path.toURI()).thenReturn(ROOT_PATH);
    when(workspaceProject.getRootPath()).thenReturn(path);
    generator = new FormDefinitionGenerator(DataObjectFormAdapter::new, this::getBPMNAdapter);
    doInit();
}
Also used : SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) FieldSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FieldSerializer) FormDefinitionSerializerImpl(org.kie.workbench.common.forms.services.backend.serialization.impl.FormDefinitionSerializerImpl) FormModelSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer) TestMetaDataEntryManager(org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager) Before(org.junit.Before)

Example 2 with SimpleFileSystemProvider

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

the class FormDefinitionGeneratorImplTest method init.

@Before
public void init() throws Exception {
    SimpleFileSystemProvider simpleFileSystemProvider = new SimpleFileSystemProvider();
    simpleFileSystemProvider.forceAsDefault();
    Definitions processDefinitions = BPMN2Utils.getDefinitions(FormDefinitionGeneratorImplTest.class.getResourceAsStream(PROCESS_PATH));
    // Prepare BPMNFormModelGenerator
    when(kieModuleService.resolveModule(any())).thenReturn(module);
    when(module.getRootPath()).thenReturn(path);
    when(moduleClassLoaderHelper.getModuleClassLoader(module)).thenReturn(moduleClassLoader);
    when(moduleClassLoader.loadClass(anyString())).thenAnswer(invocation -> Object.class);
    BPMNFormModelGenerator bpmnFormModelGenerator = spy(new BPMNFormModelGeneratorImpl(kieModuleService, moduleClassLoaderHelper));
    FormModelHandlerManager formModelHandlerManager = new TestFormModelHandlerManager(kieModuleService, moduleClassLoaderHelper, new TestFieldManager());
    BPMNFormGeneratorService<Path> bpmnFormGeneratorService = new BPMNVFSFormDefinitionGeneratorService(new TestFieldManager(), formModelHandlerManager, formFinderService, formDefinitionSerializer, ioService, commentedOptionFactory, synchronizationUtil);
    generator = spy(new TestFormDefinitionGeneratorImpl(formGenerationModelProviders, ioService, bpmnFormModelGenerator, formDefinitionSerializer, bpmnFormGeneratorService, processDefinitions));
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getPath()).thenReturn(diagramPath);
    when(diagram.getGraph()).thenReturn(graph);
    when(diagramPath.toURI()).thenReturn("default:///src/main/resources" + PROCESS_PATH);
}
Also used : SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) Path(org.uberfire.backend.vfs.Path) FormModelHandlerManager(org.kie.workbench.common.forms.editor.service.backend.FormModelHandlerManager) Definitions(org.eclipse.bpmn2.Definitions) BPMNFormModelGenerator(org.kie.workbench.common.forms.jbpm.server.service.BPMNFormModelGenerator) BPMNFormModelGeneratorImpl(org.kie.workbench.common.forms.jbpm.server.service.impl.BPMNFormModelGeneratorImpl) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) BPMNVFSFormDefinitionGeneratorService(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.impl.authoring.BPMNVFSFormDefinitionGeneratorService) Before(org.junit.Before)

Example 3 with SimpleFileSystemProvider

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

the class BuilderTest method testBuilderSimpleKModule.

@Test
public void testBuilderSimpleKModule() throws Exception {
    LRUPomModelCache pomModelCache = getReference(LRUPomModelCache.class);
    URL url = this.getClass().getResource("/GuvnorM2RepoDependencyExample1");
    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);
    assertNotNull(builder.getKieContainer());
}
Also used : SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) Module(org.guvnor.common.services.project.model.Module) URL(java.net.URL) Test(org.junit.Test)

Example 4 with SimpleFileSystemProvider

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

the class BuilderTest method testBuilderKieContainerInstantiation.

@Test
public void testBuilderKieContainerInstantiation() throws Exception {
    final URL url = this.getClass().getResource("/GuvnorM2RepoDependencyExample1");
    final SimpleFileSystemProvider p = new SimpleFileSystemProvider();
    final org.uberfire.java.nio.file.Path path = p.getPath(url.toURI());
    final Module module = moduleService.resolveModule(Paths.convert(path));
    // Build Module, including Rules and Global definition
    final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue);
    assertNotNull(builder.getKieContainer());
    // Validate Rule excluding Global definition
    final URL urlToValidate = this.getClass().getResource("/GuvnorM2RepoDependencyExample1/src/main/resources/rule2.drl");
    final org.uberfire.java.nio.file.Path pathToValidate = p.getPath(urlToValidate.toURI());
    final List<ValidationMessage> validationMessages = validator.validate(Paths.convert(pathToValidate), Resources.toString(urlToValidate, Charset.forName("UTF-8")));
    assertNotNull(validationMessages);
    assertEquals(0, validationMessages.size());
    // Retrieve a KieSession for the Module and set the Global. This should not fail as the
    // KieContainer is retrieved direct from the KieBuilder and not KieRepository (as was the
    // case before BZ1202551 was fixed.
    final KieContainer kieContainer1 = builder.getKieContainer();
    final KieSession kieSession1 = kieContainer1.newKieSession();
    kieSession1.setGlobal("list", new ArrayList<String>());
}
Also used : ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) URL(java.net.URL) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) KieSession(org.kie.api.runtime.KieSession) Module(org.guvnor.common.services.project.model.Module) KieContainer(org.kie.api.runtime.KieContainer) Test(org.junit.Test)

Example 5 with SimpleFileSystemProvider

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

the class BuilderTest method testBuilderFixForBrokenKModule.

@Test
public void testBuilderFixForBrokenKModule() throws Exception {
    LRUPomModelCache pomModelCache = getReference(LRUPomModelCache.class);
    SimpleFileSystemProvider provider = new SimpleFileSystemProvider();
    org.uberfire.java.nio.file.Path path = provider.getPath(this.getClass().getResource("/BuilderExampleBrokenSyntax").toURI());
    final Module module = moduleService.resolveModule(Paths.convert(path));
    final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, mock(PackageNameWhiteListService.class), alwaysTrue);
    assertNull(builder.getKieContainer());
    builder.deleteResource(provider.getPath(this.getClass().getResource(File.separatorChar + "BuilderExampleBrokenSyntax" + File.separatorChar + "src" + File.separatorChar + "main" + File.separatorChar + "resources" + File.separatorChar + "rule1.drl").toURI()));
    assertNotNull(builder.getKieContainer());
}
Also used : SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) PackageNameWhiteListService(org.kie.workbench.common.services.shared.whitelist.PackageNameWhiteListService) Module(org.guvnor.common.services.project.model.Module) 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