Merge branch 'stable-3.1' into stable-3.2

* change-292106:
  Adapt tests to compact JSON
  Revert "Clean up BUILD rules"

Change-Id: I9062c5f84c85cdf3203f8c4c7d7a8462f276c98e
diff --git a/BUILD b/BUILD
index d793ed7..15148a1 100644
--- a/BUILD
+++ b/BUILD
@@ -2,34 +2,36 @@
 load("//tools/bzl:junit.bzl", "junit_tests")
 load(
     "//tools/bzl:plugin.bzl",
+    "PLUGIN_DEPS",
     "PLUGIN_DEPS_NEVERLINK",
     "PLUGIN_TEST_DEPS",
     "gerrit_plugin",
 )
 
-prolog_cafe_library(
-    name = "find_owners_prolog_rules",
-    srcs = glob(["src/main/prolog/*.pl"]),
-    deps = [
-        ":find_owners",
-        "//prolog:gerrit-prolog-common",
+MODULE = ["src/main/java/com/googlesource/gerrit/plugins/findowners/Module.java"]
+
+java_library(
+    name = "find-owners-lib",
+    srcs = glob(
+        ["src/main/java/**/*.java"],
+        exclude = MODULE,
+    ),
+    deps = PLUGIN_DEPS_NEVERLINK + [
+        "@prolog-runtime//jar:neverlink",
     ],
 )
 
-FIND_OWNERS_SRCS = glob(["src/main/java/**/*.java"])
-
-FIND_OWNERS_DEPS = ["@prolog-runtime//jar:neverlink"]
-
-java_library(
-    name = "find_owners",
-    srcs = FIND_OWNERS_SRCS,
-    resources = glob(["src/main/resources/**/*"]),
-    deps = FIND_OWNERS_DEPS + PLUGIN_DEPS_NEVERLINK,
+prolog_cafe_library(
+    name = "find-owners-prolog-rules",
+    srcs = glob(["src/main/prolog/*.pl"]),
+    deps = PLUGIN_DEPS_NEVERLINK + [
+        ":find-owners-lib",
+    ],
 )
 
 gerrit_plugin(
     name = "find-owners",
-    srcs = FIND_OWNERS_SRCS,
+    srcs = MODULE,
     manifest_entries = [
         "Gerrit-PluginName: find-owners",
         "Gerrit-ReloadMode: restart",
@@ -39,55 +41,52 @@
         "Implementation-URL: https://gerrit.googlesource.com/plugins/find-owners",
     ],
     resources = glob(["src/main/resources/**/*"]),
-    deps = FIND_OWNERS_DEPS + [":find_owners_prolog_rules"],
+    deps = [
+        ":find-owners-lib",
+        ":find-owners-prolog-rules",
+    ],
 )
 
-# Libraries used by all find-owners junit tests.
-FIND_OWNERS_TESTS_DEPS = PLUGIN_TEST_DEPS
-
-FIND_OWNERS_TESTS_DEPS = FIND_OWNERS_TESTS_DEPS + [
-    ":find_owners",
-]
-
-# Base find_owners_IT library depends on these Gerrit IT acceptance libraries.
-FIND_OWNERS_IT_DEPS = [
-    "@commons-io//jar",
-]
-
-# All IT tests need the find_owners_IT and find_owners_IT libraries.
-FIND_OWNERS_IT_TESTS_DEPS = FIND_OWNERS_IT_DEPS + [
-    ":find_owners_IT",
-    ":find_owners_junit",
-    ":find_owners_prolog_rules",
-]
-
-# Utilities for junit tests.
 java_library(
-    name = "find_owners_junit",
+    name = "find-owners-junit",
     testonly = 1,
     srcs = glob(["src/test/java/**/Watcher.java"]),
-    deps = FIND_OWNERS_TESTS_DEPS,
+    deps = PLUGIN_TEST_DEPS,
 )
 
-# Base class and utilities for IT tests.
 java_library(
-    name = "find_owners_IT",
+    name = "find-owners-IT",
     testonly = 1,
     srcs = glob(["src/test/java/**/FindOwners.java"]),
-    deps = FIND_OWNERS_TESTS_DEPS + FIND_OWNERS_IT_DEPS,
+    deps = PLUGIN_TEST_DEPS + [
+        ":find-owners-junit",
+        ":find-owners-lib",
+        ":find-owners__plugin",
+    ],
 )
 
-# Simple fast junit non-IT tests.
+# Separate fast junit tests from slow interation (IT) tests.
 junit_tests(
     name = "findowners_junit_tests",
     srcs = glob(["src/test/java/**/*Test.java"]),
-    deps = FIND_OWNERS_TESTS_DEPS + [":find_owners_junit"],
+    tags = ["findowners"],
+    deps = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
+        "@commons-io//jar",
+        ":find-owners-junit",
+        ":find-owners-lib",
+    ],
 )
 
-# IT tests.
 junit_tests(
     name = "findowners_IT_tests",
     srcs = glob(["src/test/java/**/*IT.java"]),
-    shard_count = 4,
-    deps = FIND_OWNERS_IT_TESTS_DEPS + FIND_OWNERS_TESTS_DEPS,
+    tags = ["findowners"],
+    deps = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
+        "@commons-io//jar",
+        ":find-owners-IT",
+        ":find-owners-junit",
+        ":find-owners-lib",
+        ":find-owners-prolog-rules",
+        ":find-owners__plugin",
+    ],
 )
diff --git a/src/test/java/com/googlesource/gerrit/plugins/findowners/ApiIT.java b/src/test/java/com/googlesource/gerrit/plugins/findowners/ApiIT.java
index e050a8e..d6d039e 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/findowners/ApiIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/findowners/ApiIT.java
@@ -46,10 +46,12 @@
     ChangeInfo info2 = newChangeInfo("test2 GetOwners");
     assertThat(info2._number).isEqualTo(info1._number + 1);
     String expected =
-        ")]}' { addDebugMsg:false, maxCacheAge:0, maxCacheSize:1000,"
-            + " minOwnerVoteLevel:1, ownersFileName:OWNERS, rejectErrorInOwners:false,"
-            + (" change:" + info1._number)
-            + ", patchset:1, file2owners:{}, reviewers:[], owners:[], files:[] }";
+        ")]}' {addDebugMsg:false,maxCacheAge:0,maxCacheSize:1000,"
+            + "minOwnerVoteLevel:1,ownersFileName:OWNERS,rejectErrorInOwners:false,"
+            + ("change:" + info1._number)
+            + ",patchset:1,"
+            + ("owner_revision:" + projectOperations.project(project).getHead(info1.branch).name())
+            + ",file2owners:{},reviewers:[],owners:[],files:[]}";
     Cache cache = getCache().init(0, 10); // reset, no Cache
     assertThat(cache.size()).isEqualTo(0L);
     // GetOwners GET API
@@ -67,11 +69,11 @@
   @Test
   public void requestErrorTest() throws Exception {
     PushOneCommit.Result c1 = createChange("1", "t.c", "##");
-    assertThat(getOwnersResponse(c1)).contains("owners:[], files:[ t.c ]");
+    assertThat(getOwnersResponse(c1)).contains("owners:[],files:[t.c]");
     int id = c1.getChange().getId().get();
     // Correct change id.
     String result = userRestSession.get("/changes/" + id + "/owners").getEntityContent();
-    assertThat(filteredJson(result)).contains("owners:[], files:[ t.c ]");
+    assertThat(filteredJson(result)).contains("owners:[],files:[t.c]");
     // Wrong change number, 404 not found.
     RestResponse response = userRestSession.get("/changes/" + (id + 1) + "/owners");
     assertThat(response.getStatusCode()).isEqualTo(404);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/findowners/ConfigIT.java b/src/test/java/com/googlesource/gerrit/plugins/findowners/ConfigIT.java
index 425fc9a..643d50b 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/findowners/ConfigIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/findowners/ConfigIT.java
@@ -88,20 +88,20 @@
     String cXResponse = getOwnersDebugResponse(cX);
     String cBResponse = getOwnersDebugResponse(cB);
     String cYResponse = getOwnersDebugResponse(cY);
-    assertThat(cAResponse).contains(ownerX + ", files:[ tA.c ]");
-    assertThat(cBResponse).contains(ownerY + ", files:[ tB.c ]");
-    assertThat(cXResponse).contains(", files:[ tX.c ]");
-    assertThat(cYResponse).contains(", files:[ tY.c ]");
+    assertThat(cAResponse).contains(ownerX + ",files:[tA.c]");
+    assertThat(cBResponse).contains(ownerY + ",files:[tB.c]");
+    assertThat(cXResponse).contains(",files:[tX.c]");
+    assertThat(cYResponse).contains(",files:[tY.c]");
     assertThat(cXResponse).doesNotContain(ownerX);
     assertThat(cYResponse).doesNotContain(ownerY);
     assertThat(cAResponse).contains("branch:refs/heads/master");
     assertThat(cBResponse).contains("branch:refs/heads/master");
     assertThat(cXResponse).contains("branch:refs/heads/BranchX");
     assertThat(cYResponse).contains("branch:refs/heads/BranchY");
-    assertThat(cAResponse).contains("ownersFileName:OWNERS, ");
-    assertThat(cBResponse).contains("ownersFileName:OWNERS, ");
-    assertThat(cXResponse).contains("ownersFileName:OWNERS, ");
-    assertThat(cYResponse).contains("ownersFileName:OWNERS, ");
+    assertThat(cAResponse).contains("ownersFileName:OWNERS,");
+    assertThat(cBResponse).contains("ownersFileName:OWNERS,");
+    assertThat(cXResponse).contains("ownersFileName:OWNERS,");
+    assertThat(cYResponse).contains("ownersFileName:OWNERS,");
 
     // pA and pB use default OWNERS file name.
     // cA and cB logs should not contain anything about Missing/Found root.
@@ -126,12 +126,12 @@
     cBResponse = getOwnersDebugResponse(cB);
     cXResponse = getOwnersDebugResponse(cX);
     cYResponse = getOwnersDebugResponse(cY);
-    assertThat(cAResponse).contains("ownersFileName:OWNERS.alpha, ");
-    assertThat(cBResponse).contains("ownersFileName:OWNERS.beta, ");
-    assertThat(cXResponse).contains("ownersFileName:OWNERS.alpha, ");
-    assertThat(cYResponse).contains("ownersFileName:OWNERS.beta, ");
-    assertThat(cAResponse).contains(ownerA + ", files:[ tA.c ]");
-    assertThat(cBResponse).contains(ownerB + ", files:[ tB.c ]");
+    assertThat(cAResponse).contains("ownersFileName:OWNERS.alpha,");
+    assertThat(cBResponse).contains("ownersFileName:OWNERS.beta,");
+    assertThat(cXResponse).contains("ownersFileName:OWNERS.alpha,");
+    assertThat(cYResponse).contains("ownersFileName:OWNERS.beta,");
+    assertThat(cAResponse).contains(ownerA + ",files:[tA.c]");
+    assertThat(cBResponse).contains(ownerB + ",files:[tB.c]");
     // pA and pB now use non-default OWNERS file name.
     // cA and cB logs should contain "Found root ..."
     assertThat(cAResponse).contains("FoundrootOWNERS.alpha");
@@ -145,10 +145,10 @@
     setProjectConfig("ownersFileName", "MAINTAINERS");
     cAResponse = getOwnersDebugResponse(cA);
     cXResponse = getOwnersDebugResponse(cX);
-    assertThat(cAResponse).contains("ownersFileName:MAINTAINERS, ");
-    assertThat(cXResponse).contains("ownersFileName:MAINTAINERS, ");
-    assertThat(cAResponse).contains("owners:[], ");
-    assertThat(cXResponse).contains("owners:[], ");
+    assertThat(cAResponse).contains("ownersFileName:MAINTAINERS,");
+    assertThat(cXResponse).contains("ownersFileName:MAINTAINERS,");
+    assertThat(cAResponse).contains("owners:[],");
+    assertThat(cXResponse).contains("owners:[],");
     assertThat(cAResponse).contains("MissingrootMAINTAINERS");
     // Gerrit server log file should contain: "Missing root MAINTAINERS for change "
     // cX is not on the master branch, so we do not check for the root owners file.
@@ -160,8 +160,8 @@
     assertThat(projectOwnersFileName(pA)).isEqualTo("OWNERS");
     cAResponse = getOwnersDebugResponse(cA);
     cBResponse = getOwnersDebugResponse(cB);
-    assertThat(cAResponse).contains(ownerX + ", files:[ tA.c ]");
-    assertThat(cBResponse).contains(ownerB + ", files:[ tB.c ]");
+    assertThat(cAResponse).contains(ownerX + ",files:[tA.c]");
+    assertThat(cBResponse).contains(ownerB + ",files:[tB.c]");
 
     // Change back to OWNERS.alpha in Project_B, but there is no OWNERS.alpha
     switchProject(pB);
@@ -170,10 +170,10 @@
     cAResponse = getOwnersDebugResponse(cA);
     cBResponse = getOwnersDebugResponse(cB);
     cYResponse = getOwnersDebugResponse(cY);
-    assertThat(cAResponse).contains("ownersFileName:OWNERS, ");
-    assertThat(cBResponse).contains("ownersFileName:OWNERS.alpha, ");
-    assertThat(cAResponse).contains(ownerX + ", files:[ tA.c ]");
-    assertThat(cBResponse).contains("owners:[], files:[ tB.c ]");
+    assertThat(cAResponse).contains("ownersFileName:OWNERS,");
+    assertThat(cBResponse).contains("ownersFileName:OWNERS.alpha,");
+    assertThat(cAResponse).contains(ownerX + ",files:[tA.c]");
+    assertThat(cBResponse).contains("owners:[],files:[tB.c]");
     assertThat(cBResponse).contains("MissingrootOWNERS.alpha");
     // Gerrit server log file should contain: "Missing root OWNERS.alpha for change "
     assertThat(cYResponse).doesNotContain("root");
@@ -192,8 +192,8 @@
     RestResponse response = adminRestSession.get("/projects/?d");
     String content = response.getEntityContent();
     // Predefined projects: "All-Projects", "All-Users", project
-    assertThat(content).contains("\"id\": \"All-Projects\",");
-    assertThat(content).contains("\"id\": \"All-Users\",");
+    assertThat(content).contains("\"id\":\"All-Projects\",");
+    assertThat(content).contains("\"id\":\"All-Users\",");
     assertThat(content).contains(idProject("projectTest", "project"));
     assertThat(content).doesNotContain(idProject("projectTest", "ProjectA"));
     assertThat(content).doesNotContain(idProject("ProjectA"));
diff --git a/src/test/java/com/googlesource/gerrit/plugins/findowners/FindOwners.java b/src/test/java/com/googlesource/gerrit/plugins/findowners/FindOwners.java
index 2ad1e67..8f5ee7a 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/findowners/FindOwners.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/findowners/FindOwners.java
@@ -64,15 +64,15 @@
   }
 
   protected String oneOwnerList(String email) {
-    return "owners:[ " + ownerJson(email) + " ]";
+    return "owners:[" + ownerJson(email) + "]";
   }
 
   protected String ownerJson(String email) {
-    return "{ email:" + email + ", weights:[ 1, 0, 0 ] }";
+    return "{email:" + email + ",weights:[1,0,0]}";
   }
 
   protected String ownerJson(String email, int w1, int w2, int w3) {
-    return "{ email:" + email + ", weights:[ " + w1 + ", " + w2 + ", " + w3 + " ] }";
+    return "{email:" + email + ",weights:[" + w1 + "," + w2 + "," + w3 + "]}";
   }
 
   protected ChangeInfo newChangeInfo(String subject) throws Exception {
@@ -226,7 +226,7 @@
 
   protected String idProject(String name) {
     // Expected string of "id": "name",,
-    return "\"id\": \"" + name + "\",";
+    return "\"id\":\"" + name + "\",";
   }
 
   protected static void verifyRestResult(
diff --git a/src/test/java/com/googlesource/gerrit/plugins/findowners/IncludeIT.java b/src/test/java/com/googlesource/gerrit/plugins/findowners/IncludeIT.java
index 9401fb2..53bc4f3 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/findowners/IncludeIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/findowners/IncludeIT.java
@@ -30,7 +30,7 @@
   @Rule public Watcher watcher = new Watcher(logger);
 
   private static String getRepoFileLog(String msg1, String msg2) {
-    return "getRepoFile:" + msg1 + ", getFile:" + msg2 + ", ";
+    return "getRepoFile:" + msg1 + ",getFile:" + msg2 + ",";
   }
 
   private static String concat(String s1, String s2) {
@@ -46,45 +46,45 @@
     // c2 and c1 are both submitted before existence of OWNERS.
     PushOneCommit.Result c2 = addFile("1", "t.c", "##");
     // Submitted c2 still finds no owners before c1 is submitted.
-    assertThat(getOwnersResponse(c2)).contains("owners:[], files:[ t.c ]");
+    assertThat(getOwnersResponse(c2)).contains("owners:[],files:[t.c]");
     PushOneCommit.Result c1 =
         addFile("2", "OWNERS", "x@x\na@a\ninclude  P1/P2 : f1\ninclude ./d1/d2/../../f2\n");
     // Now c2 should find owners, but include directives find no repository or file.
-    String ownersAX = "owners:[ " + ownerJson("a@a") + ", " + ownerJson("x@x") + " ]";
-    String path2owners = "path2owners:{ ./:[ a@a, x@x ] }";
-    String owner2paths = "owner2paths:{ a@a:[ ./ ], x@x:[ ./ ] }";
+    String ownersAX = "owners:[" + ownerJson("a@a") + "," + ownerJson("x@x") + "]";
+    String path2owners = "path2owners:{./:[a@a,x@x]}";
+    String owner2paths = "owner2paths:{a@a:[./],x@x:[./]}";
     String projectName = project.get();
     String expectedInLog =
-        concat("project:", projectName, ", ")
-            + "ownersFileName:OWNERS, "
-            + "getBranchId:refs/heads/master(FOUND), "
-            + "findOwnersFileFor:./t.c, "
-            + "findOwnersFileIn:., "
+        concat("project:", projectName, ",")
+            + "ownersFileName:OWNERS,"
+            + "getBranchId:refs/heads/master(FOUND),"
+            + "findOwnersFileFor:./t.c,"
+            + "findOwnersFileIn:.,"
             + getRepoFileLog(projectName + ":refs/heads/master:./OWNERS", "OWNERS:(...)")
-            + "parseLine:include:P1/P2:f1, "
-            + "getRepoFile:P1/P2:refs/heads/master:f1, "
-            + "hasReadAccessException:project'P1/P2'isunavailable, " // cannot read
-            + "parseLine:include:(), " // missing file is treated as empty
-            + concat("parseLine:include:", projectName, ":./d1/d2/../../f2, ")
+            + "parseLine:include:P1/P2:f1,"
+            + "getRepoFile:P1/P2:refs/heads/master:f1,"
+            + "hasReadAccessException:project'P1/P2'isunavailable," // cannot read
+            + "parseLine:include:()," // missing file is treated as empty
+            + concat("parseLine:include:", projectName, ":./d1/d2/../../f2,")
             + getRepoFileLog(projectName + ":refs/heads/master:f2", "f2(NOTFOUND)")
-            + "parseLine:include:(), " // missing file is treated as empty
-            + "countNumOwners, "
-            + "findOwners, "
-            + "checkFile:./t.c, "
-            + "checkDir:., "
-            + "addOwnerWeightsIn:./ "
-            + "] ";
+            + "parseLine:include:()," // missing file is treated as empty
+            + "countNumOwners,"
+            + "findOwners,"
+            + "checkFile:./t.c,"
+            + "checkDir:.,"
+            + "addOwnerWeightsIn:./"
+            + "]";
     String c2Response = getOwnersDebugResponse(c2);
     assertThat(c2Response).contains(path2owners);
     assertThat(c2Response).contains(owner2paths);
-    assertThat(c2Response).contains("file2owners:{ ./t.c:[ a@a, x@x ] }");
+    assertThat(c2Response).contains("file2owners:{./t.c:[a@a,x@x]}");
     assertThat(c2Response).contains(ownersAX);
     assertThat(c2Response).contains(expectedInLog);
     // A submitted change gets owners info from current repository.
     String c1Response = getOwnersDebugResponse(c1);
     assertThat(c1Response).contains(path2owners);
     assertThat(c1Response).contains(owner2paths);
-    assertThat(c1Response).contains("file2owners:{ ./OWNERS:[ a@a, x@x ] }");
+    assertThat(c1Response).contains("file2owners:{./OWNERS:[a@a,x@x]}");
     assertThat(c1Response).contains(ownersAX);
   }
 
@@ -100,41 +100,40 @@
     String ownerX = ownerJson("x@x");
     String ownerG1 = ownerJson("g1@g");
     String ownerG2 = ownerJson("g2@g");
-    String ownersAG1G2X =
-        "owners:[ " + ownerA + ", " + ownerG1 + ", " + ownerG2 + ", " + ownerX + " ]";
-    String path2owners = "path2owners:{ ./:[ a@a, g1@g, g2@g, x@x ] }";
-    String owner2paths = "owner2paths:{ a@a:[ ./ ], g1@g:[ ./ ], g2@g:[ ./ ], x@x:[ ./ ] }";
+    String ownersAG1G2X = "owners:[" + ownerA + "," + ownerG1 + "," + ownerG2 + "," + ownerX + "]";
+    String path2owners = "path2owners:{./:[a@a,g1@g,g2@g,x@x]}";
+    String owner2paths = "owner2paths:{a@a:[./],g1@g:[./],g2@g:[./],x@x:[./]}";
     String projectName = project.get();
     String expectedInLog =
-        concat("project:", projectName, ", ")
-            + "ownersFileName:OWNERS, "
-            + "getBranchId:refs/heads/master(FOUND), "
-            + "findOwnersFileFor:./t.c, "
-            + "findOwnersFileIn:., "
+        concat("project:", projectName, ",")
+            + "ownersFileName:OWNERS,"
+            + "getBranchId:refs/heads/master(FOUND),"
+            + "findOwnersFileFor:./t.c,"
+            + "findOwnersFileIn:.,"
             + getRepoFileLog(projectName + ":refs/heads/master:./OWNERS", "OWNERS:(...)")
-            + "parseLine:include:P1/P2:f1, "
-            + "getRepoFile:P1/P2:refs/heads/master:f1, "
-            + "hasReadAccessException:project'P1/P2'isunavailable, "
-            + "parseLine:include:(), " // P1/P2 is still not found
-            + concat("parseLine:include:", projectName, ":./d1/d2/../../f2, ")
+            + "parseLine:include:P1/P2:f1,"
+            + "getRepoFile:P1/P2:refs/heads/master:f1,"
+            + "hasReadAccessException:project'P1/P2'isunavailable,"
+            + "parseLine:include:()," // P1/P2 is still not found
+            + concat("parseLine:include:", projectName, ":./d1/d2/../../f2,")
             + getRepoFileLog(projectName + ":refs/heads/master:f2", "f2:(...)")
-            + "countNumOwners, "
-            + "findOwners, "
-            + "checkFile:./t.c, "
-            + "checkDir:., "
-            + "addOwnerWeightsIn:./ "
-            + "] ";
+            + "countNumOwners,"
+            + "findOwners,"
+            + "checkFile:./t.c,"
+            + "checkDir:.,"
+            + "addOwnerWeightsIn:./"
+            + "]";
     String c2Response = getOwnersDebugResponse(c2);
     assertThat(c2Response).contains(path2owners);
     assertThat(c2Response).contains(owner2paths);
-    assertThat(c2Response).contains("file2owners:{ ./t.c:[ a@a, g1@g, g2@g, x@x ] }");
+    assertThat(c2Response).contains("file2owners:{./t.c:[a@a,g1@g,g2@g,x@x]}");
     assertThat(c2Response).contains(ownersAG1G2X);
     assertThat(c2Response).contains(expectedInLog);
     // A submitted change gets owners info from current repository.
     String c1Response = getOwnersDebugResponse(c1);
     assertThat(c1Response).contains(path2owners);
     assertThat(c1Response).contains(owner2paths);
-    assertThat(c1Response).contains("file2owners:{ ./OWNERS:[ a@a, g1@g, g2@g, x@x ] }");
+    assertThat(c1Response).contains("file2owners:{./OWNERS:[a@a,g1@g,g2@g,x@x]}");
     assertThat(c1Response).contains(ownersAG1G2X);
   }
 
@@ -159,11 +158,11 @@
     String ownerX = ownerJson("x@g", 0, 1, 0);
     assertThat(getOwnersResponse(c1))
         .contains(
-            "owners:[ "
-                + concat(ownerD2, ", ")
-                + concat(ownerF2, ", ")
-                + concat(ownerD3, ", ")
-                + concat(ownerX, " ], files:[ d3/t.c ]"));
+            "owners:["
+                + concat(ownerD2, ",")
+                + concat(ownerF2, ",")
+                + concat(ownerD3, ",")
+                + concat(ownerX, "],files:[d3/t.c]"));
   }
 
   @Test
