-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass a valid dir to MavenMojoProjectParser
Fixes openrewrite/rewrite#3593
- Loading branch information
Showing
1 changed file
with
5 additions
and
8 deletions.
There are no files selected for viewing
13 changes: 5 additions & 8 deletions
13
src/test/java/org/openrewrite/maven/MavenMojoProjectParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | ||
} | ||
} | ||
} |