client.getTasksAssignedAsPotentialOwner("control", "en-UK", handler);
List<TaskSummary> sums = handler.getResults();
assertNotNull(sums);
assertEquals(1, sums.size());
BlockingTaskOperationResponseHandler startTaskOperationHandler = new BlockingTaskOperationResponseHandler();
client.start(sums.get(0).getId(), "control", startTaskOperationHandler);
BlockingGetTaskResponseHandler getTaskHandler = new BlockingGetTaskResponseHandler();
client.getTask(sums.get(0).getId(), getTaskHandler);
Task controlTask = getTaskHandler.getTask();
BlockingGetContentResponseHandler getContentHandler = new BlockingGetContentResponseHandler();
client.getContent(controlTask.getTaskData().getDocumentContentId(), getContentHandler);
Content content = getContentHandler.getContent();
assertNotNull(content);
ByteArrayInputStream bais = new ByteArrayInputStream(content.getContent());
ObjectInputStream ois = new ObjectInputStream(bais);
Map<String, Object> deserializedContent = (Map<String, Object>) ois.readObject();
Emergency retrivedEmergency = (Emergency) deserializedContent.get("emergency");
assertNotNull(retrivedEmergency);
ActivePatients retrivedActivePatients = (ActivePatients) deserializedContent.get("activePatients");
assertNotNull(retrivedActivePatients);
assertEquals(1, retrivedActivePatients.size());
SuggestedProcedures retrivedSuggestedProcedures = (SuggestedProcedures) deserializedContent.get("suggestedProcedures");
assertNotNull(retrivedSuggestedProcedures);
assertEquals("[DefaultHeartAttackProcedure: ]", retrivedSuggestedProcedures.getSuggestedProceduresString());
Map<String, Object> info = new HashMap<String, Object>();
SelectedProcedures selectedProcedures = new SelectedProcedures(
retrivedEmergency.getId());
selectedProcedures.addSelectedProcedureName("DefaultHeartAttackProcedure");
info.put("selectedProcedures", selectedProcedures);
ContentData result = new ContentData();
result.setAccessType(AccessType.Inline);
result.setType("java.util.Map");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(info);
out.close();
result.setContent(bos.toByteArray());
BlockingTaskOperationResponseHandler completeTaskOperationHandler = new BlockingTaskOperationResponseHandler();
client.complete(sums.get(0).getId(), "control", result, completeTaskOperationHandler);
}