Skip to content

Commit

Permalink
Pass a valid dir to MavenMojoProjectParser
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Oct 1, 2023
1 parent a6cf839 commit e379464
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
package org.openrewrite.maven;

import it.unimi.dsi.fastutil.ints.IntSets;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.logging.SystemStreamLog;
import org.apache.maven.project.MavenProject;
import org.apache.maven.rtinfo.internal.DefaultRuntimeInformation;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.openrewrite.java.marker.JavaVersion;
import org.openrewrite.marker.Marker;

import java.util.Collection;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Set;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;

/**
* @author Fabian Krüger
*/
class MavenMojoProjectParserTest {
@Test
@DisplayName("Given No Java version information exists in Maven Then java.specification.version should be used")
void givenNoJavaVersionInformationExistsInMavenThenJavaSpecificationVersionShouldBeUsed() {
MavenMojoProjectParser sut = new MavenMojoProjectParser(new SystemStreamLog(), null, false, null, new DefaultRuntimeInformation(), false, Collections.EMPTY_LIST, Collections.EMPTY_LIST, -1, null, null, false);
void givenNoJavaVersionInformationExistsInMavenThenJavaSpecificationVersionShouldBeUsed(@TempDir Path dir) {
MavenMojoProjectParser sut = new MavenMojoProjectParser(new SystemStreamLog(), dir, false, null, new DefaultRuntimeInformation(), false, Collections.EMPTY_LIST, Collections.EMPTY_LIST, -1, null, null, false);
List<Marker> markers = sut.generateProvenance(new MavenProject());
JavaVersion marker = markers.stream().filter(JavaVersion.class::isInstance).map(JavaVersion.class::cast).findFirst().get();
assertThat(marker.getSourceCompatibility()).isEqualTo(System.getProperty("java.specification.version"));
assertThat(marker.getTargetCompatibility()).isEqualTo(System.getProperty("java.specification.version"));
}
}
}

0 comments on commit e379464

Please sign in to comment.