Search in sources :

Example 1 with ModuleClassLoaderHelper

use of org.kie.workbench.common.services.backend.project.ModuleClassLoaderHelper in project kie-wb-common by kiegroup.

the class FormGenerationIntegrationTest method init.

@Before
public void init() {
    formModelHandlerManager = new TestFormModelHandlerManager(moduleService, moduleClassLoaderHelper, fieldManager, finderService);
    when(pathModelReaderService.getModelReader(any())).thenReturn(new RuntimeDMOModelReader(moduleClassLoader, new RawMVELEvaluator()));
    when(formFinderService.findFormsForType(anyString(), any())).then((Answer<List<FormDefinition>>) invocationOnMock -> {
        String type = invocationOnMock.getArguments()[0].toString();
        return Collections.singletonList(readFormDefinitionForType(type));
    });
    service = new BPMNVFSFormDefinitionGeneratorService(fieldManager, pathModelReaderService, formModelHandlerManager, formFinderService, formSerializer, ioService, commentedOptionFactory, formModelSynchronizationUtil);
    when(moduleService.resolveModule(any())).thenReturn(module);
    when(moduleClassLoaderHelper.getModuleClassLoader(any())).thenReturn(moduleClassLoader);
    generator = new BPMNFormModelGeneratorImpl(moduleService, moduleClassLoaderHelper);
    final Path rootPathWithNestedForms = PathFactory.newPath(DATA_OBJECTS_FOLDER, getUriOfResource(PREPARED_NESTED_FORMS_FOLDER));
    ;
    processFormModel = generator.generateProcessFormModel(formGenerationProcessDefinitions, rootPathWithNestedForms);
    taskFormModels = generator.generateTaskFormModels(formGenerationProcessDefinitions, rootPathWithNestedForms);
}
Also used : ModelFinderService(org.kie.workbench.common.forms.data.modeller.service.shared.ModelFinderService) Arrays(java.util.Arrays) DocumentFieldType(org.kie.workbench.common.forms.jbpm.model.authoring.document.type.DocumentFieldType) ModuleClassLoaderHelper(org.kie.workbench.common.services.backend.project.ModuleClassLoaderHelper) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) FormModelerContent(org.kie.workbench.common.forms.editor.model.FormModelerContent) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) FormDefinitionSerializer(org.kie.workbench.common.forms.services.backend.serialization.FormDefinitionSerializer) StaticFormLayoutTemplateGenerator(org.kie.workbench.common.forms.commons.shared.layout.impl.StaticFormLayoutTemplateGenerator) PathFactory(org.uberfire.backend.vfs.PathFactory) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) FieldManager(org.kie.workbench.common.forms.service.shared.FieldManager) FormModelSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer) FieldSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FieldSerializer) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) ModuleFormFinderService(org.kie.workbench.common.forms.editor.service.shared.ModuleFormFinderService) SubFormFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.type.SubFormFieldType) KieModule(org.kie.workbench.common.services.shared.project.KieModule) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) BPMNFormModelGeneratorImpl(org.kie.workbench.common.forms.jbpm.server.service.impl.BPMNFormModelGeneratorImpl) Collectors(java.util.stream.Collectors) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Stream(java.util.stream.Stream) ModelReaderService(org.kie.workbench.common.forms.data.modeller.service.ext.ModelReaderService) FormModelPropertiesUtil(org.kie.workbench.common.forms.model.util.formModel.FormModelPropertiesUtil) FormModelSynchronizationUtilImpl(org.kie.workbench.common.forms.editor.service.shared.model.impl.FormModelSynchronizationUtilImpl) MultipleSubFormFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.type.MultipleSubFormFieldType) IntegerBoxFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.type.IntegerBoxFieldType) TestMetaDataEntryManager(org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) FormModelHandlerManager(org.kie.workbench.common.forms.editor.service.backend.FormModelHandlerManager) DatePickerFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.type.DatePickerFieldType) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Iterables(com.google.common.collect.Iterables) BeforeClass(org.junit.BeforeClass) FormGenerationTest_NestedObject(org.kie.workbench.common.forms.integration.tests.formgeneration.model.FormGenerationTest_NestedObject) DecimalBoxFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.type.DecimalBoxFieldType) BPMNVFSFormDefinitionGeneratorService(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.impl.authoring.BPMNVFSFormDefinitionGeneratorService) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) FormLayoutTemplateGenerator(org.kie.workbench.common.forms.commons.shared.layout.FormLayoutTemplateGenerator) AbstractJBPMFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.AbstractJBPMFormModel) TextBoxFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.type.TextBoxFieldType) FormEditorHelper(org.kie.workbench.common.forms.editor.client.editor.FormEditorHelper) TextAreaFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.type.TextAreaFieldType) Answer(org.mockito.stubbing.Answer) Charset(java.nio.charset.Charset) CommentedOptionFactory(org.guvnor.common.services.backend.util.CommentedOptionFactory) FormDefinitionSerializerImpl(org.kie.workbench.common.forms.services.backend.serialization.impl.FormDefinitionSerializerImpl) LayoutRow(org.uberfire.ext.layout.editor.api.editor.LayoutRow) FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) IOServiceDotFileImpl(org.uberfire.io.impl.IOServiceDotFileImpl) DocumentFieldProvider(org.kie.workbench.common.forms.jbpm.model.authoring.document.provider.DocumentFieldProvider) Path(org.uberfire.backend.vfs.Path) Definitions(org.eclipse.bpmn2.Definitions) Before(org.junit.Before) TestUtils(org.kie.workbench.common.forms.integration.tests.TestUtils) AbstractBPMNFormGeneratorService.generateNestedFormName(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.impl.AbstractBPMNFormGeneratorService.generateNestedFormName) CheckBoxFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.type.CheckBoxFieldType) FormModelSynchronizationUtil(org.kie.workbench.common.forms.editor.service.shared.model.FormModelSynchronizationUtil) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) IOException(java.io.IOException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) TestFormModelHandlerManager(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.test.TestFormModelHandlerManager) FormGenerationTest_DataObject(org.kie.workbench.common.forms.integration.tests.formgeneration.model.FormGenerationTest_DataObject) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) IOService(org.uberfire.io.IOService) DOCUMENT_TYPE(org.kie.workbench.common.forms.jbpm.model.authoring.document.type.DocumentFieldType.DOCUMENT_TYPE) SyncBeanManager(org.jboss.errai.ioc.client.container.SyncBeanManager) Collections(java.util.Collections) RuntimeDMOModelReader(org.kie.workbench.common.forms.data.modeller.service.impl.ext.dmo.runtime.RuntimeDMOModelReader) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Path(org.uberfire.backend.vfs.Path) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) TestFormModelHandlerManager(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.test.TestFormModelHandlerManager) List(java.util.List) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) BPMNFormModelGeneratorImpl(org.kie.workbench.common.forms.jbpm.server.service.impl.BPMNFormModelGeneratorImpl) RuntimeDMOModelReader(org.kie.workbench.common.forms.data.modeller.service.impl.ext.dmo.runtime.RuntimeDMOModelReader) BPMNVFSFormDefinitionGeneratorService(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.impl.authoring.BPMNVFSFormDefinitionGeneratorService) Before(org.junit.Before)

