Skip to content

Commit

Permalink
bump OR version
Browse files Browse the repository at this point in the history
downgrade rewrite-maven-plugin
  • Loading branch information
fabapp2 committed Nov 21, 2023
1 parent 990d0dd commit e3b15f4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
4 changes: 2 additions & 2 deletions sbm-support-rewrite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-boot.version>3.1.3</spring-boot.version>
<rewrite.version>8.9.4</rewrite.version>
<rewrite-maven-plugin.version>5.13.0</rewrite-maven-plugin.version>
<rewrite.version>8.9.5</rewrite.version>
<rewrite-maven-plugin.version>5.3.2</rewrite-maven-plugin.version>
<maven.version>3.9.1</maven.version>
<maven-resolver.version>1.9.13</maven-resolver.version>
<maven-wagon-http.version>3.5.3</maven-wagon-http.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void parseResources() {
void parse4Modules() {
Path baseDir = TestProjectHelper.getMavenProject("4-modules");
ParserParityTestHelper.scanProjectDir(baseDir)
.parseSequentially()
.verifyParity((comparingParsingResult, testedParsingResult) -> {
assertThat(comparingParsingResult.sourceFiles()).hasSize(4);
assertThat(testedParsingResult.sourceFiles()).hasSize(4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -93,7 +94,7 @@ void testMavenMojoProjectParserGenerateProvenance() {
// and assert markers
int numExpectedMarkers = 5;

if(System.getenv("GITHUB_ACTION_REF") != null) {
if (System.getenv("GITHUB_ACTION_REF") != null) {
numExpectedMarkers = 6; // CI marker
}
assertThat(markers).hasSize(numExpectedMarkers);
Expand Down Expand Up @@ -123,7 +124,18 @@ void testMavenMojoProjectParserGenerateProvenance() {
String gitHash = getCurrentGitHash();
GitProvenance expectedGitProvenance = GitProvenance.fromProjectDirectory(baseDir, BuildEnvironment.build(System::getenv));
GitProvenance gitProvenance = findMarker(markers, GitProvenance.class);
assertThat(countGetters(gitProvenance)).isEqualTo(9);
assertThat(getGetterNames(gitProvenance)).containsExactlyInAnyOrder(
"getId()",
"getBranch()",
"getEol()",
"getOrigin()",
"getAutocrlf()",
"getRepositoryName()",
"getChange()",
"getOrganizationName(java.lang.String)",
"getOrganizationName()",
"getCommitters()"
);
assertThat(gitProvenance.getId()).isInstanceOf(UUID.class);
assertThat(gitProvenance.getBranch()).isEqualTo(branch);
assertThat(gitProvenance.getEol()).isEqualTo(GitProvenance.EOL.Native);
Expand All @@ -133,6 +145,7 @@ void testMavenMojoProjectParserGenerateProvenance() {
assertThat(gitProvenance.getChange()).isEqualTo(gitHash);
assertThat(gitProvenance.getOrganizationName()).isEqualTo("spring-projects-experimental");
assertThat(gitProvenance.getOrganizationName("https://github.com")).isEqualTo("spring-projects-experimental");
assertThat(gitProvenance.getCommitters().stream().map(c -> c.getName()).toList()).contains("Fabian Krüger");

OperatingSystemProvenance operatingSystemProvenance = findMarker(markers, OperatingSystemProvenance.class);
OperatingSystemProvenance expected = OperatingSystemProvenance.current();
Expand All @@ -152,17 +165,17 @@ void testMavenMojoProjectParserGenerateProvenance() {
private <T extends Marker> T findMarker(List<Marker> markers, Class<T> markerClass) {
return (T) markers.stream().filter(m -> markerClass.isAssignableFrom(m.getClass())).findFirst().orElseThrow();
}
}


}


@Nested
public class GivenSimpleMultiModuleProject {


@Test
@DisplayName("Should Create Provenance Markers")
void shouldCreateProvenanceMarkers() {
void shouldCreateProvenanceMarkers() {

// The MavenMojoProjectParserFactory creates an instance of OpenRewrite's MavenMojoProjectParser
// We provide a mock, there's a test for MavenMojoProjectParser
Expand Down Expand Up @@ -202,13 +215,11 @@ void shouldCreateProvenanceMarkers() {
// assertThat(resourceListMap.get(path2)).isEqualTo(markers2);
}

/**
* With a configured maven-compile-plugin the source and target version should be taken from the plugin
*/
@Nested
public class GivenSimpleMultiModuleProjectWithCompilerPlugin {

}

}

private void verifyMarkers(Resource resource, Path baseDir, Map<Path, List<Marker>> resourceListMap, String projectName, String groupId, String artifactModule, String version) {
Expand All @@ -225,7 +236,10 @@ private void verifyMarkers(Resource resource, Path baseDir, Map<Path, List<Marke
assertThat(jv.getId()).isInstanceOf(UUID.class);

JavaProject jp = findMarker(resourceListMap, resource, JavaProject.class);
assertThat(countGetters(jp)).isEqualTo(3);
assertThat(getGetterNames(jp)).containsExactly(
"getId",
"getProjectName"
);
assertThat(jp.getId()).isInstanceOf(UUID.class);
assertThat(jp.getProjectName()).isEqualTo(projectName);
JavaProject.Publication publication = jp.getPublication();
Expand Down Expand Up @@ -294,6 +308,17 @@ private long countGetters(Object marker) {
.count();
}

/**
* With a configured maven-compile-plugin the source and target version should be taken from the plugin
*/
private static List<String> getGetterNames(Object marker) {
return getGetter(marker).map(m -> m.getName() + "(" + renderArgs(m) + ")").toList();
}

private static String renderArgs(Method m) {
return Arrays.stream(m.getParameters()).map(p -> p.getType().getName()).collect(Collectors.joining(", "));
}

@NotNull
private static Stream<Method> getGetter(Object marker) {
return Arrays
Expand Down Expand Up @@ -326,6 +351,7 @@ private <T> T findMarker(Map<Path, List<Marker>> markedResources, Resource pom,

public static class MyLogger implements Log {


@Override
public boolean isDebugEnabled() {
return false;
Expand Down

0 comments on commit e3b15f4

Please sign in to comment.