Skip to content

Commit

Permalink
Simplify Maven.readModel usage in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
murdos authored and gastaldi committed Feb 26, 2024
1 parent 194fbcf commit 3c239ab
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/test/java/io/fabric8/maven/MavenTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
Expand Down

0 comments on commit 3c239ab

Please sign in to comment.