Package org.jbpm.formapi.shared.api

Examples of org.jbpm.formapi.shared.api.FormRepresentation


        Translator translator = EasyMock.createMock(Translator.class);
        ServletContext context = EasyMock.createMock(ServletContext.class);
        RESTFormService restService = emulateRESTFormService(translator, null, null, null);
        restService.setFormService(new MockFormDefinitionService());
       
        FormRepresentation form = createMockForm("myForm", "key1", "key2");
        FormPreviewDTO dto = createFormPreviewDTO(form);
       
        TranslatorException exception = new TranslatorException("Something going wrong");
        EasyMock.expect(translator.translateForm(EasyMock.eq(form))).andThrow(exception).once();
       
View Full Code Here


        EasyMock.expect(request.getParameter(EasyMock.eq("pwd"))).andReturn(null).once();
        EasyMock.expect(request.getParameter(EasyMock.eq("uuid"))).andReturn(uuid).once();
        FormDefinitionService formService = EasyMock.createMock(FormDefinitionService.class);
        TaskDefinitionService taskService = EasyMock.createMock(TaskDefinitionService.class);
        EasyMock.expect(taskService.getContainingPackage(EasyMock.eq(uuid))).andReturn("somePackage").once();
        FormRepresentation form = RESTAbstractTest.createMockForm("myForm", "my1Param", "my2Param");
        EasyMock.expect(formService.getFormByUUID(EasyMock.eq("somePackage"), EasyMock.eq(uuid))).andReturn(form).once();
        request.setAttribute(EasyMock.eq("jsonData"), EasyMock.anyObject(String.class));
        EasyMock.expectLastCall().once();
        RequestDispatcher dispatcher = EasyMock.createMock(RequestDispatcher.class);
        dispatcher.forward(request, response);
View Full Code Here

        EasyMock.expect(request.getParameter(EasyMock.eq("pwd"))).andReturn(null).once();
        EasyMock.expect(request.getParameter(EasyMock.eq("uuid"))).andReturn(uuid).once();
        FormDefinitionService formService = EasyMock.createMock(FormDefinitionService.class);
        TaskDefinitionService taskService = EasyMock.createMock(TaskDefinitionService.class);
        EasyMock.expect(taskService.getContainingPackage(EasyMock.eq(uuid))).andReturn("somePackage").once();
        FormRepresentation form = RESTAbstractTest.createMockForm("myForm", "my1Param", "my2Param");
        EasyMock.expect(formService.getFormByUUID(EasyMock.eq("somePackage"), EasyMock.eq(uuid))).andReturn(form).once();
        FormRepresentationEncoder encoder = EasyMock.createMock(FormRepresentationEncoder.class);
        EasyMock.expect(encoder.encode(EasyMock.eq(form))).andThrow(new FormEncodingException()).once();
        EmbedingServlet servlet = createServlet(formService, taskService);
        FormEncodingFactory.register(encoder, FormEncodingFactory.getDecoder());
View Full Code Here

        FormDefinitionService formService = EasyMock.createMock(FormDefinitionService.class);
        TaskDefinitionService taskService = EasyMock.createMock(TaskDefinitionService.class);
        TaskRef task = new TaskRef();
        task.setPackageName("somePackage");
        EasyMock.expect(taskService.getBPMN2Task(EasyMock.eq(xml), EasyMock.eq("PROCESS_NAME"), EasyMock.eq("USER_TASK"))).andReturn(task).once();
        FormRepresentation form = RESTAbstractTest.createMockForm("myForm", "myParam");
        EasyMock.expect(formService.getAssociatedForm(EasyMock.eq("somePackage"), EasyMock.eq(task))).andReturn(form).once();
        EmbedingServlet servlet = createServlet(formService, taskService);
        request.setAttribute(EasyMock.eq("jsonData"), EasyMock.anyObject(String.class));
        EasyMock.expectLastCall().once();
        RequestDispatcher dispatcher = EasyMock.createMock(RequestDispatcher.class);