@@ -193,15 +192,14 @@
     PushOneCommit.Result c22 = createChange("c22", "d3/d2/d2/t.c", "test");
 
     // file and file
-    String owners11 = "file2owners:{ ./d3/d1/d1/t.c:" + "[ d1d1@g, d1d1d1@g, d3@g, d3d1d1@g ] }";
+    String owners11 = "file2owners:{./d3/d1/d1/t.c:" + "[d1d1@g,d1d1d1@g,d3@g,d3d1d1@g]}";
     // file and include
-    String owners12 = "file2owners:{ ./d3/d1/d2/t.c:" + "[ d1d2@g, d1d2d1@g, d3@g, d3d1d2@g ] }";
+    String owners12 = "file2owners:{./d3/d1/d2/t.c:" + "[d1d2@g,d1d2d1@g,d3@g,d3d1d2@g]}";
     // include and file
-    String owners21 =
-        "file2owners:{ ./d3/d2/d1/t.c:" + "[ d2d1@g, d2d1d1@g, d2d1p@g, d3@g, d3d2d1@g ] }";
+    String owners21 = "file2owners:{./d3/d2/d1/t.c:" + "[d2d1@g,d2d1d1@g,d2d1p@g,d3@g,d3d2d1@g]}";
     // include and include
     String owners22 =
