Verified Commit f4bd7c91 authored by Daniel Mangold's avatar Daniel Mangold
Browse files

Changed test metadata format to JSON

parent e277b3ed
package h05;
import org.json.JSONObject;
import org.opentest4j.TestAbortedException;
import java.io.*;
......@@ -213,24 +214,24 @@ public class Utils {
return false;
}
try (BufferedReader remoteReader = new BufferedReader(new StringReader(response.body()))) {
try {
JSONObject remoteData = new JSONObject(response.body());
boolean persistentChanges = false;
String[] versionLine = remoteReader.readLine().split(" -- ", 2);
Version localVersion = new Version(LOCAL_VERSION),
remoteVersion = new Version(versionLine[0]);
remoteVersion = new Version(remoteData.getString("version"));
if (remoteVersion.compareTo(localVersion) > 0) {
System.out.println("Update available! Local version: " + localVersion + " -- Remote version: " + remoteVersion);
System.out.println("Changelog: " + REPOSITORY_URL + "blob/master/changelog.md");
System.out.println(versionLine[1]);
}
System.out.println(remoteData.getString("updateMessage"));
} else
System.out.println("Local tests are up to date");
for (
String line = remoteReader.readLine();
(CHECK_HASHES || (AUTO_UPDATE && remoteVersion.compareTo(localVersion) > 0)) && line != null && line.length() != 0;
line = remoteReader.readLine()
) {
String fileName = line.split(" +")[0], expectedHash = line.split(" +")[1];
if (!(CHECK_HASHES || (AUTO_UPDATE && remoteVersion.compareTo(localVersion) > 0)))
return false;
for (Map.Entry<String, Object> fileMap : remoteData.getJSONObject("hashes").toMap().entrySet()) {
String fileName = fileMap.getKey(), expectedHash = (String) fileMap.getValue();
if (((List<?>) getConfigOrDefault("EXCLUDED_FILES", List.of())).contains(fileName))
continue;
......@@ -268,8 +269,6 @@ public class Utils {
}
}
System.out.println("Local tests are up to date");
return persistentChanges;
} catch (IOException | InterruptedException | NoSuchAlgorithmException e) {
e.printStackTrace();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment