1 5 6 package org.exoplatform.services.workflow.test; 7 8 import org.exoplatform.container.PortalContainer; 9 import org.exoplatform.services.database.DatabaseService; 10 import org.exoplatform.services.exception.ExoServiceException; 11 import org.exoplatform.services.workflow.Form; 12 import org.exoplatform.services.workflow.WorkflowExecutionService; 13 import org.jbpm.JpdlException; 14 import org.jbpm.JbpmConfiguration; 15 import org.jbpm.model.definition.Definition; 16 17 import java.io.IOException ; 18 import java.util.List ; 19 import java.util.Locale ; 20 import java.util.ResourceBundle ; 21 22 27 public class TestForm extends BaseTest{ 28 29 private static final String PROCESS_FILE = "processdefinition.xml"; 30 31 public TestForm(String name) { 32 super(name); 33 } 34 35 protected String getDescription() { 36 return "test workflow forms"; 37 } 38 39 public void setUp() { 40 super.setUp(); 41 String [] files = {"forms.xml", "start.properties", 42 "evaluation.properties", "hr.properties"}; 43 try { 44 deployProcess(PROCESS_FILE, files); 45 } catch (IOException e) { 46 e.printStackTrace(); 47 } catch (JpdlException e) { 48 e.printStackTrace(); 49 } catch (ExoServiceException e) { 50 e.printStackTrace(); 51 } 52 53 } 54 55 public void testForms() { 56 WorkflowExecutionService executionService = workflowServiceContainer. 57 createWorkflowExecutionService(); 58 Definition definition = (Definition) executionService.getAllDefinitions().get(0); 59 workflowFormsService.addForms(definition, executionService, new Locale ("en")); 60 executionService.close(); 61 Form form = workflowFormsService.getForm(definition.getId(), "start"); 62 assertNotNull(form); 63 assertEquals("start", form.getStateName()); 64 ResourceBundle rB = form.getResourceBundle(); 65 assertEquals("Let's pray", rB.getString("submit")); 66 assertEquals("the amount you want your salary to be increased", 67 rB.getString("amount.asked.title")); 68 69 List map = form.getSubmitButtons(); 70 assertTrue(map.isEmpty()); 71 72 List variableFormats = form.getVariableFormats(); 73 assertTrue(!variableFormats.isEmpty()); 74 } 75 } 76 | Popular Tags |