use of org.kie.workbench.common.forms.editor.model.FormModelerContent in project kie-wb-common by kiegroup.
the class FormEditorHelperTest method loadContent.
private void loadContent() {
testFieldManager = spy(new TestFieldManager());
when(editorFieldLayoutComponents.get()).thenAnswer(invocationOnMock -> {
final EditorFieldLayoutComponent mocked = mock(EditorFieldLayoutComponent.class);
return mocked;
});
when(formEditorService.loadContent(any())).then(invocation -> {
FormDefinition form = new FormDefinition();
form.setName("EmployeeTestForm");
form.setId("_random_id");
content = new FormModelerContent();
PortableJavaModel model = new PortableJavaModel("com.test.Employee");
model.getProperties().addAll(modelProperties);
form.setModel(model);
content.setDefinition(form);
content.setOverview(new Overview());
return content;
});
when(testFieldManager.getBaseFieldTypes()).thenAnswer(invocationOnMock -> {
List<String> baseFields = new ArrayList<>();
baseFields.add("TextBox");
baseFields.add("CheckBox");
return baseFields;
});
editorServiceCallerMock = new CallerMock<>(formEditorService);
formEditorHelper = new TestFormEditorHelper(testFieldManager, editorFieldLayoutComponents);
formEditorService.loadContent(null);
formEditorHelper.initHelper(content);
assertEquals(formEditorHelper.getEditorFieldTypes().size(), formEditorHelper.getBaseFieldsDraggables().size());
}
use of org.kie.workbench.common.forms.editor.model.FormModelerContent in project kie-wb-common by kiegroup.
the class FormEditorPresenterAbstractTest method serviceLoad.
public FormModelerContent serviceLoad() {
content = spy(new FormModelerContent());
content.setDefinition(form);
content.setOverview(new Overview());
content.setPath(path);
content.setSynchronizationResult(synchronizationResult);
return content;
}
use of org.kie.workbench.common.forms.editor.model.FormModelerContent in project kie-wb-common by kiegroup.
the class FormEditorPresenterFieldSynchronizationTest method serviceLoad.
@Override
public FormModelerContent serviceLoad() {
FormModelerContent content = super.serviceLoad();
if (syncMode.equals(SyncMode.NEW_FIELDS)) {
synchronizationResult.getNewProperties().addAll(modelProperties);
} else if (syncMode.equals(SyncMode.CONFLICTS)) {
modelProperties.stream().map(property -> new TypeConflictImpl(property.getName(), property.getTypeInfo(), property.getTypeInfo())).forEach(typeConflict -> {
synchronizationResult.getConflicts().put(typeConflict.getPropertyName(), typeConflict);
});
} else if (syncMode.equals(SyncMode.REMOVED_FIELDS)) {
content.getDefinition().getFields().addAll(employeeFields);
synchronizationResult.getRemovedProperties().addAll(modelProperties);
}
return content;
}
use of org.kie.workbench.common.forms.editor.model.FormModelerContent in project kie-wb-common by kiegroup.
the class EditorFieldLayoutComponentTest method init.
@Before
public void init() {
fieldManager = spy(new TestFieldManager());
when(editorFieldLayoutComponents.get()).thenAnswer(invocationOnMock -> {
final EditorFieldLayoutComponent mocked = mock(EditorFieldLayoutComponent.class);
return mocked;
});
formEditorHelper = spy(new FormEditorHelper(new TestFieldManager(), editorFieldLayoutComponents));
fieldDefinition = new TextBoxFieldDefinition();
fieldDefinition.setId(EditorFieldLayoutComponent.FIELD_ID);
fieldDefinition.setName(EditorFieldLayoutComponent.FIELD_ID);
fieldDefinition.setBinding(EditorFieldLayoutComponent.FIELD_ID);
when(formDefinition.getId()).thenReturn(EditorFieldLayoutComponent.FORM_ID);
when(formDefinition.getFieldById(anyString())).thenReturn(fieldDefinition);
when(formDefinition.getModel()).thenReturn(formModel);
when(context.getRootForm()).thenReturn(formDefinition);
content = new FormModelerContent();
content.setDefinition(formDefinition);
content.setOverview(mock(Overview.class));
formEditorHelper.initHelper(content);
when(formEditorHelper.getRenderingContext()).thenReturn(context);
when(formEditorHelper.getFormField(any())).thenReturn(fieldDefinition);
layoutComponent.addProperty(EditorFieldLayoutComponent.FIELD_ID, EditorFieldLayoutComponent.FIELD_ID);
layoutComponent.addProperty(EditorFieldLayoutComponent.FORM_ID, EditorFieldLayoutComponent.FORM_ID);
ctx = new RenderingContext(layoutComponent, widget);
when(fieldRendererManager.getRendererForField(any())).thenReturn(fieldRenderer);
when(fieldRenderer.renderWidget()).thenReturn(widget);
when(propertiesRenderer.getView()).thenReturn(fieldPropertiesRendererView);
editorFieldLayoutComponent = spy(new EditorFieldLayoutComponent(propertiesRenderer, layoutDragComponentHelper, fieldManager, formEditorContext, syncPaletteEvent) {
{
fieldRendererManager = EditorFieldLayoutComponentTest.this.fieldRendererManager;
translationService = EditorFieldLayoutComponentTest.this.translationService;
}
@Override
protected FormEditorHelper getHelperInstance() {
return formEditorHelper;
}
});
editorFieldLayoutComponent.initPropertiesConfig();
propertiesRendererHelper = spy(editorFieldLayoutComponent.getPropertiesRendererHelper());
}
use of org.kie.workbench.common.forms.editor.model.FormModelerContent 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);
}
Aggregations