/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.activiti.engine.test.bpmn.servicetask;

import java.util.HashMap;
import java.util.Map;

import org.activiti.engine.impl.bpmn.FieldBaseStructureInstance;
import org.activiti.engine.impl.bpmn.ItemDefinition;
import org.activiti.engine.impl.bpmn.ItemInstance;
import org.activiti.engine.impl.bpmn.SimpleStructureDefinition;
import org.activiti.engine.runtime.ProcessInstance;

/**
 * @author Esteban Robles Luna
 */
public class WebServiceUELTest extends AbstractWebServiceTaskTest {

  public void testWebServiceInvocationWithDataFlowUEL() throws Exception {
    //TODO replace structure creation with a query to the repository
    SimpleStructureDefinition simpleStructureDefinition = new SimpleStructureDefinition("structure-id");
    simpleStructureDefinition.setFieldName(0, "prefix", String.class);
    simpleStructureDefinition.setFieldName(1, "suffix", String.class);
    ItemDefinition itemDefinition = new ItemDefinition("definition-id", simpleStructureDefinition);
    
    ItemInstance itemInstance = itemDefinition.createInstance();
    FieldBaseStructureInstance structureInstance = (FieldBaseStructureInstance) itemInstance.getStructureInstance();
    structureInstance.setFieldValue("prefix", "The counter has the value ");
    structureInstance.setFieldValue("suffix", ". Good news");
    
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("dataInputOfProcess", itemInstance);
    
    ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceByKey(
            "webServiceInvocationWithDataFlowUEL",
            variables);
    waitForJobExecutorToProcessAllJobs(10000L, 250L);
    
    String response = (String) processEngine.getRuntimeService().getVariable(instance.getId(), "dataOutputOfProcess");
    assertEquals("The counter has the value -1. Good news", response);
  }
}

@@ -861,28 +861,139 @@
 mpl.
-bpmn.SimpleStructure
+cfg.RepositorySession;%0Aimport org.activiti.engine.impl.db.DbRepositorySessionFactory;%0Aimport org.activiti.engine.repository.Process
 Defi
@@ -1244,317 +1244,330 @@
     
-//TODO replace structure creation with a query to the repository%0A    SimpleStructureDefinition simpleStructureDefinition = new SimpleStructureDefinition(%22structure-id%22);%0A    simpleStructureDefinition.setFieldName(0, %22prefix%22, String.class);%0A    simpleStructureDefinition.setFieldName(1, %22suffix%22, String.class
+DbRepositorySessionFactory dbRepositorySessionFactory = (DbRepositorySessionFactory) this.processEngineConfiguration.getSessionFactories().get(%0A            RepositorySession.class);%0A    ProcessDefinition processDefinition = dbRepositorySessionFactory.getProcessDefinitionCache().get(%22webServiceInvocationWithDataFlowUEL:1%22
 );%0A 
@@ -1605,16 +1605,15 @@
 n = 
-new Item
+process
 Defi
@@ -1622,41 +1622,56 @@
 tion
-(%22definition-id%22, simpleStructure
+.getIoSpecification().getDataInputs().get(0).get
 Defi
@@ -1676,23 +1676,20 @@
 finition
+(
 );%0A
-    
 %0A    Ite
@@ -2002,21 +2002,17 @@
 news%22);%0A
-    
 %0A
+
     Map%3C
@@ -2125,20 +2125,16 @@
 tance);%0A
-    
 %0A    Pro
@@ -2217,29 +2217,16 @@
 ceByKey(
-%0A            
 %22webServ
@@ -2255,28 +2255,16 @@
 lowUEL%22,
-%0A           
  variabl
@@ -2322,20 +2322,16 @@
  250L);%0A
-    
 %0A    Str

Add web service task - Improve UEL test