Skip to content

Commit 94f75ce

Browse files
timtebeekTeamModerne
authored andcommitted
refactor: Extract documentation examples from tests
Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.recipes.ExamplesExtractor?organizationId=ODQ2MGExMTUtNDg0My00N2EwLTgzMGMtNGE1NGExMTBmZDkw Co-authored-by: Moderne <[email protected]>
1 parent e631e86 commit 94f75ce

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

src/main/resources/META-INF/rewrite/examples.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,39 @@ examples:
126126
language: java
127127
---
128128
type: specs.openrewrite.org/v1beta/example
129+
recipeName: org.openrewrite.java.migrate.AddStaticVariableOnProducerSessionBean
130+
examples:
131+
- description: ''
132+
sources:
133+
- before: |
134+
package com.test;
135+
import jakarta.ejb.Stateless;
136+
import jakarta.enterprise.inject.Produces;
137+
138+
@Stateless
139+
public class MySessionBean {
140+
@Produces
141+
private SomeDependency someDependency;
142+
void exampleMethod() {
143+
return;
144+
}
145+
}
146+
after: |
147+
package com.test;
148+
import jakarta.ejb.Stateless;
149+
import jakarta.enterprise.inject.Produces;
150+
151+
@Stateless
152+
public class MySessionBean {
153+
@Produces
154+
private static SomeDependency someDependency;
155+
void exampleMethod() {
156+
return;
157+
}
158+
}
159+
language: java
160+
---
161+
type: specs.openrewrite.org/v1beta/example
129162
recipeName: org.openrewrite.java.migrate.ArrayStoreExceptionToTypeNotPresentException
130163
examples:
131164
- description: ''
@@ -6054,6 +6087,63 @@ examples:
60546087
language: java
60556088
---
60566089
type: specs.openrewrite.org/v1beta/example
6090+
recipeName: org.openrewrite.java.migrate.lang.RefineSwitchCases
6091+
examples:
6092+
- description: ''
6093+
sources:
6094+
- before: |
6095+
class Test {
6096+
static void score(Object obj) {
6097+
switch (obj) {
6098+
case null -> System.out.println("You did not enter the test yet");
6099+
case Integer i -> {
6100+
if (i >= 5 && i <= 10)
6101+
System.out.println("You got it");
6102+
else if (i >= 0 && i < 5)
6103+
System.out.println("Shame");
6104+
else
6105+
System.out.println("Sorry?");
6106+
}
6107+
case String s -> {
6108+
if (s.equalsIgnoreCase("YES"))
6109+
System.out.println("You got it");
6110+
else if ("NO".equalsIgnoreCase(s))
6111+
System.out.println("Shame");
6112+
else
6113+
System.out.println("Sorry?");
6114+
}
6115+
default -> {
6116+
// Comment retained
6117+
}
6118+
}
6119+
}
6120+
}
6121+
after: |
6122+
class Test {
6123+
static void score(Object obj) {
6124+
switch (obj) {
6125+
case null -> System.out.println("You did not enter the test yet");
6126+
case Integer i when i >= 5 && i <= 10 ->
6127+
System.out.println("You got it");
6128+
case Integer i when i >= 0 && i < 5 ->
6129+
System.out.println("Shame");
6130+
case Integer i ->
6131+
System.out.println("Sorry?");
6132+
case String s when s.equalsIgnoreCase("YES") ->
6133+
System.out.println("You got it");
6134+
case String s when "NO".equalsIgnoreCase(s) ->
6135+
System.out.println("Shame");
6136+
case String s ->
6137+
System.out.println("Sorry?");
6138+
default -> {
6139+
// Comment retained
6140+
}
6141+
}
6142+
}
6143+
}
6144+
language: java
6145+
---
6146+
type: specs.openrewrite.org/v1beta/example
60576147
recipeName: org.openrewrite.java.migrate.lang.StringRulesRecipes
60586148
examples:
60596149
- description: ''

0 commit comments

Comments
 (0)