-        "file2owners:{ ./d3/d2/d2/t.c:" + "[ d2d2@g, d2d2d1@g, d2d2d1p@g, d2d2p@g, d3d2d2@g ] }";
+        "file2owners:{./d3/d2/d2/t.c:" + "[d2d2@g,d2d2d1@g,d2d2d1p@g,d2d2p@g,d3d2d2@g]}";
 
     assertThat(getOwnersDebugResponse(c11)).contains(owners11);
     assertThat(getOwnersDebugResponse(c12)).contains(owners12);
@@ -218,8 +216,8 @@
     PushOneCommit.Result c1 = createChange("c1", "d2/d1/t.c", "test");
     PushOneCommit.Result c2 = createChange("c2", "d2/d2/t.c", "test");
     String projectName = project.get();
-    String log1 = "parseLine:useSaved:file:" + projectName + "://d1/OWNERS, ";
-    String log2 = "parseLine:useSaved:include:" + projectName + ":/d1/OWNERS, ";
+    String log1 = "parseLine:useSaved:file:" + projectName + "://d1/OWNERS,";
+    String log2 = "parseLine:useSaved:include:" + projectName + ":/d1/OWNERS,";
     String response1 = getOwnersDebugResponse(c1);
     String response2 = getOwnersDebugResponse(c2);
     assertThat(response1).contains(log1);
