Skip to content

Commit

Permalink
Perform recipe SelectRecipeExamples on rewrite itself to select recip…
Browse files Browse the repository at this point in the history
…e examples
  • Loading branch information
kunli2 committed Apr 26, 2023
1 parent 1f10a84 commit f6e37b9
Show file tree
Hide file tree
Showing 338 changed files with 683 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.openrewrite;

import org.junit.jupiter.api.Test;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.marker.SearchResult;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
Expand All @@ -31,6 +32,7 @@ public void defaults(RecipeSpec spec) {
spec.validateRecipeSerialization(false);
}

@DocumentExample
@Test
void not() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.openrewrite;

import org.junit.jupiter.api.Test;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.marker.GitProvenance;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
Expand All @@ -31,6 +32,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new FindGitProvenance());
}

@DocumentExample
@Test
void showGitProvenance() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.intellij.lang.annotations.Language;
import org.junit.jupiter.api.Test;
import org.openrewrite.config.RecipeDescriptor;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.marker.Markers;
Expand Down Expand Up @@ -101,6 +102,7 @@ public PlainText visitText(PlainText tree, P p) {
}
}

@DocumentExample
@Test
void recipeApplicabilityWithFindNothingApplicability() {
// Given:
Expand Down Expand Up @@ -475,6 +477,7 @@ void sourceFilesAcceptOnlyApplicableVisitors() {
}
}

@DocumentExample
@Test
void accurateReportingOfRecipesMakingChanges() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.openrewrite;

import org.junit.jupiter.api.Test;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RewriteTest;
import org.openrewrite.text.PlainText;
import org.openrewrite.text.PlainTextVisitor;
Expand All @@ -27,6 +28,7 @@

class RecipeSchedulerTest implements RewriteTest {

@DocumentExample
@Test
void exceptionsCauseResult() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.openrewrite;

import org.junit.jupiter.api.Test;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RewriteTest;
import org.openrewrite.text.PlainText;
import org.openrewrite.text.PlainTextVisitor;
Expand All @@ -28,6 +29,7 @@

class TreeObserverTest implements RewriteTest {

@DocumentExample
@Test
void observePropertyChange() {
var observed = new AtomicInteger(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.openrewrite.Contributor;
import org.openrewrite.Maintainer;
import org.openrewrite.Recipe;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RewriteTest;

import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -92,6 +93,7 @@ void maintainers() {
assertThat(jon.getLogo()).isNull();
}

@DocumentExample
@Test
void singleSourceApplicability() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.openrewrite.SourceFile;
import org.openrewrite.Tree;
import org.openrewrite.TreeVisitor;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.marker.SearchResult;
import org.openrewrite.test.RewriteTest;

Expand All @@ -28,6 +29,7 @@

class QuarkTest implements RewriteTest {

@DocumentExample
@Test
void renderMarkersOnQuarks() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.junit.jupiter.api.Test;
import org.openrewrite.*;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.marker.SearchResult;
import org.openrewrite.test.RecipeSpec;
Expand Down Expand Up @@ -69,6 +70,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new RecipeWithApplicabilityTest());
}

@DocumentExample
@Test
void singleRow() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.openrewrite.table;

import org.junit.jupiter.api.Test;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RewriteTest;

import java.io.ByteArrayInputStream;
Expand All @@ -25,6 +26,7 @@

class SourceFileResultsTest implements RewriteTest {

@DocumentExample
@Test
void hierarchical() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@

import org.intellij.lang.annotations.Language;
import org.junit.jupiter.api.Test;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RewriteTest;

import static org.assertj.core.api.Assertions.assertThat;
import static org.openrewrite.test.SourceSpecs.text;


class SourcesFileResultsTest implements RewriteTest {
@DocumentExample
@Test
void twoResultsOnly() {
@Language("yaml")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.junit.jupiter.api.Test;
import org.openrewrite.Issue;
import org.openrewrite.Recipe;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RewriteTest;
import org.openrewrite.test.SourceSpec;

Expand Down Expand Up @@ -59,6 +60,7 @@ void createsFileIfNeededWithMultipleInstances() {
);
}

@DocumentExample
@Test
void replacesFileIfRequested() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.openrewrite.text;

import org.junit.jupiter.api.Test;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

Expand All @@ -28,6 +29,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new EndOfLineAtEndOfFile());
}

@DocumentExample
@Test
void nonTxtExtension() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
package org.openrewrite.text;

import org.junit.jupiter.api.Test;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.test.SourceSpecs.text;

class FindAndReplaceTest implements RewriteTest {

@DocumentExample
@Test
void nonTxtExtension() {
rewriteRun(
Expand Down
2 changes: 2 additions & 0 deletions rewrite-core/src/test/java/org/openrewrite/text/FindTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
package org.openrewrite.text;

import org.junit.jupiter.api.Test;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.test.SourceSpecs.text;

class FindTest implements RewriteTest {

@DocumentExample
@Test
void regex() {
rewriteRun(
Expand Down
2 changes: 1 addition & 1 deletion rewrite-gradle/src/main/groovy/RepositoryHandler.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ interface RepositoryHandlerSpec extends RepositoryHandler {

interface MavenArtifactRepositorySpec extends MavenArtifactRepository {
void url(Object url)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.openrewrite.gradle;

import org.junit.jupiter.api.Test;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
import org.openrewrite.test.TypeValidation;
Expand All @@ -32,6 +33,7 @@ public void defaults(RecipeSpec spec) {
.typeValidationOptions(TypeValidation.none());
}

@DocumentExample
@Test
void addToRewriteDsl() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.openrewrite.gradle;

import org.junit.jupiter.api.Test;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
Expand All @@ -31,6 +32,7 @@ public void defaults(RecipeSpec spec) {
.recipe(new AddDelegatesToGradleApi());
}

@DocumentExample
@Test
void simpleMethod() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.gradle.Assertions.buildGradle;

class ChangeDependencyArtifactIdTest implements RewriteTest {

@DocumentExample
@Test
void worksWithEmptyStringConfig() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.gradle.Assertions.buildGradle;

class ChangeDependencyClassifierTest implements RewriteTest {
@DocumentExample
@Test
void worksWithEmptyStringConfig() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.gradle.Assertions.buildGradle;

class ChangeDependencyConfigurationTest implements RewriteTest {
@DocumentExample
@Test
void worksWithEmptyStringConfig() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.gradle.Assertions.buildGradle;

class ChangeDependencyExtensionTest implements RewriteTest {

@DocumentExample
@Test
void worksWithEmptyStringConfig() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.gradle.Assertions.buildGradle;

class ChangeDependencyGroupIdTest implements RewriteTest {

@DocumentExample
@Test
void worksWithEmptyStringConfig() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.gradle.Assertions.buildGradle;

class ChangeDependencyVersionTest implements RewriteTest {

@DocumentExample
@Test
void worksWithEmptyStringConfig() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.junit.jupiter.api.Test;
import org.openrewrite.Issue;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

Expand All @@ -29,6 +30,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new DependencyUseMapNotation());
}

@DocumentExample
@Test
void basicString() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.openrewrite.gradle;

import org.junit.jupiter.api.Test;
import org.openrewrite.internal.DocumentExample;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

Expand All @@ -28,6 +29,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new DependencyUseStringNotation());
}

@DocumentExample
@Test
void basicMap() {
rewriteRun(
Expand Down
Loading

0 comments on commit f6e37b9

Please sign in to comment.