Example 2 with ModuleClassLoaderHelper

use of org.kie.workbench.common.services.backend.project.ModuleClassLoaderHelper 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 3 with ModuleClassLoaderHelper

use of org.kie.workbench.common.services.backend.project.ModuleClassLoaderHelper in project kie-wb-common by kiegroup.

the class TestAppSetup method classLoaderHelper.

@Produces
@Alternative
public ModuleClassLoaderHelper classLoaderHelper() {
    ModuleClassLoaderHelper classLoaderHelper = mock(ModuleClassLoaderHelper.class);
    when(classLoaderHelper.getModuleClassLoader(any())).thenReturn(this.getClass().getClassLoader());
    return classLoaderHelper;
}
Also used : ModuleClassLoaderHelper(org.kie.workbench.common.services.backend.project.ModuleClassLoaderHelper) Alternative(javax.enterprise.inject.Alternative) Produces(javax.enterprise.inject.Produces)

Aggregations

List (java.util.List)2 Before (org.junit.Before)2 Test (org.junit.Test)2 RunWith (org.junit.runner.RunWith)2 ModuleClassLoaderHelper (org.kie.workbench.common.services.backend.project.ModuleClassLoaderHelper)2 Iterables (com.google.common.collect.Iterables)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 Charset (java.nio.charset.Charset)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Alternative (javax.enterprise.inject.Alternative)1 Produces (javax.enterprise.inject.Produces)1 IOUtils (org.apache.commons.io.IOUtils)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Definitions (org.eclipse.bpmn2.Definitions)1 CommentedOptionFactory (org.guvnor.common.services.backend.util.CommentedOptionFactory)1