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();
}
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);
}
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());
}
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>());
}
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());
}
Aggregations