Search in sources :

Example 1 with TestMetaDataEntryManager

use of org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager 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 TestMetaDataEntryManager

use of org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager in project kie-wb-common by kiegroup.

the class FormGenerationIntegrationTest method setup.

@BeforeClass
public static void setup() throws ClassNotFoundException {
    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);
}
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 3 with TestMetaDataEntryManager

use of org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager 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 TestMetaDataEntryManager

use of org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager in project kie-wb-common by kiegroup.

the class FormDefinitionSerializerImplTest method initTest.

@Before
public void initTest() {
    fieldManager = new TestFieldManager();
    definitionSerializer = new FormDefinitionSerializerImpl(new FieldSerializer(), new FormModelSerializer(), new TestMetaDataEntryManager());
    JavaFormModel model = new PortableJavaModel("org.test.MyParentModel");
    formDefinition = new FormDefinition(model);
    formDefinition.setId("testForm");
    formDefinition.setName("testForm");
    formDefinition.setLayoutTemplate(new LayoutTemplate());
    for (BasicTypeFieldProvider provider : fieldManager.getAllBasicTypeProviders()) {
        for (String type : provider.getSupportedTypes()) {
            FieldDefinition field = provider.getFieldByType(new TypeInfoImpl(type));
            assertNotNull(field);
            String fieldDescription = provider.getFieldTypeName() + "_" + type;
            field.setName(fieldDescription);
            field.setLabel(fieldDescription);
            field.setStandaloneClassName(type);
            field.setBinding(fieldDescription);
            model.getProperties().add(new ModelPropertyImpl(fieldDescription, new TypeInfoImpl(type)));
            formDefinition.getFields().add(field);
        }
    }
    SubFormFieldDefinition subForm = new SubFormFieldDefinition();
    subForm.setLabel("SubForm");
    subForm.setNestedForm("");
    subForm.setBinding("model");
    subForm.setStandaloneClassName("org.test.MyTestModel");
    subForm.setBinding("SubForm");
    formDefinition.getFields().add(subForm);
    model.getProperties().add(new ModelPropertyImpl(subForm.getBinding(), new TypeInfoImpl(TypeKind.OBJECT, subForm.getStandaloneClassName(), false)));
    MultipleSubFormFieldDefinition multipleSubForm = new MultipleSubFormFieldDefinition();
    multipleSubForm.setLabel("MultipleSubForm");
    multipleSubForm.setCreationForm("");
    multipleSubForm.setEditionForm("");
    multipleSubForm.setStandaloneClassName("org.test.MyTestModel");
    multipleSubForm.setBinding("MultipleSubForm");
    formDefinition.getFields().add(multipleSubForm);
    model.getProperties().add(new ModelPropertyImpl(multipleSubForm.getBinding(), new TypeInfoImpl(TypeKind.OBJECT, multipleSubForm.getStandaloneClassName(), true)));
    EnumListBoxFieldDefinition enumListBox = new EnumListBoxFieldDefinition();
    enumListBox.setLabel("EnumListBox");
    enumListBox.setBinding("EnumListBox");
    enumListBox.setStandaloneClassName("org.test.MyTestModel");
    formDefinition.getFields().add(enumListBox);
    model.getProperties().add(new ModelPropertyImpl(enumListBox.getBinding(), new TypeInfoImpl(TypeKind.ENUM, enumListBox.getStandaloneClassName(), false)));
}
Also used : LayoutTemplate(org.uberfire.ext.layout.editor.api.editor.LayoutTemplate) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) EnumListBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TestMetaDataEntryManager(org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) EnumListBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) PortableJavaModel(org.kie.workbench.common.forms.model.impl.PortableJavaModel) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) JavaFormModel(org.kie.workbench.common.forms.model.JavaFormModel) BasicTypeFieldProvider(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider) Before(org.junit.Before)

Aggregations

TestMetaDataEntryManager (org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager)4 FieldSerializer (org.kie.workbench.common.forms.services.backend.serialization.impl.FieldSerializer)3 FormDefinitionSerializerImpl (org.kie.workbench.common.forms.services.backend.serialization.impl.FormDefinitionSerializerImpl)3 FormModelSerializer (org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer)3 Before (org.junit.Before)2 TestFieldManager (org.kie.workbench.common.forms.fields.test.TestFieldManager)2 Form (org.guvnor.common.services.project.categories.Form)1 BeforeClass (org.junit.BeforeClass)1 StaticFormLayoutTemplateGenerator (org.kie.workbench.common.forms.commons.shared.layout.impl.StaticFormLayoutTemplateGenerator)1 FormEditorHelper (org.kie.workbench.common.forms.editor.client.editor.FormEditorHelper)1 FormModelerContent (org.kie.workbench.common.forms.editor.model.FormModelerContent)1 FormModelSynchronizationUtilImpl (org.kie.workbench.common.forms.editor.service.shared.model.impl.FormModelSynchronizationUtilImpl)1 FormResourceTypeDefinition (org.kie.workbench.common.forms.editor.type.FormResourceTypeDefinition)1 BasicTypeFieldProvider (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider)1 EnumListBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition)1 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)1 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)1 DocumentFieldProvider (org.kie.workbench.common.forms.jbpm.model.authoring.document.provider.DocumentFieldProvider)1 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)1 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)1