in rake-runner-test/src/jetbrains/slow/plugins/rakerunner/AbstractRakeRunnerTest.java [334:373]
private static String reorderAttributesOfServiceMessages(String patchedActual) {
final String[] lines = patchedActual.split("\n");
for (int i = 0; i < lines.length; i++) {
String line = lines[i].trim();
final int serviceMessageStart = line.indexOf(SERVICE_MESSAGE_START);
if (serviceMessageStart != -1) {
// Fix order of attributes to match order of attributes in the test data.
// Just to avoid patching all the test data.
String text = line.substring(serviceMessageStart + SERVICE_MESSAGE_START.length());
String prefix = line.substring(0, serviceMessageStart + SERVICE_MESSAGE_START.length() + text.indexOf(" ") + 1);
text = text.substring(text.indexOf(" "), text.lastIndexOf(']')).trim();
if (text.startsWith("'")) {
// In case we have 'Single attribute message'
// do nothing
} else {
// In case we located at least one attribute ('Multiple attribute message')
try {
final Map<String, String> attributes = StringUtil.stringToProperties(text, StringUtil.STD_ESCAPER2, false);
removeAttributes(attributes);
final ArrayList<String> keys = new ArrayList<String>(attributes.keySet());
reorderAttributes(keys);
final Map<String, String> orderedAttributes = new LinkedHashMap<String, String>();
for (String key : keys) {
orderedAttributes.put(key, attributes.get(key));
}
final String s = StringUtil.propertiesToString(orderedAttributes, StringUtil.STD_ESCAPER2);
String newline = prefix + s + line.substring(line.lastIndexOf(']'));
lines[i] = newline;
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
}
}
patchedActual = StringUtil.join("\n", lines);
return patchedActual;
}