use of com.centurylink.mdw.model.value.work.ActivityInstanceVO in project mdw-designer by CenturyLinkCloud.
the class TestCaseRun method translateToLegacyTestFile.
private void translateToLegacyTestFile(String procName, ProcessInstanceVO procInst, int instIndex, Map<Long, String> activityNameMap) throws IOException, DataAccessException {
TestFile actualFile = new TestFile(null, testcase.getResultDirectory().getPath() + "/R_" + procName + "_I" + instIndex + ".txt");
TestFile expectedFileToCreate = null;
if (createReplace) {
expectedFileToCreate = new TestFile(null, testcase.getCaseDirectory().getPath() + "/E_" + procName + "_I" + instIndex + ".txt");
log.println("Creating expected results file: " + expectedFileToCreate);
}
TestFileLine line = new TestFileLine("PROC");
line.addWord(Integer.toString(instIndex));
line.addWord("#");
line.addWord(procInst.getId().toString());
actualFile.addLine(line);
if (expectedFileToCreate != null)
expectedFileToCreate.addLine(line);
LinkedList<ActivityInstanceVO> reversedList = new LinkedList<>();
for (ActivityInstanceVO act : procInst.getActivities()) {
reversedList.add(0, act);
}
for (ActivityInstanceVO act : reversedList) {
String status = WorkStatuses.getWorkStatuses().get(act.getStatusCode());
String actName = activityNameMap.get(act.getDefinitionId());
if (actName == null)
actName = act.getDefinitionId().toString();
line = new TestFileLine("ACT");
line.addWord(actName);
line.addWord(status);
line.addWord("#");
line.addWord(act.getId().toString());
line.addWord(act.getStartDate());
actualFile.addLine(line);
if (expectedFileToCreate != null)
expectedFileToCreate.addLine(line);
}
for (VariableInstanceInfo var : procInst.getVariables()) {
line = new TestFileLine("VAR");
line.addWord(var.getName());
try {
String value = var.getStringValue();
if (VariableHelper.isDocumentVariable(var.getType(), value)) {
DocumentReference docref = new DocumentReference(value);
String docVal = dao.getDocumentContent(docref, var.getType());
line.addWord(docVal);
// pre-populate document values
procInst.getVariable().put(var.getName(), docVal);
} else
line.addWord(var.getStringValue());
} catch (Throwable e) {
log.println("Failed to translate variable to string with the following exception");
e.printStackTrace(log);
line.addWord(var.getStringValue());
}
line.addWord("#");
line.addWord(var.getInstanceId().toString());
actualFile.addLine(line);
if (expectedFileToCreate != null)
expectedFileToCreate.addLine(line);
}
actualFile.save();
if (expectedFileToCreate != null)
expectedFileToCreate.save();
}
Aggregations