|
32 | 32 |
|
33 | 33 | import org.assertj.core.internal.PathsBaseTest;
|
34 | 34 | import org.junit.jupiter.api.Test;
|
| 35 | +import org.junit.jupiter.params.ParameterizedTest; |
| 36 | +import org.junit.jupiter.params.provider.ValueSource; |
35 | 37 |
|
36 | 38 | /**
|
37 | 39 | * @author Valeriy Vyrva
|
@@ -108,27 +110,55 @@ void should_fail_if_actual_is_empty() throws IOException {
|
108 | 110 | then(error).hasMessage(directoryShouldContain(actual, emptyList(), "the 'glob:**' pattern").create());
|
109 | 111 | }
|
110 | 112 |
|
111 |
| - @Test |
112 |
| - void should_pass_if_actual_contains_at_least_one_path_matching_the_given_pattern() throws IOException { |
| 113 | + @ParameterizedTest |
| 114 | + @ValueSource(strings = { |
| 115 | + "glob:**file", |
| 116 | +// "glob:file", // fails due to gh-2329 |
| 117 | + "regex:.*file", |
| 118 | +// "regex:file", // fails due to gh-2329 |
| 119 | + }) |
| 120 | + void should_pass_if_actual_directly_contains_any_entries_matching_the_given_pattern(String syntaxAndPattern) throws IOException { |
113 | 121 | // GIVEN
|
114 | 122 | Path actual = createDirectory(tempDir.resolve("actual"));
|
115 |
| - createFile(actual.resolve("file")); |
116 | 123 | createDirectory(actual.resolve("directory"));
|
117 |
| - String syntaxAndPattern = "glob:**file"; |
| 124 | + createFile(actual.resolve("file")); |
118 | 125 | // WHEN/THEN
|
119 | 126 | paths.assertIsDirectoryContaining(info, actual, syntaxAndPattern);
|
120 | 127 | }
|
121 | 128 |
|
122 |
| - @Test |
123 |
| - void should_fail_if_actual_does_not_contain_any_paths_matching_the_given_pattern() throws IOException { |
| 129 | + @ParameterizedTest |
| 130 | + @ValueSource(strings = { |
| 131 | + "glob:**file", |
| 132 | + "glob:file", |
| 133 | + "regex:.*file", |
| 134 | + "regex:file", |
| 135 | + }) |
| 136 | + void should_fail_if_actual_does_not_contain_any_entries_matching_the_given_pattern(String syntaxAndPattern) throws IOException { |
| 137 | + // GIVEN |
| 138 | + Path actual = createDirectory(tempDir.resolve("actual")); |
| 139 | + Path directory = createDirectory(actual.resolve("directory")); |
| 140 | + // WHEN |
| 141 | + AssertionError error = expectAssertionError(() -> paths.assertIsDirectoryContaining(info, actual, syntaxAndPattern)); |
| 142 | + // THEN |
| 143 | + then(error).hasMessage(directoryShouldContain(actual, list(directory), "the '" + syntaxAndPattern + "' pattern").create()); |
| 144 | + } |
| 145 | + |
| 146 | + @ParameterizedTest |
| 147 | + @ValueSource(strings = { |
| 148 | + "glob:**file", |
| 149 | + "glob:file", |
| 150 | + "regex:.*file", |
| 151 | + "regex:file", |
| 152 | + }) |
| 153 | + void should_fail_if_actual_recursively_contains_any_entries_matching_the_given_pattern(String syntaxAndPattern) throws IOException { |
124 | 154 | // GIVEN
|
125 | 155 | Path actual = createDirectory(tempDir.resolve("actual"));
|
126 | 156 | Path directory = createDirectory(actual.resolve("directory"));
|
127 |
| - String syntaxAndPattern = "glob:**file"; |
| 157 | + createFile(directory.resolve("file")); |
128 | 158 | // WHEN
|
129 | 159 | AssertionError error = expectAssertionError(() -> paths.assertIsDirectoryContaining(info, actual, syntaxAndPattern));
|
130 | 160 | // THEN
|
131 |
| - then(error).hasMessage(directoryShouldContain(actual, list(directory), "the 'glob:**file' pattern").create()); |
| 161 | + then(error).hasMessage(directoryShouldContain(actual, list(directory), "the '" + syntaxAndPattern + "' pattern").create()); |
132 | 162 | }
|
133 | 163 |
|
134 | 164 | }
|
0 commit comments