AnsweredAssumed Answered

problem with formService.submitStartFormData

Question asked by tomi87 on Jan 3, 2013
Latest reply on Jan 4, 2013 by tomi87
Hello,
I have with my Code a problem. The error message is:

java.lang.NumberFormatException: For input string: "usa"
   at java.lang.NumberFormatException.forInputString(Unknown Source)
   at java.lang.Long.parseLong(Unknown Source)
   at java.lang.Long.<init>(Unknown Source)
   at org.activiti.engine.impl.form.LongFormType.convertFormValueToModelValue(LongFormType.java:35)
   at org.activiti.engine.impl.form.FormPropertyHandler.submitFormProperty(FormPropertyHandler.java:87)
   at org.activiti.engine.impl.form.DefaultFormHandler.submitFormProperties(DefaultFormHandler.java:131)
   at org.activiti.engine.impl.cmd.SubmitStartFormCmd.execute(SubmitStartFormCmd.java:78)
   at org.activiti.engine.impl.cmd.SubmitStartFormCmd.execute(SubmitStartFormCmd.java:35)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.FormServiceImpl.submitStartFormData(FormServiceImpl.java:60)
   at org.bpmwithactiviti.Part1ApplicationTest.TestStartEvent.startFormSubmit(TestStartEvent.java:62)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
   at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
   at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
   at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
   at org.junit.rules.TestWatchman$1.evaluate(TestWatchman.java:48)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
   at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

My Test:

public class TestStartEvent {
   @Rule
   public ActivitiRule activitiRule = new ActivitiRule("activiti.cfg-mem.xml");
   @Test
   @Deployment(resources={"Part1Application.bpmn20.xml"})
   public void startFormSubmit() {
      ProcessDefinition definition = activitiRule.getRepositoryService()
            .createProcessDefinitionQuery().processDefinitionKey("part1Application").singleResult();
      assertNotNull(definition);
      FormService formService = activitiRule.getFormService();
      List<FormProperty> formList = formService.getStartFormData(definition.getId()).getFormProperties();
      assertEquals(12, formList.size());
      Map<String, String> formProperties = new HashMap<String, String>();
      formProperties.put("studentName", "Toni Peter");
      formProperties.put("emailAddress", "toni@localhost");
      formProperties.put("dateFrom", "12345");
           formProperties.put("dateToo", "23456");
      formProperties.put("homeCountry", "usa");
      formProperties.put("homeUniversity", "assdff");
      formProperties.put("homeDepartment", "Computer Science");
      formProperties.put("targetUniversity", "blaa University");
      formProperties.put("targetDepartment", "Communication Engineering");
      formProperties.put("research", "Enrollment Process");
      formProperties.put("courseEnrollment", "UML");
      formProperties.put("project", "true");
   
      formService.submitStartFormData(definition.getId(), formProperties);
      List<HistoricDetail> historyVariables = activitiRule.getHistoryService()
           .createHistoricDetailQuery()
           .formProperties()
           .list();

      assertNotNull(historyVariables);
      assertEquals(12, historyVariables.size());
      HistoricFormProperty formProperty = (HistoricFormProperty) historyVariables.get(0);
      assertEquals("project", formProperty.getPropertyId());
      assertEquals("true", formProperty.getPropertyValue());
      
      formProperty = (HistoricFormProperty) historyVariables.get(1);
      assertEquals("courseEnrollment", formProperty.getPropertyId());
      assertEquals("UML", formProperty.getPropertyValue());
   }
}

My Java:

      StudentAppInfo sai = new StudentAppInfo();
      sai.setStudentName((String) execution.getVariable("studentName"));
      sai.setEmailAddress((String) execution.getVariable("emailAddress"));
      sai.setDateFrom((Long) execution.getVariable("dateFrom"));
      sai.setDateToo((Long) execution.getVariable("dateToo"));
      sai.setHomeCountry((String) execution.getVariable("homeCountry"));
      sai.setHomeUniversity((String) execution.getVariable("homeUniversity"));
      sai.setHomeDepartment((String) execution.getVariable("homeDepartement"));
      sai.setTargetUniversity((String) execution.getVariable("targetUniversity"));
      sai.setTargetDepartment((String) execution.getVariable("targetDepartment"));
      sai.setResearch((String) execution.getVariable("research"));
      sai.setProject((Boolean) execution.getVariable("project"));
      sai.setCourseEnrollment((String) execution.getVariable("courseEnrollment"));
      execution.setVariable("studentAppInfo", sai);
   }
And .bpmn20.xml code:
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn"
   xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
   xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema"
   expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.signavio.com/bpmn20">
   <process id="part1Application">
      <startEvent id="start">
         <extensionElements>
            <activiti:formProperty id="studentName" name="Studenten Name"
               required="true" type="string" />
            <activiti:formProperty id="emailAddress" name="Email address"
               required="true" type="string" />
            <activiti:formProperty id="dateFrom" name="Date from"
               required="true" type="long" />
            <activiti:formProperty id="dateToo" name="Date too"
               required="true" type="long" />
            <activiti:formProperty id="homeCountry" name="Home Country"
               required="true" type="long" />
            <activiti:formProperty id="homeUniversity"
               name="Home University" required="true" type="long" />
            <activiti:formProperty id="homeDepartment"
               name="Home Department" required="true" type="long" />
            <activiti:formProperty id="targetUniversity"
               name="Target University" required="true" type="long" />
            <activiti:formProperty id="targetDepartment"
               name="Target Department" required="true" type="long" />
            <activiti:formProperty id="research" name="Research"
               required="true" type="long" />
            <activiti:formProperty id="courseEnrollment"
               name="Course Enrollment" required="true" type="long" />
            <activiti:formProperty id="project" name="With project"
               required="true" type="boolean" />
         </extensionElements>
      </startEvent>

I figured out that the error come at formService.submitStartFormData(definition.getId(), formProperties); but I don't know what could be wrong.

Please help me.

Outcomes