View Full Code Here

        FormDefinitionService formService = EasyMock.createMock(FormDefinitionService.class);
        TaskDefinitionService taskService = EasyMock.createMock(TaskDefinitionService.class);
        TaskRef task = new TaskRef();
        task.setPackageName("somePackage");
        EasyMock.expect(taskService.getBPMN2Task(EasyMock.eq(xml), EasyMock.eq("PROCESS_NAME"), EasyMock.eq("USER_TASK"))).andReturn(task).once();
        FormRepresentation form = RESTAbstractTest.createMockForm("myForm", "myParam");
        EasyMock.expect(formService.getAssociatedForm(EasyMock.eq("somePackage"), EasyMock.eq(task))).andReturn(form).once();
        FormRepresentationEncoder encoder = EasyMock.createMock(FormRepresentationEncoder.class);
        EasyMock.expect(encoder.encode(EasyMock.eq(form))).andThrow(new FormEncodingException()).once();
        EmbedingServlet servlet = createServlet(formService, taskService);
        FormEncodingFactory.register(encoder, FormEncodingFactory.getDecoder());
View Full Code Here

*
*/
public abstract class RESTAbstractTest extends TestCase {

    public static FormRepresentation createMockForm(String title, String... params) {
        FormRepresentation form = new FormRepresentation();
        HeaderRepresentation header = new HeaderRepresentation();
        header.setValue(title);
        form.addFormItem(header);
       
        TableRepresentation table = new TableRepresentation();
        table.setRows(params.length);
        table.setColumns(2);
        table.setHeight("" + (params.length * 30) + "px");
        for (int index = 0; index < params.length; index++) {
            String paramName = params[index];
            LabelRepresentation labelName = new LabelRepresentation();
            labelName.setValue(paramName);
            labelName.setWidth("100px");
            table.setElement(index, 0, labelName);
            TextFieldRepresentation textField = new TextFieldRepresentation();
            textField.setWidth("200px");
            OutputData data = new OutputData();
            data.setName(paramName);
            data.setMimeType("multipart/form-data");
            data.setFormatter(null);
            textField.setOutput(data);
            table.setElement(index, 1, textField);
        }
        LabelRepresentation labelParams = new LabelRepresentation();
        labelParams.setValue("Parameters:");
        form.addFormItem(labelParams);
        form.addFormItem(table);
       
        CompleteButtonRepresentation completeButton = new CompleteButtonRepresentation();
        completeButton.setText("Complete");
        form.addFormItem(completeButton);
        form.setAction("complete");
        form.setEnctype("multipart/form-data");
        form.setMethod("POST");
        form.setName(title + "AutoForm");
        return form;
    }
View Full Code Here

        assertNull("result should be null", encoder.fromMap(null));
        assertNull("result should be null", encoder.fromMap(new HashMap<String, Object>()));
       
        assertNotNull("formattedDate shouldn't be null", encoder.formatDate(new Date()));
       
        FormRepresentation form = RESTAbstractTest.createMockForm("myForm", "myParam1", "myParam2");
        FormItemRepresentation item = form.getFormItems().iterator().next();
        Map<String, Object> data = item.getDataMap();
        Object obj = encoder.fromMap(data);
        assertNotNull("obj shouldn't be null", obj);
        assertTrue("obj should be of type FormItemRepresentation", obj instanceof FormItemRepresentation);
        FormItemRepresentation retval = (FormItemRepresentation) obj;
View Full Code Here

    public void testTemplateFormFromTask() throws Exception {
        TaskRef task = new TaskRef();
        task.setTaskId("MyTask");
        FormDefinitionService formService = new MockFormDefinitionService();
        FormRepresentation form = formService.createFormFromTask(task);
        assertNotNull("form shouldn't be null", form);
        assertTrue("form should contain two items", form.getFormItems().size() == 2);
    }
View Full Code Here

        assertTrue("form should contain two items", form.getFormItems().size() == 2);
    }
   
    public void testMockService() throws Exception {
        MockFormDefinitionService service = new MockFormDefinitionService();
        FormRepresentation form = RESTAbstractTest.createMockForm("myForm", "myParam");
        String formId = service.saveForm("pkgName", form);
        assertNotNull("formId shouldn't be null", formId);
       
        FormRepresentation form2 = service.getForm("pkgName", formId);
        assertNotNull("form2 shouldn't be null", form2);
        assertEquals("form and form2 should be the same", form, form2);
       
        FormRepresentation form3 = service.getForm("pkgName", "notARealFormId");
        assertNull("form2 should be null", form3);
       
        List<FormRepresentation> forms = service.getForms("pkgName");
        assertNotNull("forms shouldn't be null", forms);
        assertEquals("forms size should be 1", 1, forms.size());
View Full Code Here

TOP

Related Classes of org.jbpm.formapi.shared.api.FormRepresentation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.