Skip to content

Commit 10aa070

Browse files
Change testMatcher from data-centric to code-centric
(it still does the same thing)
1 parent 998ae3d commit 10aa070

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemTest.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.google.cloud.storage.contrib.nio;
1818

1919
import static com.google.common.truth.Truth.assertThat;
20-
import static com.google.common.truth.Truth.assertWithMessage;
2120
import static java.nio.charset.StandardCharsets.UTF_8;
2221

2322
import com.google.cloud.storage.StorageOptions;
@@ -166,18 +165,23 @@ public void testListFiles() throws IOException {
166165
@Test
167166
public void testMatcher() throws IOException {
168167
try (FileSystem fs = CloudStorageFileSystem.forBucket("bucket")) {
169-
List<String> paths = ImmutableList.of("a.java", "a.text", "folder/c.java", "d");
170168
String pattern1 = "glob:*.java";
171169
PathMatcher matcher1 = fs.getPathMatcher(pattern1);
172-
List<Boolean> matches1 = ImmutableList.of(true, false, true, false);
173170
String pattern2 = "glob:*.{java,text}";
174171
PathMatcher matcher2 = fs.getPathMatcher(pattern2);
175-
List<Boolean> matches2 = ImmutableList.of(true, true, true, false);
176-
for (int i=0; i<paths.size(); i++) {
177-
Path input = fs.getPath(paths.get(i)).getFileName();
178-
assertWithMessage(pattern1 + " on " + paths.get(i)).that(matcher1.matches(input)).isEqualTo(matches1.get(i));
179-
assertWithMessage(pattern2 + " on " + paths.get(i)).that(matcher2.matches(input)).isEqualTo(matches2.get(i));
180-
}
172+
173+
assertMatches(fs, matcher1, "a.java", true);
174+
assertMatches(fs, matcher1, "a.text", false);
175+
assertMatches(fs, matcher1, "folder/c.java", true);
176+
assertMatches(fs, matcher1, "d", false);
177+
assertMatches(fs, matcher2, "a.java", true);
178+
assertMatches(fs, matcher2, "a.text", true);
179+
assertMatches(fs, matcher2, "folder/c.java", true);
180+
assertMatches(fs, matcher2, "d", false);
181181
}
182182
}
183+
184+
private void assertMatches(FileSystem fs, PathMatcher matcher, String toMatch, boolean expected) {
185+
assertThat(matcher.matches(fs.getPath(toMatch).getFileName())).isEqualTo(expected);
186+
}
183187
}

0 commit comments

Comments
 (0)