From dcd99ce83a3b50f23602e1c7d091752587f52a12 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Wed, 26 Jun 2024 15:19:57 +0200 Subject: [PATCH] [java] Removing usages of deprecated methods in Require.java --- .../test/org/openqa/selenium/RequireTest.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/java/test/org/openqa/selenium/RequireTest.java b/java/test/org/openqa/selenium/RequireTest.java index 4300bd8708a1e..a3db623d279d3 100644 --- a/java/test/org/openqa/selenium/RequireTest.java +++ b/java/test/org/openqa/selenium/RequireTest.java @@ -189,40 +189,40 @@ void canCheckIntegerArgumentWithCheckerObject() { @Test void canCheckFileArgument() throws IOException { assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> Require.argument("Target", (File) null).isFile()) + .isThrownBy(() -> Require.argument("Target", (Path) null).isFile()) .withMessage("Target must be set"); File tempFile = File.createTempFile("example", "tmp"); tempFile.deleteOnExit(); - assertThat(Require.argument("Target", tempFile).isFile()).isSameAs(tempFile); + assertThat(Require.argument("Target", tempFile.toPath()).isFile()).isSameAs(tempFile.toPath()); File dir = tempFile.getParentFile(); assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> Require.argument("Target", dir).isFile()) + .isThrownBy(() -> Require.argument("Target", dir.toPath()).isFile()) .withMessage("Target must be a regular file: %s", dir); if (!tempFile.delete()) { fail("Unable to delete temp file"); } assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> Require.argument("Target", tempFile).isFile()) + .isThrownBy(() -> Require.argument("Target", tempFile.toPath()).isFile()) .withMessage("Target must exist: %s", tempFile); } @Test void canCheckDirectoryArgument() throws IOException { assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> Require.argument("Target", (File) null).isDirectory()) + .isThrownBy(() -> Require.argument("Target", (Path) null).isDirectory()) .withMessage("Target must be set"); File tempFile = File.createTempFile("example", "tmp"); tempFile.deleteOnExit(); assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> Require.argument("Target", tempFile).isDirectory()) + .isThrownBy(() -> Require.argument("Target", tempFile.toPath()).isDirectory()) .withMessage("Target must be a directory: %s", tempFile); File dir = tempFile.getParentFile(); - assertThat(Require.argument("Target", dir).isDirectory()).isSameAs(dir); + assertThat(Require.argument("Target", dir.toPath()).isDirectory()).isSameAs(dir.toPath()); if (!tempFile.delete()) { fail("Unable to delete temp file"); } assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> Require.argument("Target", tempFile).isDirectory()) + .isThrownBy(() -> Require.argument("Target", tempFile.toPath()).isDirectory()) .withMessage("Target must exist: %s", tempFile); } @@ -264,40 +264,40 @@ void canCheckStateClass() { @Test void canCheckFileState() throws IOException { assertThatExceptionOfType(IllegalStateException.class) - .isThrownBy(() -> Require.state("Target", (File) null).isFile()) + .isThrownBy(() -> Require.state("Target", (Path) null).isFile()) .withMessage("Target must be set"); File tempFile = File.createTempFile("example", "tmp"); tempFile.deleteOnExit(); - assertThat(Require.state("Target", tempFile).isFile()).isSameAs(tempFile); + assertThat(Require.state("Target", tempFile.toPath()).isFile()).isSameAs(tempFile.toPath()); File dir = tempFile.getParentFile(); assertThatExceptionOfType(IllegalStateException.class) - .isThrownBy(() -> Require.state("Target", dir).isFile()) + .isThrownBy(() -> Require.state("Target", dir.toPath()).isFile()) .withMessage("Target must be a regular file: %s", dir); if (!tempFile.delete()) { fail("Unable to delete temp file"); } assertThatExceptionOfType(IllegalStateException.class) - .isThrownBy(() -> Require.state("Target", tempFile).isFile()) + .isThrownBy(() -> Require.state("Target", tempFile.toPath()).isFile()) .withMessage("Target must exist: %s", tempFile); } @Test void canCheckDirectoryState() throws IOException { assertThatExceptionOfType(IllegalStateException.class) - .isThrownBy(() -> Require.state("Target", (File) null).isDirectory()) + .isThrownBy(() -> Require.state("Target", (Path) null).isDirectory()) .withMessage("Target must be set"); File tempFile = File.createTempFile("example", "tmp"); tempFile.deleteOnExit(); assertThatExceptionOfType(IllegalStateException.class) - .isThrownBy(() -> Require.state("Target", tempFile).isDirectory()) + .isThrownBy(() -> Require.state("Target", tempFile.toPath()).isDirectory()) .withMessage("Target must be a directory: %s", tempFile); File dir = tempFile.getParentFile(); - assertThat(Require.state("Target", dir).isDirectory()).isSameAs(dir); + assertThat(Require.state("Target", dir.toPath()).isDirectory()).isSameAs(dir.toPath()); if (!tempFile.delete()) { fail("Unable to delete temp file"); } assertThatExceptionOfType(IllegalStateException.class) - .isThrownBy(() -> Require.state("Target", tempFile).isDirectory()) + .isThrownBy(() -> Require.state("Target", tempFile.toPath()).isDirectory()) .withMessage("Target must exist: %s", tempFile); }