Source:
<code>public void testGetProcessInstanceCustomMapper() throws Exception { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("stringData", "waiting for signal"); <START> parameters.put("personData", USER_JOHN); <END> Long pid = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK, parameters); QueryDefinition query = new QueryDefinition(); query.setName("jbpmProcessWithVarsSearch"); query.setSource(System.getProperty("org.kie.server.persistence.ds", "jdbc/jbpm-ds")); query.setExpression("select p. PROCESSINSTANCEID, p.PROCESSID, p.PROCESSNAME, p.PROCESSVERSION, p.STATUS, " + "p.EXTERNALID, pr.STARTDATE as START_DATE, p.USER_IDENTITY, p.PROCESSINSTANCEDESCRIPTION, " + "p.CORRELATIONKEY, p.PARENTPROCESSINSTANCEID, pr.LASTMODIFICATIONDATE, var.variableId, var.value " + "from PROCESSINSTANCELOG p inner join PROCESSINSTANCEINFO pr on p.PROCESSINSTANCEID = pr.INSTANCEID " + "inner join (select v.processInstanceId, v.variableId, v.value from VariableInstanceLog v " + "where v.id = (select MAX(vil.id) from VariableInstanceLog vil " + "where v.variableId = vil.variableId and v.processInstanceId = vil.processInstanceId)) var " + "on p.PROCESSINSTANCEID = var.PROCESSINSTANCEID"); query.setTarget("CUSTOM"); try { queryClient.registerQuery(query); List<ProcessInstanceCustomVars> instance = queryClient.query(query.getName(), QueryServicesClient.QUERY_MAP_PI_CUSTOM, 0, 10, ProcessInstanceCustomVars.class); assertNotNull(instance); assertEquals(1, instance.size()); final Map<String, Object> variables = instance.get(0).getVariables(); assertNotNull(variables); assertEquals(3, variables.size()); assertEquals(TestConfig.getUsername(), variables.get("initiator")); assertEquals("waiting for signal", variables.get("stringData")); assertEquals(USER_JOHN, variables.get("personData")); } finally { processClient.abortProcessInstance(CONTAINER_ID, pid); queryClient.unregisterQuery(query.getName()); } }</code><technical_language>leave is compare end is equals toString() representation of object</technical_language>

Target:
public void testGetProcessInstanceCustomMapper() throws Exception { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("stringData", "waiting for signal"); parameters.put("personData", createPersonInstance(CONTAINER_ID)); Long pid = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK, parameters); QueryDefinition query = new QueryDefinition(); query.setName("jbpmProcessWithVarsSearch"); query.setSource(System.getProperty("org.kie.server.persistence.ds", "jdbc/jbpm-ds")); query.setExpression("select p. PROCESSINSTANCEID, p.PROCESSID, p.PROCESSNAME, p.PROCESSVERSION, p.STATUS, " + "p.EXTERNALID, pr.STARTDATE as START_DATE, p.USER_IDENTITY, p.PROCESSINSTANCEDESCRIPTION, " + "p.CORRELATIONKEY, p.PARENTPROCESSINSTANCEID, pr.LASTMODIFICATIONDATE, var.variableId, var.value " + "from PROCESSINSTANCELOG p inner join PROCESSINSTANCEINFO pr on p.PROCESSINSTANCEID = pr.INSTANCEID " + "inner join (select v.processInstanceId, v.variableId, v.value from VariableInstanceLog v " + "where v.id = (select MAX(vil.id) from VariableInstanceLog vil " + "where v.variableId = vil.variableId and v.processInstanceId = vil.processInstanceId)) var " + "on p.PROCESSINSTANCEID = var.PROCESSINSTANCEID"); query.setTarget("CUSTOM"); try { queryClient.registerQuery(query); List<ProcessInstanceCustomVars> instance = queryClient.query(query.getName(), QueryServicesClient.QUERY_MAP_PI_CUSTOM, 0, 10, ProcessInstanceCustomVars.class); assertNotNull(instance); assertEquals(1, instance.size()); final Map<String, Object> variables = instance.get(0).getVariables(); assertNotNull(variables); assertEquals(3, variables.size()); assertEquals(TestConfig.getUsername(), variables.get("initiator")); assertEquals("waiting for signal", variables.get("stringData")); assertEquals(parameters.get("personData").toString(), variables.get("personData")); } finally { processClient.abortProcessInstance(CONTAINER_ID, pid); queryClient.unregisterQuery(query.getName()); } }