TestPathExpressions: Match file types in all subfolders

Since change I049316068 the matchFileTypeInCurrentFolder method cannot
be implemented for the FindOwnersGlobMatcher anymore (because all globs
are prefixed with "{**/,}"). Change the method to match file types in
all subfolders instead. This doesn't make a difference to any of the
tests that are using this method.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I3645f46ec5dc43893840d7c264e91358e6f1e899
diff --git a/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestPathExpressions.java b/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestPathExpressions.java
index 91867cb..d2acaed 100644
--- a/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestPathExpressions.java
+++ b/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestPathExpressions.java
@@ -41,16 +41,20 @@
   }
 
   /**
-   * Creates a path expression that matches all files of the given file type in the current folder.
+   * Creates a path expression that matches all files of the given file type in the current folder
+   * and all subfolders.
    *
    * @param fileType the file type
    */
-  public String matchFileTypeInCurrentFolder(String fileType) {
+  public String matchFileType(String fileType) {
     PathExpressionMatcher pathExpressionMatcher = getPathExpressionMatcher();
-    if (pathExpressionMatcher instanceof GlobMatcher
-        || pathExpressionMatcher instanceof FindOwnersGlobMatcher
-        || pathExpressionMatcher instanceof SimplePathExpressionMatcher) {
+    if (pathExpressionMatcher instanceof GlobMatcher) {
+      return "**." + fileType;
+    } else if (pathExpressionMatcher instanceof FindOwnersGlobMatcher) {
       return "*." + fileType;
+    } else if (pathExpressionMatcher instanceof SimplePathExpressionMatcher) {
+      // '...' (matches any string, including slashes), followed by '.<file-type>'
+      return "...." + fileType;
     }
     throw new IllegalStateException(
         String.format(
diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/AbstractGetCodeOwnersForPathIT.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/AbstractGetCodeOwnersForPathIT.java
index d7d3da3..0826b9e 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/AbstractGetCodeOwnersForPathIT.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/AbstractGetCodeOwnersForPathIT.java
@@ -226,12 +226,12 @@
         .folderPath("/foo/bar/")
         .addCodeOwnerSet(
             CodeOwnerSet.builder()
-                .addPathExpression(testPathExpressions.matchFileTypeInCurrentFolder("txt"))
+                .addPathExpression(testPathExpressions.matchFileType("txt"))
                 .addCodeOwnerEmail(admin.email())
                 .build())
         .addCodeOwnerSet(
             CodeOwnerSet.builder()
-                .addPathExpression(testPathExpressions.matchFileTypeInCurrentFolder("md"))
+                .addPathExpression(testPathExpressions.matchFileType("md"))
                 .addCodeOwnerEmail(user.email())
                 .build())
         .create();
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigHierarchyTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigHierarchyTest.java
index a99de99..4df0138 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigHierarchyTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigHierarchyTest.java
@@ -540,7 +540,7 @@
             .addCodeOwnerSet(
                 CodeOwnerSet.builder()
                     .setIgnoreGlobalAndParentCodeOwners()
-                    .addPathExpression(testPathExpressions.matchFileTypeInCurrentFolder("txt"))
+                    .addPathExpression(testPathExpressions.matchFileType("txt"))
                     .addCodeOwnerEmail(admin.email())
                     .build())
             .create();