Skip to content

Commit dcd99ce

Browse files
committed
[java] Removing usages of deprecated methods in Require.java
1 parent 2b32dbd commit dcd99ce

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

java/test/org/openqa/selenium/RequireTest.java

+16-16
Original file line numberDiff line numberDiff line change
@@ -189,40 +189,40 @@ void canCheckIntegerArgumentWithCheckerObject() {
189189
@Test
190190
void canCheckFileArgument() throws IOException {
191191
assertThatExceptionOfType(IllegalArgumentException.class)
192-
.isThrownBy(() -> Require.argument("Target", (File) null).isFile())
192+
.isThrownBy(() -> Require.argument("Target", (Path) null).isFile())
193193
.withMessage("Target must be set");
194194
File tempFile = File.createTempFile("example", "tmp");
195195
tempFile.deleteOnExit();
196-
assertThat(Require.argument("Target", tempFile).isFile()).isSameAs(tempFile);
196+
assertThat(Require.argument("Target", tempFile.toPath()).isFile()).isSameAs(tempFile.toPath());
197197
File dir = tempFile.getParentFile();
198198
assertThatExceptionOfType(IllegalArgumentException.class)
199-
.isThrownBy(() -> Require.argument("Target", dir).isFile())
199+
.isThrownBy(() -> Require.argument("Target", dir.toPath()).isFile())
200200
.withMessage("Target must be a regular file: %s", dir);
201201
if (!tempFile.delete()) {
202202
fail("Unable to delete temp file");
203203
}
204204
assertThatExceptionOfType(IllegalArgumentException.class)
205-
.isThrownBy(() -> Require.argument("Target", tempFile).isFile())
205+
.isThrownBy(() -> Require.argument("Target", tempFile.toPath()).isFile())
206206
.withMessage("Target must exist: %s", tempFile);
207207
}
208208

209209
@Test
210210
void canCheckDirectoryArgument() throws IOException {
211211
assertThatExceptionOfType(IllegalArgumentException.class)
212-
.isThrownBy(() -> Require.argument("Target", (File) null).isDirectory())
212+
.isThrownBy(() -> Require.argument("Target", (Path) null).isDirectory())
213213
.withMessage("Target must be set");
214214
File tempFile = File.createTempFile("example", "tmp");
215215
tempFile.deleteOnExit();
216216
assertThatExceptionOfType(IllegalArgumentException.class)
217-
.isThrownBy(() -> Require.argument("Target", tempFile).isDirectory())
217+
.isThrownBy(() -> Require.argument("Target", tempFile.toPath()).isDirectory())
218218
.withMessage("Target must be a directory: %s", tempFile);
219219
File dir = tempFile.getParentFile();
220-
assertThat(Require.argument("Target", dir).isDirectory()).isSameAs(dir);
220+
assertThat(Require.argument("Target", dir.toPath()).isDirectory()).isSameAs(dir.toPath());
221221
if (!tempFile.delete()) {
222222
fail("Unable to delete temp file");
223223
}
224224
assertThatExceptionOfType(IllegalArgumentException.class)
225-
.isThrownBy(() -> Require.argument("Target", tempFile).isDirectory())
225+
.isThrownBy(() -> Require.argument("Target", tempFile.toPath()).isDirectory())
226226
.withMessage("Target must exist: %s", tempFile);
227227
}
228228

@@ -264,40 +264,40 @@ void canCheckStateClass() {
264264
@Test
265265
void canCheckFileState() throws IOException {
266266
assertThatExceptionOfType(IllegalStateException.class)
267-
.isThrownBy(() -> Require.state("Target", (File) null).isFile())
267+
.isThrownBy(() -> Require.state("Target", (Path) null).isFile())
268268
.withMessage("Target must be set");
269269
File tempFile = File.createTempFile("example", "tmp");
270270
tempFile.deleteOnExit();
271-
assertThat(Require.state("Target", tempFile).isFile()).isSameAs(tempFile);
271+
assertThat(Require.state("Target", tempFile.toPath()).isFile()).isSameAs(tempFile.toPath());
272272
File dir = tempFile.getParentFile();
273273
assertThatExceptionOfType(IllegalStateException.class)
274-
.isThrownBy(() -> Require.state("Target", dir).isFile())
274+
.isThrownBy(() -> Require.state("Target", dir.toPath()).isFile())
275275
.withMessage("Target must be a regular file: %s", dir);
276276
if (!tempFile.delete()) {
277277
fail("Unable to delete temp file");
278278
}
279279
assertThatExceptionOfType(IllegalStateException.class)
280-
.isThrownBy(() -> Require.state("Target", tempFile).isFile())
280+
.isThrownBy(() -> Require.state("Target", tempFile.toPath()).isFile())
281281
.withMessage("Target must exist: %s", tempFile);
282282
}
283283

284284
@Test
285285
void canCheckDirectoryState() throws IOException {
286286
assertThatExceptionOfType(IllegalStateException.class)
287-
.isThrownBy(() -> Require.state("Target", (File) null).isDirectory())
287+
.isThrownBy(() -> Require.state("Target", (Path) null).isDirectory())
288288
.withMessage("Target must be set");
289289
File tempFile = File.createTempFile("example", "tmp");
290290
tempFile.deleteOnExit();
291291
assertThatExceptionOfType(IllegalStateException.class)
292-
.isThrownBy(() -> Require.state("Target", tempFile).isDirectory())
292+
.isThrownBy(() -> Require.state("Target", tempFile.toPath()).isDirectory())
293293
.withMessage("Target must be a directory: %s", tempFile);
294294
File dir = tempFile.getParentFile();
295-
assertThat(Require.state("Target", dir).isDirectory()).isSameAs(dir);
295+
assertThat(Require.state("Target", dir.toPath()).isDirectory()).isSameAs(dir.toPath());
296296
if (!tempFile.delete()) {
297297
fail("Unable to delete temp file");
298298
}
299299
assertThatExceptionOfType(IllegalStateException.class)
300-
.isThrownBy(() -> Require.state("Target", tempFile).isDirectory())
300+
.isThrownBy(() -> Require.state("Target", tempFile.toPath()).isDirectory())
301301
.withMessage("Target must exist: %s", tempFile);
302302
}
303303

0 commit comments

Comments
 (0)