Search in sources :

Example 1 with FormModelSerializer

use of org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer in project kie-wb-common by kiegroup.

the class FormGenerationIntegrationTest method setup.

@BeforeClass
public static void setup() {
    FormModelPropertiesUtil.registerBaseType(DOCUMENT_TYPE);
    FormModelPropertiesUtil.registerBaseType(DocumentFieldType.DOCUMENT_IMPL_TYPE);
    fieldManager = new TestFieldManager() {

        {
            registerFieldProvider(new DocumentFieldProvider() {

                {
                    doRegisterFields();
                }
            });
        }
    };
    formSerializer = new FormDefinitionSerializerImpl(new FieldSerializer(), new FormModelSerializer(), new TestMetaDataEntryManager());
    ioService = new IOServiceDotFileImpl();
    templateGenerator = new StaticFormLayoutTemplateGenerator();
    formModelSynchronizationUtil = new FormModelSynchronizationUtilImpl(fieldManager, templateGenerator);
    moduleClassLoader = FormGenerationIntegrationTest.class.getClassLoader();
    formGenerationProcessDefinitions = TestUtils.getDefinitionsFromResources(FormGenerationIntegrationTest.class, DEFINITION_PATH);
    formModelerContent = new FormModelerContent();
    formEditorHelper = new FormEditorHelper(fieldManager, null, mock(SyncBeanManager.class));
}
Also used : FieldSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FieldSerializer) IOServiceDotFileImpl(org.uberfire.io.impl.IOServiceDotFileImpl) StaticFormLayoutTemplateGenerator(org.kie.workbench.common.forms.commons.shared.layout.impl.StaticFormLayoutTemplateGenerator) DocumentFieldProvider(org.kie.workbench.common.forms.jbpm.model.authoring.document.provider.DocumentFieldProvider) FormDefinitionSerializerImpl(org.kie.workbench.common.forms.services.backend.serialization.impl.FormDefinitionSerializerImpl) FormModelerContent(org.kie.workbench.common.forms.editor.model.FormModelerContent) FormModelSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) FormEditorHelper(org.kie.workbench.common.forms.editor.client.editor.FormEditorHelper) TestMetaDataEntryManager(org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager) FormModelSynchronizationUtilImpl(org.kie.workbench.common.forms.editor.service.shared.model.impl.FormModelSynchronizationUtilImpl) BeforeClass(org.junit.BeforeClass)

Example 2 with FormModelSerializer

use of org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer 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(formsMigrationServicesCDIWrapper.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 3 with FormModelSerializer

use of org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer in project kie-wb-common by kiegroup.

the class FormDefinitionIndexerTest method setup.

@Override
public void setup() throws IOException {
    FormModelVisitor visitor = mock(FormModelVisitor.class);
    FormModelVisitorProvider provider = mock(FormModelVisitorProvider.class);
    when(provider.getModelType()).thenReturn(FormModel.class);
    when(provider.getVisitor()).thenReturn(visitor);
    Instance<FormModelVisitorProvider<?>> providersInstance = mock(Instance.class);
    List<FormModelVisitorProvider<?>> providers = Arrays.asList(provider);
    when(providersInstance.iterator()).thenReturn(providers.iterator());
    indexer = spy(new TestFormDefinitionIndexer(new FormResourceTypeDefinition(new Form()), new FormDefinitionSerializerImpl(new FieldSerializer(), new FormModelSerializer(), new TestMetaDataEntryManager()), providersInstance));
    when(indexer.getProviderForModel(any())).thenReturn(provider);
    super.setup();
}
Also used : FieldSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FieldSerializer) FormResourceTypeDefinition(org.kie.workbench.common.forms.editor.type.FormResourceTypeDefinition) Form(org.guvnor.common.services.project.categories.Form) 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)

Example 4 with FormModelSerializer

use of org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer in project kie-wb-common by kiegroup.

the class AbstractFormDefinitionHelperTest method init.

