} else if (section.equals(Section.NOTES)) {
currentPermutation.note(multiLineKey, multiLineValue, OutputFormat.FromFile);
} else if (section.equals(Section.DATA)) {
currentPermutation.data(multiLineKey, multiLineValue, OutputFormat.FromFile);
} else {
throw new UnexpectedLiquibaseException("Unknown multiline section on line " + lineNumber + ": " + section);
}
multiLineKey = null;
multiLineValue = null;
}
}
if (StringUtils.trimToEmpty(line).equals("")) {
continue;
}
if (line.equals("#### Notes ####")) {
section = Section.NOTES;
continue;
} else if (line.equals("#### Data ####")) {
section = Section.DATA;
continue;
}
Matcher permutationStartMatcher = permutationStartPattern.matcher(line);
if (permutationStartMatcher.matches()) {
currentPermutation = new TestPermutation(results);
section = Section.DEFINITION;
continue;
}
Matcher permutationGroupStartMatcher = permutationGroupStartPattern.matcher(line);
if (permutationGroupStartMatcher.matches()) {
currentPermutation = null;
currentPermutationGroup = new HashMap<String, String>();
permutationDefinitionKey = permutationGroupStartMatcher.group(1);
permutationColumns = new ArrayList<String>();
section = Section.GROUP_DEFINITION;
continue;
}
Matcher internalKeyValueMatcher = internalKeyValuePattern.matcher(line);
if (internalKeyValueMatcher.matches()) {
String key = internalKeyValueMatcher.group(1);
String value = internalKeyValueMatcher.group(2);
if (key.equals("VERIFIED")) {
setVerifiedFromString(currentPermutation, value);
} else {
throw new UnexpectedLiquibaseException("Unknown internal parameter " + key);
}
continue;
}
Matcher keyValueMatcher = keyValuePattern.matcher(line);
if (keyValueMatcher.matches()) {
String key = keyValueMatcher.group(1);
String value = keyValueMatcher.group(2);
if (section.equals(Section.DEFINITION)) {
currentPermutation.describe(key, value, OutputFormat.FromFile);
} else if (section.equals(Section.GROUP_DEFINITION)) {
currentPermutationGroup.put(key, value);
} else if (section.equals(Section.NOTES)) {
currentPermutation.note(key, value, OutputFormat.FromFile);
} else if (section.equals(Section.DATA)) {
currentPermutation.data(key, value, OutputFormat.FromFile);
} else {
throw new UnexpectedLiquibaseException("Unknown section " + section);
}
continue;
}
if (line.startsWith("|")) {
String unlikelyStringForSplit = "OIPUGAKJNGAOIUWDEGKJASDG";
String lineToSplit = line.replaceFirst("\\|", unlikelyStringForSplit).replaceAll("([^\\\\])\\|", "$1" + unlikelyStringForSplit);
String[] values = lineToSplit.split("\\s*" + unlikelyStringForSplit + "\\s*");
if (line.startsWith("| Permutation ")) {
for (int i = 3; i < values.length - 1; i++) { //ignoring first value that is an empty string and last value that is DETAILS
permutationColumns.add(values[i]);
}
} else {
if (values[1].equals("")) {
; //continuing row
} else {
currentPermutation = new TestPermutation(results);
for (Map.Entry<String, String> entry : currentPermutationGroup.entrySet()) {
currentPermutation.describe(entry.getKey(), entry.getValue(), OutputFormat.FromFile);
}
setVerifiedFromString(currentPermutation, values[2]);
int columnNum = 0;
Map<String, TestPermutation.Value> valueDescription = new HashMap<String, TestPermutation.Value>();
try {
for (int i = 3; i < values.length - 1; i++) {
if (!values[i].equals("")) {
valueDescription.put(permutationColumns.get(columnNum), new TestPermutation.Value(decode(values[i]), OutputFormat.FromFile));
}
columnNum++;
}
} catch (Throwable e) {
throw new UnexpectedLiquibaseException("Error parsing line " + line);
}
currentPermutation.describeAsTable(permutationDefinitionKey, valueDescription);
}
String details = values[values.length - 1];
Matcher dataMatcher = dataDetailsMatcher.matcher(details);
Matcher notesMatcher = notesDetailsMatcher.matcher(details);
if (dataMatcher.matches()) {
currentPermutation.data(dataMatcher.group(1), decode(dataMatcher.group(2)), OutputFormat.FromFile);
} else if (notesMatcher.matches()) {
currentPermutation.note(notesMatcher.group(1), decode(notesMatcher.group(2)), OutputFormat.FromFile);
} else {
throw new RuntimeException("Unknown details column format: " + details);
}
}
continue;
}
Matcher multiLineKeyValueMatcher = multiLineKeyValuePattern.matcher(line);
if (multiLineKeyValueMatcher.matches()) {
multiLineKey = multiLineKeyValueMatcher.group(1);
multiLineValue = "";
continue;
}
if (currentPermutation == null) {
//in the header section describing what the file is for
} else {
throw new UnexpectedLiquibaseException("Could not parse line " + lineNumber + ": " + line);
}
}
}
return results;