From 3c239ab4becd0d3c358f7d4eba9306f5f3ee1c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Sat, 24 Feb 2024 11:48:49 +0100 Subject: [PATCH] Simplify Maven.readModel usage in tests --- src/test/java/io/fabric8/maven/MavenTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/java/io/fabric8/maven/MavenTest.java b/src/test/java/io/fabric8/maven/MavenTest.java index 9a6382a..1fecb7e 100644 --- a/src/test/java/io/fabric8/maven/MavenTest.java +++ b/src/test/java/io/fabric8/maven/MavenTest.java @@ -49,7 +49,7 @@ void should_read_model_using_reader() { @Test void should_read_model_string() { Path basePom = Paths.get("pom.xml"); - Model model = Maven.readModel(basePom.toAbsolutePath().toString()); + Model model = Maven.readModel(basePom); Assertions.assertThat(model).isNotNull(); assertThat(model.getPomFile().getAbsolutePath()).isEqualTo(basePom.toAbsolutePath().toString()); assertThat(model.getParent().getGroupId()).isEqualTo("org.jboss"); @@ -72,7 +72,7 @@ void should_write_model(@TempDir Path tempDir) throws IOException { @Test void should_write_model_with_sorted_properties(@TempDir Path tempDir) throws IOException { Path basePom = Paths.get("pom.xml"); - Model model = Maven.readModel(basePom.toAbsolutePath().toString()); + Model model = Maven.readModel(basePom); Properties properties = model.getProperties(); assertThat(properties).isInstanceOf(SortedProperties.class); @@ -91,7 +91,7 @@ void should_write_model_with_sorted_properties(@TempDir Path tempDir) throws IOE @Test void should_write_model_with_sorted_properties_using_reader(@TempDir Path tempDir) throws IOException { Path basePom = Paths.get("pom.xml"); - Model model = Maven.readModel(new FileReader(basePom.toFile())); + Model model = Maven.readModel(basePom); Properties properties = model.getProperties(); assertThat(properties).isInstanceOf(SortedProperties.class); @@ -126,7 +126,7 @@ void should_preserve_parent_relative_path(@TempDir Path tempDir) throws Exceptio void should_save_full_pom_on_new_file(@TempDir Path tempDir) throws Exception { URL resource = getClass().getResource("full-pom.xml"); Path basePom = Paths.get(resource.toURI()); - Model model = Maven.readModel(new FileReader(basePom.toFile())); + Model model = Maven.readModel(basePom); Path newPom = tempDir.resolve("new-pom.xml"); Maven.writeModel(model, newPom); @@ -138,7 +138,7 @@ void should_save_full_pom_on_new_file(@TempDir Path tempDir) throws Exception { void should_save_full_pom_on_updated_full_file(@TempDir Path tempDir) throws Exception { URL resource = getClass().getResource("full-pom.xml"); Path basePom = Paths.get(resource.toURI()); - Model model = Maven.readModel(new FileReader(basePom.toFile())); + Model model = Maven.readModel(basePom); Path updatedPom = tempDir.resolve("updated-full-pom.xml"); Files.copy(basePom, updatedPom); @@ -151,7 +151,7 @@ void should_save_full_pom_on_updated_full_file(@TempDir Path tempDir) throws Exc void should_save_full_pom_on_updated_minimal_file(@TempDir Path tempDir) throws Exception { URL resource = getClass().getResource("full-pom.xml"); Path basePom = Paths.get(resource.toURI()); - Model model = Maven.readModel(new FileReader(basePom.toFile())); + Model model = Maven.readModel(basePom); Path updatedPom = tempDir.resolve("updated-minimal-pom.xml"); Files.writeString(updatedPom, "\n" +