@@ -241,30 +239,29 @@
     String response = getOwnersDebugResponse(c);
     String projectName = project.get();
     String expectedInLog =
-        concat("project:", projectName, ", ")
-            + "ownersFileName:OWNERS, "
-            + "getBranchId:refs/heads/master(FOUND), "
-            + "findOwnersFileFor:./t.c, "
-            + "findOwnersFileIn:., "
+        concat("project:", projectName, ",")
+            + "ownersFileName:OWNERS,"
+            + "getBranchId:refs/heads/master(FOUND),"
+            + "findOwnersFileFor:./t.c,"
+            + "findOwnersFileIn:.,"
             + getRepoFileLog(projectName + ":refs/heads/master:./OWNERS", "OWNERS:(...)")
-            + concat("parseLine:include:", projectName, ":./d1/../f1, ")
+            + concat("parseLine:include:", projectName, ":./d1/../f1,")
             + getRepoFileLog(projectName + ":refs/heads/master:f1", "f1:(...)")
-            + concat("parseLine:include:", projectName, ":./f2, ")
+            + concat("parseLine:include:", projectName, ":./f2,")
             + getRepoFileLog(projectName + ":refs/heads/master:f2", "f2:(...)")
-            + concat("parseLine:include:", projectName, ":d1/../f3, ")
+            + concat("parseLine:include:", projectName, ":d1/../f3,")
             + getRepoFileLog(projectName + ":refs/heads/master:f3", "f3:(...)")
