Skip to content

Commit 144b91d

Browse files
committed
Parser parity test (#984)
- Introduce `ParserParityTestHelper` which takes a dir and parses the given project with `RewriteMavenProjectParser` (comparing) and `RewritePropjectParser` (system under test). The parsing result is then compared using AssertJ's `usingRecursiveComparison` which verifies that all markers and their fields of both parsing results are equal proving that both parsers yield the same result. - Introduce ´TestProjectHelper` which helps set up test projects. - Fixes multiple bugs, e.g. calculation of the classpath. - Cleanups and refactorings
1 parent fece721 commit 144b91d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/RewriteProjectParserParityTest.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@
1616
package org.springframework.sbm.parsers;
1717

1818
import org.intellij.lang.annotations.Language;
19-
import org.junit.jupiter.api.BeforeEach;
19+
import org.jetbrains.annotations.NotNull;
2020
import org.junit.jupiter.api.Disabled;
2121
import org.junit.jupiter.api.DisplayName;
2222
import org.junit.jupiter.api.Test;
2323
import org.junit.jupiter.api.io.TempDir;
2424
import org.junitpioneer.jupiter.Issue;
25-
import org.mockito.Mockito;
2625
import org.openrewrite.ExecutionContext;
2726
import org.openrewrite.InMemoryExecutionContext;
2827
import org.openrewrite.Parser;
2928
import org.openrewrite.SourceFile;
29+
import org.openrewrite.java.JavaParser;
30+
import org.openrewrite.java.internal.JavaTypeCache;
3031
import org.openrewrite.java.marker.JavaProject;
3132
import org.openrewrite.java.marker.JavaSourceSet;
3233
import org.openrewrite.java.marker.JavaVersion;
@@ -40,15 +41,11 @@
4041
import org.openrewrite.maven.MavenSettings;
4142
import org.openrewrite.maven.cache.CompositeMavenPomCache;
4243
import org.openrewrite.maven.tree.MavenResolutionResult;
43-
import org.openrewrite.shaded.jgit.api.Git;
4444
import org.openrewrite.shaded.jgit.api.errors.GitAPIException;
4545
import org.openrewrite.tree.ParsingEventListener;
4646
import org.openrewrite.tree.ParsingExecutionContextView;
4747
import org.openrewrite.xml.style.Autodetect;
4848
import org.openrewrite.xml.tree.Xml;
49-
import org.sonatype.plexus.components.cipher.DefaultPlexusCipher;
50-
import org.sonatype.plexus.components.cipher.PlexusCipherException;
51-
import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher;
5249
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
5350
import org.springframework.context.ApplicationEventPublisher;
5451
import org.springframework.core.io.DefaultResourceLoader;
@@ -58,10 +55,9 @@
5855
import org.springframework.sbm.parsers.events.RewriteParsingEventListenerAdapter;
5956
import org.springframework.sbm.scopes.ScanScope;
6057
import org.springframework.sbm.test.util.DummyResource;
61-
import org.springframework.sbm.utils.ResourceUtil;
58+
import org.springframework.sbm.test.util.ParserParityTestHelper;
6259
import org.springframework.test.util.ReflectionTestUtils;
6360

64-
import java.io.File;
6561
import java.nio.charset.Charset;
6662
import java.nio.file.Path;
6763
import java.time.Duration;
@@ -77,6 +73,8 @@
7773
import static org.assertj.core.api.Fail.fail;
7874
import static org.mockito.Mockito.mock;
7975

76+
77+
8078
/**
8179
* Test parity between OpenRewrite parser logic and RewriteProjectParser.
8280
*

0 commit comments

Comments
 (0)