Skip to content

Commit

Permalink
refactor: Automatically select recipe examples from the unit test cas…
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek and TeamModerne authored Feb 4, 2024
1 parent b38c77c commit c7459b9
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.openrewrite.staticanalysis;

import org.junit.jupiter.api.Test;
import org.openrewrite.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 BigDecimalDoubleConstructorRecipe());
}

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

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
Expand Down Expand Up @@ -120,6 +121,7 @@ Integer method(Optional<Integer> o) {
);
}

@DocumentExample
@Test
void ignoreReturnInsideLambda() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
package org.openrewrite.staticanalysis;

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

import static org.openrewrite.java.Assertions.java;

class SimplifyTernaryTest implements RewriteTest {
@DocumentExample
@Test
void simplified() {
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.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 SortedSetStreamToLinkedHashSet());
}

@DocumentExample
@Test
void changeSortedSetStreamToLinkedHashSet() {
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.junitpioneer.jupiter.ExpectedToFail;
import org.openrewrite.DocumentExample;
import org.openrewrite.Issue;
import org.openrewrite.staticanalysis.MinimumSwitchCases;
import org.openrewrite.test.RecipeSpec;
Expand Down Expand Up @@ -63,6 +64,7 @@ void test(OpenOption o) {
);
}

@DocumentExample
@ExpectedToFail("Temporarily until we have investigated why the behavior has changed here")
@Test
void twoCases() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.staticanalysis.RenameLocalVariablesToCamelCase;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
Expand All @@ -30,6 +31,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new RenameLocalVariablesToCamelCase());
}

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

import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.staticanalysis.SimplifyBooleanExpression;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
Expand All @@ -29,6 +30,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new SimplifyBooleanExpression());
}

@DocumentExample
@Test
void regular() {
rewriteRun(
Expand Down

0 comments on commit c7459b9

Please sign in to comment.