@Deployment(resources={"org/activiti/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml"}) public void testLocalizeTasks() throws Exception {
  ProcessInstance processInstance=runtimeService.startProcessInstanceByKey("oneTaskProcess");
  List<Task> tasks=taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).list();
  assertEquals(1,tasks.size());
  assertEquals("my task",tasks.get(0).getName());
  assertEquals("My Task Description",tasks.get(0).getDescription());
  tasks=taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).locale("es").list();
  assertEquals(1,tasks.size());
  assertEquals("Mi Tarea",tasks.get(0).getName());
  assertEquals("Mi Tarea Descripción",tasks.get(0).getDescription());
  ObjectNode infoNode=dynamicBpmnService.getProcessDefinitionInfo(processInstance.getProcessDefinitionId());
  dynamicBpmnService.changeLocalizationName("en-GB","theTask","My 'en-GB' localized name",infoNode);
  dynamicBpmnService.changeLocalizationDescription("en-GB","theTask","My 'en-GB' localized description",infoNode);
  dynamicBpmnService.saveProcessDefinitionInfo(processInstance.getProcessDefinitionId(),infoNode);
  dynamicBpmnService.changeLocalizationName("en","theTask","My 'en' localized name",infoNode);
  dynamicBpmnService.changeLocalizationDescription("en","theTask","My 'en' localized description",infoNode);
  dynamicBpmnService.saveProcessDefinitionInfo(processInstance.getProcessDefinitionId(),infoNode);
  tasks=taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).list();
  assertEquals(1,tasks.size());
  assertEquals("my task",tasks.get(0).getName());
  assertEquals("My Task Description",tasks.get(0).getDescription());
  tasks=taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).locale("es").list();
  assertEquals(1,tasks.size());
  assertEquals("Mi Tarea",tasks.get(0).getName());
  assertEquals("Mi Tarea Descripción",tasks.get(0).getDescription());
  tasks=taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).locale("en-GB").list();
  assertEquals(1,tasks.size());
  assertEquals("My 'en-GB' localized name",tasks.get(0).getName());
  assertEquals("My 'en-GB' localized description",tasks.get(0).getDescription());
  tasks=taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).listPage(0,10);
  assertEquals(1,tasks.size());
  assertEquals("my task",tasks.get(0).getName());
  assertEquals("My Task Description",tasks.get(0).getDescription());
  tasks=taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).locale("es").listPage(0,10);
  assertEquals(1,tasks.size());
  assertEquals("Mi Tarea",tasks.get(0).getName());
  assertEquals("Mi Tarea Descripción",tasks.get(0).getDescription());
  tasks=taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).locale("en-GB").listPage(0,10);
  assertEquals(1,tasks.size());
  assertEquals("My 'en-GB' localized name",tasks.get(0).getName());
  assertEquals("My 'en-GB' localized description",tasks.get(0).getDescription());
  Task task=taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
  assertEquals("my task",task.getName());
  assertEquals("My Task Description",task.getDescription());
  task=taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).locale("es").singleResult();
  assertEquals("Mi Tarea",task.getName());
  assertEquals("Mi Tarea Descripción",task.getDescription());
  task=taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).locale("en-GB").singleResult();
  assertEquals("My 'en-GB' localized name",task.getName());
  assertEquals("My 'en-GB' localized description",task.getDescription());
  task=taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
  assertEquals("my task",task.getName());
  assertEquals("My Task Description",task.getDescription());
  task=taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).locale("en").singleResult();
  assertEquals("My 'en' localized name",task.getName());
  assertEquals("My 'en' localized description",task.getDescription());
  task=taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).locale("en-AU").withLocalizationFallback().singleResult();
  assertEquals("My 'en' localized name",task.getName());
  assertEquals("My 'en' localized description",task.getDescription());
}