@Before
public void init() throws IOException {
    simpleFileSystemProvider = new SimpleFileSystemProvider();
    simpleFileSystemProvider.forceAsDefault();
    serializer = spy(new FormDefinitionSerializerImpl(new FieldSerializer(), new FormModelSerializer(), new TestMetaDataEntryManager()));
    when(originalPath.getFileName()).thenReturn(ORIGNAL_FORM_ASSET_NAME);
    when(destinationPath.getFileName()).thenReturn(DESTINATION_FORM_ASSET_NAME);
    when(destinationPath.toURI()).thenReturn(DESTINATION_FORM_PATH);
    when(ioService.readAllString(any())).thenReturn(IOUtils.toString(new InputStreamReader(this.getClass().getResourceAsStream(ORIGINAL_FORM_PATH))));
    doAnswer((Answer<FormDefinition>) invocationOnMock -> {
        FormDefinition formDefinition = (FormDefinition) invocationOnMock.callRealMethod();
        beforeProcess(formDefinition);
        return formDefinition;
    }).when(serializer).deserialize(Mockito.<String>any());
    helper = getHelper(ioService, serializer, commentedOptionFactory);
}
Also used : SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mock(org.mockito.Mock) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) FormDefinitionSerializer(org.kie.workbench.common.forms.services.backend.serialization.FormDefinitionSerializer) Mockito.spy(org.mockito.Mockito.spy) Answer(org.mockito.stubbing.Answer) CommentedOptionFactory(org.guvnor.common.services.backend.util.CommentedOptionFactory) FormDefinitionSerializerImpl(org.kie.workbench.common.forms.services.backend.serialization.impl.FormDefinitionSerializerImpl) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Assertions(org.assertj.core.api.Assertions) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) FormModelSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer) FieldSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FieldSerializer) Path(org.uberfire.backend.vfs.Path) Before(org.junit.Before) IOException(java.io.IOException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) InputStreamReader(java.io.InputStreamReader) Mockito.verify(org.mockito.Mockito.verify) IOUtils(org.apache.commons.io.IOUtils) Mockito(org.mockito.Mockito) FormResourceTypeDefinition(org.kie.workbench.common.forms.editor.type.FormResourceTypeDefinition) IOService(org.uberfire.io.IOService) TestMetaDataEntryManager(org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager) Mockito.mock(org.mockito.Mockito.mock) FieldSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FieldSerializer) InputStreamReader(java.io.InputStreamReader) FormDefinitionSerializerImpl(org.kie.workbench.common.forms.services.backend.serialization.impl.FormDefinitionSerializerImpl) FormModelSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TestMetaDataEntryManager(org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager) Before(org.junit.Before)

Example 5 with FormModelSerializer

use of org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer in project kie-wb-common by kiegroup.

the class FormEditorServiceImplTest method init.

@Before
public void init() {
    Instance<FormModelHandler<? extends FormModel>> instances = mock(Instance.class);
    when(dataObjectFormModelHandler.getModelType()).thenReturn(DataObjectFormModel.class);
    when(dataObjectFormModelHandler.newInstance()).thenReturn(dataObjectFormModelHandler);
    List<FormModelHandler> handlers = Arrays.asList(dataObjectFormModelHandler);
    when(instances.iterator()).then(invocationOnMock -> handlers.iterator());
    modelHandlerManager = spy(new FormModelHandlerManagerImpl(instances));
    formDefinitionSerializer = spy(new FormDefinitionSerializerImpl(new FieldSerializer(), new FormModelSerializer(), new TestMetaDataEntryManager()));
    formEditorService = spy(new FormEditorServiceImpl(ioService, sessionInfo, resourceOpenedEvent, fieldManager, modelHandlerManager, moduleService, formDefinitionSerializer, moduleFormFinderService, deleteService, commentedOptionFactory, renameService, copyService));
    when(path.toURI()).thenReturn("file:///src/main/resources/test.frm");
    when(moduleService.resolveModule(any())).thenReturn(module);
}
Also used : FieldSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FieldSerializer) DataObjectFormModel(org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel) FormModel(org.kie.workbench.common.forms.model.FormModel) FormDefinitionSerializerImpl(org.kie.workbench.common.forms.services.backend.serialization.impl.FormDefinitionSerializerImpl) FormModelSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer) FormModelHandler(org.kie.workbench.common.forms.editor.service.backend.FormModelHandler) TestMetaDataEntryManager(org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager) Before(org.junit.Before)

Aggregations

TestMetaDataEntryManager (org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager)5 FieldSerializer (org.kie.workbench.common.forms.services.backend.serialization.impl.FieldSerializer)5 FormDefinitionSerializerImpl (org.kie.workbench.common.forms.services.backend.serialization.impl.FormDefinitionSerializerImpl)5 FormModelSerializer (org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer)5 Before (org.junit.Before)3 FormResourceTypeDefinition (org.kie.workbench.common.forms.editor.type.FormResourceTypeDefinition)2 SimpleFileSystemProvider (org.uberfire.java.nio.fs.file.SimpleFileSystemProvider)2 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 IOUtils (org.apache.commons.io.IOUtils)1 Assertions (org.assertj.core.api.Assertions)1 CommentedOptionFactory (org.guvnor.common.services.backend.util.CommentedOptionFactory)1 Form (org.guvnor.common.services.project.categories.Form)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1 StaticFormLayoutTemplateGenerator (org.kie.workbench.common.forms.commons.shared.layout.impl.StaticFormLayoutTemplateGenerator)1 DataObjectFormModel (org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel)1 FormEditorHelper (org.kie.workbench.common.forms.editor.client.editor.FormEditorHelper)1 FormModelerContent (org.kie.workbench.common.forms.editor.model.FormModelerContent)1 FormModelHandler (org.kie.workbench.common.forms.editor.service.backend.FormModelHandler)1