-            + concat("parseLine:include:", projectName, ":/f4, ")
+            + concat("parseLine:include:", projectName, ":/f4,")
             + getRepoFileLog(projectName + ":refs/heads/master:f4", "f4:(...)")
-            + concat("parseLine:errorRecursion:include:", projectName, ":d2/../f2, ")
-            + "countNumOwners, "
-            + "findOwners, "
-            + "checkFile:./t.c, "
-            + "checkDir:., "
-            + "addOwnerWeightsIn:./ "
-            + "] ";
-    assertThat(response).contains("path2owners:{ ./:[ f1@g, f2@g, f3@g, f4@g, x@g ] }");
-    assertThat(response)
-        .contains("owner2paths:{ f1@g:[ ./ ], f2@g:[ ./ ], f3@g:[ ./ ], f4@g:[ ./ ], x@g:[ ./ ] }");
+            + concat("parseLine:errorRecursion:include:", projectName, ":d2/../f2,")
+            + "countNumOwners,"
+            + "findOwners,"
+            + "checkFile:./t.c,"
+            + "checkDir:.,"
+            + "addOwnerWeightsIn:./"
+            + "]";
+    assertThat(response).contains("path2owners:{./:[f1@g,f2@g,f3@g,f4@g,x@g]}");
+    assertThat(response).contains("owner2paths:{f1@g:[./],f2@g:[./],f3@g:[./],f4@g:[./],x@g:[./]}");
     assertThat(response).contains(expectedInLog);
   }
 
@@ -286,46 +283,46 @@
             "f6@g\ninclude /d0/f0\ninclude ../d1/d2/f1\n"
                 + "include ../d2/f2\ninclude /d2/d3/f3\ninclude /d2/../d4/d5/f5\ninclude /d4/f4\n");
     String result = getOwnersDebugResponse(c);
-    assertThat(result).contains("{ ./d6/OWNERS:[ f0@g, f1@g, f2@g, f3@g, f4@g, f5@g, f6@g ] }");
+    assertThat(result).contains("{./d6/OWNERS:[f0@g,f1@g,f2@g,f3@g,f4@g,f5@g,f6@g]}");
     String projectName = project.get();
     String skipLog = "parseLine:useSaved:include:" + projectName + ":";
     for (String path : new String[] {"../../d0/f0", "../d0/f0", "../d2/f2", "/d2/f2", "/d4/f4"}) {
       assertThat(result).contains(skipLog + path);
     }
     String expectedInLog =
-        concat("project:", projectName, ", ")
-            + "ownersFileName:OWNERS, "
-            + "getBranchId:refs/heads/master(FOUND), "
-            + "findOwnersFileFor:./d6/OWNERS, "
-            + "findOwnersFileIn:./d6, "
+        concat("project:", projectName, ",")
+            + "ownersFileName:OWNERS,"
+            + "getBranchId:refs/heads/master(FOUND),"
+            + "findOwnersFileFor:./d6/OWNERS,"
+            + "findOwnersFileIn:./d6,"
             + getRepoFileLog(projectName + ":refs/heads/master:./d6/OWNERS", "d6/OWNERS:(...)")
-            + concat("parseLine:include:", projectName, ":/d0/f0, ")
+            + concat("parseLine:include:", projectName, ":/d0/f0,")
             + getRepoFileLog(projectName + ":refs/heads/master:d0/f0", "d0/f0:(...)")
-            + concat("parseLine:include:", projectName, ":../d1/d2/f1, ")
+            + concat("parseLine:include:", projectName, ":../d1/d2/f1,")
             + getRepoFileLog(projectName + ":refs/heads/master:d1/d2/f1", "d1/d2/f1:(...)")
-            + concat("parseLine:useSaved:include:", projectName, ":../../d0/f0, ")
-            + concat("parseLine:include:", projectName, ":../d2/f2, ")
+            + concat("parseLine:useSaved:include:", projectName, ":../../d0/f0,")
+            + concat("parseLine:include:", projectName, ":../d2/f2,")
             + getRepoFileLog(projectName + ":refs/heads/master:d2/f2", "d2/f2:(...)")
-            + concat("parseLine:useSaved:include:", projectName, ":../d0/f0, ")
-            + concat("parseLine:include:", projectName, ":/d2/d3/f3, ")
+            + concat("parseLine:useSaved:include:", projectName, ":../d0/f0,")
+            + concat("parseLine:include:", projectName, ":/d2/d3/f3,")
             + getRepoFileLog(projectName + ":refs/heads/master:d2/d3/f3", "d2/d3/f3:(...)")
-            + concat("parseLine:useSaved:include:", projectName, ":/d0/f0, ")
-            + concat("parseLine:include:", projectName, ":/d2/../d4/d5/f5, ")
+            + concat("parseLine:useSaved:include:", projectName, ":/d0/f0,")
+            + concat("parseLine:include:", projectName, ":/d2/../d4/d5/f5,")
             + getRepoFileLog(projectName + ":refs/heads/master:d4/d5/f5", "d4/d5/f5:(...)")
-            + concat("parseLine:useSaved:include:", projectName, ":/d2/f2, ")
-            + concat("parseLine:include:", projectName, ":../f4, ")
+            + concat("parseLine:useSaved:include:", projectName, ":/d2/f2,")
+            + concat("parseLine:include:", projectName, ":../f4,")
             + getRepoFileLog(projectName + ":refs/heads/master:d4/f4", "d4/f4:(...)")
-            + concat("parseLine:useSaved:include:", projectName, ":../d2/f2, ")
-            + concat("parseLine:useSaved:include:", projectName, ":/d4/f4, ")
-            + "findOwnersFileIn:., "
+            + concat("parseLine:useSaved:include:", projectName, ":../d2/f2,")
+            + concat("parseLine:useSaved:include:", projectName, ":/d4/f4,")
+            + "findOwnersFileIn:.,"
             + getRepoFileLog(projectName + ":refs/heads/master:./OWNERS", "OWNERS(NOTFOUND)")
-            + "countNumOwners, "
-            + "findOwners, "
-            + "checkFile:./d6/OWNERS, "
-            + "checkDir:./d6, "
-            + "checkDir:., "
-            + "addOwnerWeightsIn:./d6/ "
-            + "] ";
+            + "countNumOwners,"
+            + "findOwners,"
+            + "checkFile:./d6/OWNERS,"
+            + "checkDir:./d6,"
+            + "checkDir:.,"
+            + "addOwnerWeightsIn:./d6/"
+            + "]";
     assertThat(result).contains(expectedInLog);
   }
 
@@ -351,14 +348,14 @@
     // included: pA:d2/OWNERS, pA:d2/../f1, pA:d1/f1, pB:d2/f2, pB:d2/../f1, pB:./d1/f1
     // inherited: pA:OWNERS
     String owners =
-        "owners:[ "
-            + concat(ownerJson("pAd1f1@g"), ", ")
-            + concat(ownerJson("pAd2@g"), ", ")
-            + concat(ownerJson("pAf1@g"), ", ")
-            + concat(ownerJson("pBd1f1@g"), ", ")
-            + concat(ownerJson("pBd2f2@g"), ", ")
-            + concat(ownerJson("pBf1@g"), ", ")
-            + concat(ownerJson("pA@g", 0, 1, 0), " ]");
+        "owners:["
+            + concat(ownerJson("pAd1f1@g"), ",")
+            + concat(ownerJson("pAd2@g"), ",")
+            + concat(ownerJson("pAf1@g"), ",")
+            + concat(ownerJson("pBd1f1@g"), ",")
+            + concat(ownerJson("pBd2f2@g"), ",")
+            + concat(ownerJson("pBf1@g"), ",")
+            + concat(ownerJson("pA@g", 0, 1, 0), "]");
     assertThat(getOwnersResponse(c1)).contains(owners);
   }
 
@@ -386,11 +383,11 @@
     // inherited: pA:OWNERS
     // pB's OWNERS files are not readable
     String owners =
-        "owners:[ "
-            + concat(ownerJson("pAd1f1@g"), ", ")
-            + concat(ownerJson("pAd2@g"), ", ")
-            + concat(ownerJson("pAf1@g"), ", ")
-            + concat(ownerJson("pA@g", 0, 1, 0), " ]");
+        "owners:["
+            + concat(ownerJson("pAd1f1@g"), ",")
+            + concat(ownerJson("pAd2@g"), ",")
+            + concat(ownerJson("pAf1@g"), ",")
+            + concat(ownerJson("pA@g", 0, 1, 0), "]");
     // The "owners:[...]" substring contains only owners from pA.
     assertThat(getOwnersResponse(c1)).contains(owners);
   }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/findowners/InheritanceIT.java b/src/test/java/com/googlesource/gerrit/plugins/findowners/InheritanceIT.java
index 9adb4f9..ab87398 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/findowners/InheritanceIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/findowners/InheritanceIT.java
@@ -42,10 +42,10 @@
         addFile("4", "d2/OWNERS", "d2@g\nper-file OWNERS=d2o@g\nper-file *S=set  noparent \n");
     // Files that match per-file globs with set noparent do not inherit global default owners.
     // But include directive can include more per-file owners as in c3.
-    assertThat(getOwnersResponse(c1)).contains("{ ./d1/d1/OWNERS:[ d1d1o@g ] }");
-    assertThat(getOwnersResponse(c2)).contains("{ ./d1/OWNERS:[ d1o@g ] }");
-    assertThat(getOwnersResponse(c3)).contains("{ ./d2/d1/OWNERS:[ d1d1o@g, d2d1o@g ] }");
-    assertThat(getOwnersResponse(c4)).contains("{ ./d2/OWNERS:[ d2o@g ] }");
+    assertThat(getOwnersResponse(c1)).contains("{./d1/d1/OWNERS:[d1d1o@g]}");
+    assertThat(getOwnersResponse(c2)).contains("{./d1/OWNERS:[d1o@g]}");
+    assertThat(getOwnersResponse(c3)).contains("{./d2/d1/OWNERS:[d1d1o@g,d2d1o@g]}");
+    assertThat(getOwnersResponse(c4)).contains("{./d2/OWNERS:[d2o@g]}");
   }
 
   @Test
@@ -58,15 +58,15 @@
     PushOneCommit.Result c5 = addFile("5", "d2/d2/OWNERS", "d2d2@g\ninclude ../../d1/d2/OWNERS");
     PushOneCommit.Result c6 = addFile("6", "d2/OWNERS", "d2@g\n");
     // d1/d1/OWNERS sets noparent, does not inherit d1/OWNERS
-    assertThat(getOwnersResponse(c1)).contains("{ ./d1/d1/OWNERS:[ d1d1@g ] }");
+    assertThat(getOwnersResponse(c1)).contains("{./d1/d1/OWNERS:[d1d1@g]}");
     // d1/d2/OWNERS inherits d1/OWNERS
-    assertThat(getOwnersResponse(c2)).contains("{ ./d1/d2/OWNERS:[ d1@g, d1d2@g ] }");
-    assertThat(getOwnersResponse(c3)).contains("{ ./d1/OWNERS:[ d1@g ] }");
+    assertThat(getOwnersResponse(c2)).contains("{./d1/d2/OWNERS:[d1@g,d1d2@g]}");
+    assertThat(getOwnersResponse(c3)).contains("{./d1/OWNERS:[d1@g]}");
     // d2/d1/OWNERS includes d1/d1/OWNERS, does not inherit d1/OWNERS or d2/OWNERS
-    assertThat(getOwnersResponse(c4)).contains("{ ./d2/d1/OWNERS:[ d1d1@g, d2d1@g ] }");
+    assertThat(getOwnersResponse(c4)).contains("{./d2/d1/OWNERS:[d1d1@g,d2d1@g]}");
     // d2/d2/OWNERS includes d1/d1/OWNERS, inherit d2/OWNERS but not d1/OWNERS
-    assertThat(getOwnersResponse(c5)).contains("{ ./d2/d2/OWNERS:[ d1d2@g, d2@g, d2d2@g ] }");
-    assertThat(getOwnersResponse(c6)).contains("{ ./d2/OWNERS:[ d2@g ] }");
+    assertThat(getOwnersResponse(c5)).contains("{./d2/d2/OWNERS:[d1d2@g,d2@g,d2d2@g]}");
+    assertThat(getOwnersResponse(c6)).contains("{./d2/OWNERS:[d2@g]}");
   }
 
   @Test
@@ -81,32 +81,32 @@
     PushOneCommit.Result c2 = createChange("c2", "t.c", "Hello!");
     String ownerA = ownerJson("a@a");
     String ownerX = ownerJson("x@x");
-    assertThat(getOwnersResponse(c2)).contains("owners:[ " + ownerX + " ], files:[ t.c ]");
+    assertThat(getOwnersResponse(c2)).contains("owners:[" + ownerX + "],files:[t.c]");
     // Add "d1/t.c" file, which is owned by ./d1 and root owners.
     PushOneCommit.Result c3 = createChange("c3", "d1/t.c", "Hello!");
     String ownerX010 = ownerJson("x@x", 0, 1, 0);
     assertThat(getOwnersResponse(c3))
-        .contains("owners:[ " + ownerA + ", " + ownerX010 + " ], files:[ d1/t.c ]");
+        .contains("owners:[" + ownerA + "," + ownerX010 + "],files:[d1/t.c]");
     // Add "d2/t.c" file, which is owned by ./d2 and root owners.
     PushOneCommit.Result c4 = createChange("c4", "d2/t.c", "Hello!");
     String ownerY = ownerJson("y@y");
     assertThat(getOwnersResponse(c4))
-        .contains("owners:[ " + ownerY + ", " + ownerX010 + " ], files:[ d2/t.c ]");
+        .contains("owners:[" + ownerY + "," + ownerX010 + "],files:[d2/t.c]");
     // Add "d2/d1/t.c" file, which is owned by ./d2 and root owners.
     PushOneCommit.Result c5 = createChange("c5", "d2/d1/t.c", "Hello!");
     assertThat(getOwnersResponse(c5))
-        .contains("owners:[ " + ownerY + ", " + ownerX010 + " ], files:[ d2/d1/t.c ]");
+        .contains("owners:[" + ownerY + "," + ownerX010 + "],files:[d2/d1/t.c]");
     // Add "d3/t.c" file, which is owned only by ./d3 owners due to "set noparent".
     PushOneCommit.Result c6 = createChange("c6", "d3/t.c", "Hello!");
     String ownerB = ownerJson("b@b");
-    assertThat(getOwnersResponse(c6)).contains("owners:[ " + ownerB + " ], files:[ d3/t.c ]");
+    assertThat(getOwnersResponse(c6)).contains("owners:[" + ownerB + "],files:[d3/t.c]");
     // Add "d3/d1/t.c" file, which is owned only by ./d3 owners due to "set noparent".
     PushOneCommit.Result c7 = createChange("c7", "d3/d1/t.c", "Hello!");
-    assertThat(getOwnersResponse(c7)).contains("owners:[ " + ownerB + " ], files:[ d3/d1/t.c ]");
+    assertThat(getOwnersResponse(c7)).contains("owners:[" + ownerB + "],files:[d3/d1/t.c]");
     // Add "d4/t.c" file, which is owned by ./d4 and ./d2 owners, but not root owners.
     PushOneCommit.Result c8 = createChange("c8", "d4/t.c", "Hello!");
     String ownerZ = ownerJson("z@z");
     assertThat(getOwnersResponse(c8))
-        .contains("owners:[ " + ownerY + ", " + ownerZ + ", " + ownerX010 + " ], files:[ d4/t.c ]");
+        .contains("owners:[" + ownerY + "," + ownerZ + "," + ownerX010 + "],files:[d4/t.c]");
   }
 }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/findowners/PerFileIT.java b/src/test/java/com/googlesource/gerrit/plugins/findowners/PerFileIT.java
index 26fc914..d0fc00b 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/findowners/PerFileIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/findowners/PerFileIT.java
@@ -36,12 +36,12 @@
     String ownerA = ownerJson("a@a");
     String ownerB = ownerJson("b@b");
     String ownerC = ownerJson("c@c");
-    String ownerABC = "owners:[ " + ownerA + ", " + ownerB + ", " + ownerC;
+    String ownerABC = "owners:[" + ownerA + "," + ownerB + "," + ownerC;
     String ownerX = ownerJson("x@x");
-    assertThat(getOwnersResponse(c2)).contains(ownerABC + ", " + ownerX + " ], files:[ t.c ]");
+    assertThat(getOwnersResponse(c2)).contains(ownerABC + "," + ownerX + "],files:[t.c]");
     // Add "t.txt" file, which has only global default owners.
     PushOneCommit.Result c3 = createChange("3", "t.txt", "Test!");
-    assertThat(getOwnersResponse(c3)).contains(ownerABC + " ], files:[ t.txt ]");
+    assertThat(getOwnersResponse(c3)).contains(ownerABC + "],files:[t.txt]");
   }
 
   @Test
@@ -54,8 +54,8 @@
     PushOneCommit.Result c2 = createChange("c2", "t.c", "test");
     String c1Response = getOwnersDebugResponse(c1);
     String c2Response = getOwnersDebugResponse(c2);
-    assertThat(c1Response).contains("file2owners:{ ./x.c:[ a@a, x@x ] }");
-    assertThat(c2Response).contains("file2owners:{ ./t.c:[ *, a@a, m2@g, m@g, t1@g, x@x ] }");
+    assertThat(c1Response).contains("file2owners:{./x.c:[a@a,x@x]}");
+    assertThat(c2Response).contains("file2owners:{./t.c:[*,a@a,m2@g,m@g,t1@g,x@x]}");
   }
 
   @Test
@@ -66,11 +66,10 @@
     PushOneCommit.Result c3 = addFile("3", "d2/d1/OWNERS", "d2d1@g\ninclude ../../d1/d1/OWNERS\n");
     PushOneCommit.Result c4 = addFile("4", "d2/OWNERS", "d2@g\nper-file OWNERS=d2o@g");
     // Files that match per-file globs now inherit global default owners.
-    assertThat(getOwnersResponse(c1))
-        .contains("{ ./d1/d1/OWNERS:[ d1@g, d1d1@g, d1d1o@g, d1o@g ] }");
-    assertThat(getOwnersResponse(c2)).contains("{ ./d1/OWNERS:[ d1@g, d1o@g ] }");
+    assertThat(getOwnersResponse(c1)).contains("{./d1/d1/OWNERS:[d1@g,d1d1@g,d1d1o@g,d1o@g]}");
+    assertThat(getOwnersResponse(c2)).contains("{./d1/OWNERS:[d1@g,d1o@g]}");
     assertThat(getOwnersResponse(c3))
-        .contains("{ ./d2/d1/OWNERS:[ d1d1@g, d1d1o@g, d2@g, d2d1@g, d2o@g ] }");
-    assertThat(getOwnersResponse(c4)).contains("{ ./d2/OWNERS:[ d2@g, d2o@g ] }");
+        .contains("{./d2/d1/OWNERS:[d1d1@g,d1d1o@g,d2@g,d2d1@g,d2o@g]}");
+    assertThat(getOwnersResponse(c4)).contains("{./d2/OWNERS:[d2@g,d2o@g]}");
   }
 }