Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void doNotChangeWhenEntriesExistInDifferentOrder() {

@Test
void rootOnlyTargetingByDefault() {
AddToGitignore recipe = new AddToGitignore("*.log", null);
var recipe = new AddToGitignore("*.log", null);
rewriteRun(
spec -> spec.recipe(recipe),
text(
Expand All @@ -340,7 +340,7 @@ void rootOnlyTargetingByDefault() {

@Test
void targetSpecificSubdirectory() {
AddToGitignore recipe = new AddToGitignore("*.log", "src/.gitignore");
var recipe = new AddToGitignore("*.log", "src/.gitignore");
rewriteRun(
spec -> spec.recipe(recipe),
text(
Expand All @@ -365,7 +365,7 @@ void targetSpecificSubdirectory() {

@Test
void targetAllGitignoreFiles() {
AddToGitignore recipe = new AddToGitignore("*.log", "**/.gitignore");
var recipe = new AddToGitignore("*.log", "**/.gitignore");
rewriteRun(
spec -> spec.recipe(recipe),
text(
Expand Down Expand Up @@ -406,7 +406,7 @@ void targetAllGitignoreFiles() {

@Test
void createGitignoreInSpecificLocation() {
AddToGitignore recipe = new AddToGitignore("*.log", "src/.gitignore");
var recipe = new AddToGitignore("*.log", "src/.gitignore");
rewriteRun(
spec -> spec.recipe(recipe),
text(
Expand All @@ -421,7 +421,7 @@ void createGitignoreInSpecificLocation() {

@Test
void createRootGitignoreWhenPatternIsWildcard() {
AddToGitignore recipe = new AddToGitignore("*.log", "**/.gitignore");
var recipe = new AddToGitignore("*.log", "**/.gitignore");
rewriteRun(
spec -> spec.recipe(recipe),
text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import java.nio.file.Path;
import java.util.List;
import java.util.stream.Collectors;

import static org.assertj.core.api.Assertions.assertThat;
import static org.openrewrite.test.SourceSpecs.text;
Expand Down Expand Up @@ -81,7 +80,7 @@ void dataTableWithMultilineValue() {

// Verify the row has multiline content
List<?> rows = store.getRows(parseFailuresDt.getName(), parseFailuresDt.getGroup())
.collect(java.util.stream.Collectors.toList());
.toList();
assertThat(rows).hasSize(1);
}),
text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ void recipeRunExceptionDuringGenerate() {

@Test
void suppliedWorkingDirectoryRoot(@TempDir Path path) {
InMemoryExecutionContext ctx = new InMemoryExecutionContext();
var ctx = new InMemoryExecutionContext();
WorkingDirectoryExecutionContextView.view(ctx).setRoot(path);
AtomicInteger cycle = new AtomicInteger(0);
var cycle = new AtomicInteger(0);
rewriteRun(
spec -> spec.executionContext(ctx).recipe(toRecipe(() -> new TreeVisitor<>() {
@Override
Expand All @@ -139,7 +139,7 @@ public Tree visit(@Nullable Tree tree, ExecutionContext ctx) {

@Test
void managedWorkingDirectoryWithRecipe(@TempDir Path path) {
InMemoryExecutionContext ctx = new InMemoryExecutionContext();
var ctx = new InMemoryExecutionContext();
WorkingDirectoryExecutionContextView.view(ctx).setRoot(path);
rewriteRun(
spec -> spec.executionContext(ctx).recipe(new RecipeWritingToFile(0)),
Expand All @@ -150,9 +150,9 @@ void managedWorkingDirectoryWithRecipe(@TempDir Path path) {

@Test
void managedWorkingDirectoryWithMultipleRecipes(@TempDir Path path) {
InMemoryExecutionContext ctx = new InMemoryExecutionContext();
var ctx = new InMemoryExecutionContext();
WorkingDirectoryExecutionContextView.view(ctx).setRoot(path);
DeclarativeRecipe recipe = new DeclarativeRecipe(
var recipe = new DeclarativeRecipe(
"root",
"Root recipe",
"Root recipe.",
Expand All @@ -176,7 +176,7 @@ void managedWorkingDirectoryWithMultipleRecipes(@TempDir Path path) {
void verifyCycleInvariantsDuringMultipleCycles() {
List<Integer> cyclesFromFactory = new java.util.ArrayList<>();
List<Integer> cyclesFromContext = new java.util.ArrayList<>();
AtomicInteger visitCount = new AtomicInteger(0);
var visitCount = new AtomicInteger(0);

RecipeScheduler trackingScheduler = new RecipeScheduler() {
@Override
Expand Down Expand Up @@ -205,7 +205,7 @@ public PlainText visitText(PlainText text, ExecutionContext ctx) {
}
}).withCausesAnotherCycle(true);

InMemoryExecutionContext ctx = new InMemoryExecutionContext();
var ctx = new InMemoryExecutionContext();
List<SourceFile> sources = List.of(PlainText.builder().text("v").sourcePath(Path.of("test.txt")).build());
trackingScheduler.scheduleRun(multiCycleRecipe, new InMemoryLargeSourceSet(sources), ctx, 5, 1);

Expand Down Expand Up @@ -252,7 +252,7 @@ public PlainText visitText(PlainText text, ExecutionContext ctx) {
}
});

InMemoryExecutionContext ctx = new InMemoryExecutionContext();
var ctx = new InMemoryExecutionContext();
List<SourceFile> sources = List.of(
PlainText.builder().text("a").sourcePath(Path.of("a.txt")).build(),
PlainText.builder().text("b").sourcePath(Path.of("b.txt")).build()
Expand Down Expand Up @@ -292,7 +292,7 @@ protected void recordSourceFileResultAndSearchResults(

Recipe generatingRecipe = new GeneratingRecipe();

InMemoryExecutionContext ctx = new InMemoryExecutionContext();
var ctx = new InMemoryExecutionContext();
List<SourceFile> sources = List.of(PlainText.builder().text("existing").sourcePath(Path.of("existing.txt")).build());
trackingScheduler.scheduleRun(generatingRecipe, new InMemoryLargeSourceSet(sources), ctx, 3, 1);

Expand Down
4 changes: 2 additions & 2 deletions rewrite-core/src/test/java/org/openrewrite/TreeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public String afterSyntax(Marker marker, Cursor cursor, UnaryOperator<String> co
})
@ParameterizedTest
void printBomHandling(boolean charsetBomMarked, String expected) {
PlainText sourceFile = new PlainText(
var sourceFile = new PlainText(
Tree.randomId(),
Paths.get("test.txt"),
Markers.EMPTY,
Expand All @@ -82,7 +82,7 @@ void printBomHandling(boolean charsetBomMarked, String expected) {

@Test
void printQuarkDoesNotThrowOnBomRestoration() {
Quark quark = new Quark(
var quark = new Quark(
Tree.randomId(),
Paths.get("unknown.file"),
Markers.EMPTY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void precondition() {
rewriteRun(
spec -> {
spec.validateRecipeSerialization(false);
DeclarativeRecipe dr = new DeclarativeRecipe("test", "test", "test", emptySet(),
var dr = new DeclarativeRecipe("test", "test", "test", emptySet(),
null, URI.create("null"), true, emptyList());
dr.addPrecondition(
toRecipe(() -> new PlainTextVisitor<>() {
Expand Down Expand Up @@ -89,7 +89,7 @@ public PlainText visitText(PlainText text, ExecutionContext ctx) {

@Test
void addingPreconditionsWithOptions() {
DeclarativeRecipe dr = new DeclarativeRecipe("test", "test", "test", emptySet(),
var dr = new DeclarativeRecipe("test", "test", "test", emptySet(),
null, URI.create("dummy"), true, emptyList());
dr.addPrecondition(
toRecipe(() -> new PlainTextVisitor<>() {
Expand Down Expand Up @@ -119,7 +119,7 @@ public PlainText visitText(PlainText text, ExecutionContext ctx) {

@Test
void preconditionDescriptorsIncludedInDescriptor() {
DeclarativeRecipe dr = new DeclarativeRecipe("test", "test", "test", emptySet(),
var dr = new DeclarativeRecipe("test", "test", "test", emptySet(),
null, URI.create("dummy"), true, emptyList());
dr.addPrecondition(new Find("precondition-marker", null, null, null, null, null, null, null));
dr.addUninitialized(new ChangeText("2"));
Expand All @@ -138,7 +138,7 @@ void preconditionDescriptorsIncludedInDescriptor() {

@Test
void uninitializedFailsValidation() {
DeclarativeRecipe dr = new DeclarativeRecipe("test", "test", "test", emptySet(),
var dr = new DeclarativeRecipe("test", "test", "test", emptySet(),
null, URI.create("dummy"), true, emptyList());
dr.addUninitializedPrecondition(
toRecipe(() -> new PlainTextVisitor<>() {
Expand All @@ -165,7 +165,7 @@ public PlainText visitText(PlainText text, ExecutionContext ctx) {

@Test
void uninitializedWithInitializedRecipesPassesValidation() {
DeclarativeRecipe dr = new DeclarativeRecipe("test", "test", "test", emptySet(),
var dr = new DeclarativeRecipe("test", "test", "test", emptySet(),
null, URI.create("dummy"), true, emptyList());
dr.setPreconditions(
List.of(
Expand Down Expand Up @@ -364,7 +364,7 @@ void preconditionOnNestedDeclarative() {

@Test
void exposesUnderlyingDataTables() {
DeclarativeRecipe dr = new DeclarativeRecipe("org.openrewrite.DeclarativeDataTable", "declarative with data table",
var dr = new DeclarativeRecipe("org.openrewrite.DeclarativeDataTable", "declarative with data table",
"test", emptySet(), null, URI.create("dummy"), true, emptyList());
dr.addUninitialized(new Find("sam", null, null, null, null, null, null, null));
dr.initialize(List.of());
Expand All @@ -373,17 +373,17 @@ void exposesUnderlyingDataTables() {

@Test
void getDataTableDescriptorsThreadSafe() throws Exception {
DeclarativeRecipe dr = new DeclarativeRecipe("org.openrewrite.ConcurrentTest", "concurrent test",
var dr = new DeclarativeRecipe("org.openrewrite.ConcurrentTest", "concurrent test",
"test", emptySet(), null, URI.create("dummy"), true, emptyList());
dr.addUninitialized(new Find("sam", null, null, null, null, null, null, null));
dr.initialize(List.of());

int threadCount = 10;
int iterations = 100;
ExecutorService executor = Executors.newFixedThreadPool(threadCount);
CountDownLatch startLatch = new CountDownLatch(1);
CountDownLatch doneLatch = new CountDownLatch(threadCount);
ConcurrentLinkedQueue<Throwable> errors = new ConcurrentLinkedQueue<>();
var startLatch = new CountDownLatch(1);
var doneLatch = new CountDownLatch(threadCount);
var errors = new ConcurrentLinkedQueue<Throwable>();

for (int i = 0; i < threadCount; i++) {
final int threadIdx = i;
Expand Down Expand Up @@ -418,7 +418,7 @@ void getDataTableDescriptorsThreadSafe() throws Exception {

@Test
void concurrentInitializeDoesNotDuplicateRecipes() throws Exception {
DeclarativeRecipe dr = new DeclarativeRecipe("org.openrewrite.ConcurrentInitTest", "concurrent init test",
var dr = new DeclarativeRecipe("org.openrewrite.ConcurrentInitTest", "concurrent init test",
"test", emptySet(), null, URI.create("dummy"), true, emptyList());
dr.addUninitialized(new Find("sam", null, null, null, null, null, null, null));
dr.addUninitialized(new ChangeText("hello"));
Expand All @@ -428,9 +428,9 @@ void concurrentInitializeDoesNotDuplicateRecipes() throws Exception {

int threadCount = 20;
ExecutorService executor = Executors.newFixedThreadPool(threadCount);
CountDownLatch startLatch = new CountDownLatch(1);
CountDownLatch doneLatch = new CountDownLatch(threadCount);
ConcurrentLinkedQueue<Throwable> errors = new ConcurrentLinkedQueue<>();
var startLatch = new CountDownLatch(1);
var doneLatch = new CountDownLatch(threadCount);
var errors = new ConcurrentLinkedQueue<Throwable>();

for (int i = 0; i < threadCount; i++) {
executor.submit(() -> {
Expand Down Expand Up @@ -469,7 +469,7 @@ void maxCycles() {

@Test
void maxCyclesNested() {
AtomicInteger cycleCount = new AtomicInteger();
var cycleCount = new AtomicInteger();
Recipe root = new MaxCycles(
100,
List.of(new MaxCycles(
Expand Down Expand Up @@ -540,7 +540,7 @@ public Tree visit(@Nullable Tree tree, ExecutionContext ctx) {
@Test
void selfReferencingRecipeDetectedAsCycle() {
// Test that a recipe referencing itself is detected as a cycle
DeclarativeRecipe selfReferencing = new DeclarativeRecipe(
var selfReferencing = new DeclarativeRecipe(
"org.openrewrite.SelfReferencing",
"Self Referencing Recipe",
"A recipe that references itself",
Expand All @@ -564,7 +564,7 @@ void selfReferencingRecipeDetectedAsCycle() {
@Test
void mutuallyRecursiveRecipesDetectedAsCycle() {
// Test that mutually recursive recipes are detected as a cycle
DeclarativeRecipe recipeA = new DeclarativeRecipe(
var recipeA = new DeclarativeRecipe(
"org.openrewrite.RecipeA",
"Recipe A",
"Recipe A that references Recipe B",
Expand All @@ -575,7 +575,7 @@ void mutuallyRecursiveRecipesDetectedAsCycle() {
emptyList()
);

DeclarativeRecipe recipeB = new DeclarativeRecipe(
var recipeB = new DeclarativeRecipe(
"org.openrewrite.RecipeB",
"Recipe B",
"Recipe B that references Recipe A",
Expand Down Expand Up @@ -785,7 +785,7 @@ void multipleNestedOrPreconditionsWithSameScanningRecipe() {
@Test
void deeperCyclicReferencesDetectedAsCycle() {
// Test that deeper cyclic references (A -> B -> C -> A) are detected as a cycle
DeclarativeRecipe recipeA = new DeclarativeRecipe(
var recipeA = new DeclarativeRecipe(
"org.openrewrite.RecipeA",
"Recipe A",
"Recipe A that references Recipe B",
Expand All @@ -796,7 +796,7 @@ void deeperCyclicReferencesDetectedAsCycle() {
emptyList()
);

DeclarativeRecipe recipeB = new DeclarativeRecipe(
var recipeB = new DeclarativeRecipe(
"org.openrewrite.RecipeB",
"Recipe B",
"Recipe B that references Recipe C",
Expand All @@ -807,7 +807,7 @@ void deeperCyclicReferencesDetectedAsCycle() {
emptyList()
);

DeclarativeRecipe recipeC = new DeclarativeRecipe(
var recipeC = new DeclarativeRecipe(
"org.openrewrite.RecipeC",
"Recipe C",
"Recipe C that references Recipe A",
Expand Down Expand Up @@ -842,7 +842,7 @@ void deeperCyclicReferencesDetectedAsCycle() {
// This can't be tested via rewriteRun() which uses a single RecipeRunCycle per cycle.
@Test
void scanningRecipeAccumulatorSurvivesAcrossRecipeRunCycles() {
DeclarativeRecipe recipe = new DeclarativeRecipe(
var recipe = new DeclarativeRecipe(
"test.WithPrecondition", "With precondition", "Test with precondition.",
emptySet(), null, URI.create("test"), true, emptyList()
);
Expand All @@ -855,12 +855,12 @@ void scanningRecipeAccumulatorSurvivesAcrossRecipeRunCycles() {
PlainText.builder().id(Tree.randomId()).sourcePath(Paths.get("file2.txt")).text("world").build()
);

Cursor rootCursor = new Cursor(null, Cursor.ROOT_VALUE);
WatchableExecutionContext ctx = new WatchableExecutionContext(new InMemoryExecutionContext());
var rootCursor = new Cursor(null, Cursor.ROOT_VALUE);
var ctx = new WatchableExecutionContext(new InMemoryExecutionContext());
Recipe noop = Recipe.noop();

// Cycle 1: scan (simulates first yield batch on the platform)
RecipeRunCycle<LargeSourceSet> scanCycle = new RecipeRunCycle<>(
var scanCycle = new RecipeRunCycle<LargeSourceSet>(
recipe, 1, rootCursor, ctx,
new RecipeRunStats(noop), new SearchResults(noop),
new SourcesFileResults(noop), new SourcesFileErrors(noop),
Expand All @@ -870,7 +870,7 @@ void scanningRecipeAccumulatorSurvivesAcrossRecipeRunCycles() {
scanCycle.scanSources(new InMemoryLargeSourceSet(sources));

// Cycle 2: edit (simulates new RecipeRunCycle after worker yield — new RecipeStack, fresh getRecipeList() calls)
RecipeRunCycle<LargeSourceSet> editCycle = new RecipeRunCycle<>(
var editCycle = new RecipeRunCycle<LargeSourceSet>(
recipe, 1, rootCursor, ctx,
new RecipeRunStats(noop), new SearchResults(noop),
new SourcesFileResults(noop), new SourcesFileErrors(noop),
Expand Down
20 changes: 10 additions & 10 deletions rewrite-core/src/test/java/org/openrewrite/rpc/RewriteRpcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ class RewriteRpcTest implements RewriteTest {

@BeforeEach
void before() throws IOException {
PipedOutputStream serverOut = new PipedOutputStream();
PipedOutputStream clientOut = new PipedOutputStream();
PipedInputStream serverIn = new PipedInputStream(clientOut);
PipedInputStream clientIn = new PipedInputStream(serverOut);
var serverOut = new PipedOutputStream();
var clientOut = new PipedOutputStream();
var serverIn = new PipedInputStream(clientOut);
var clientIn = new PipedInputStream(serverOut);

marketplace = env.toMarketplace(runtimeClasspath());

JsonMessageFormatter clientFormatter = new JsonMessageFormatter(new ParameterNamesModule());
JsonMessageFormatter serverFormatter = new JsonMessageFormatter(new ParameterNamesModule());
var clientFormatter = new JsonMessageFormatter(new ParameterNamesModule());
var serverFormatter = new JsonMessageFormatter(new ParameterNamesModule());

client = new RewriteRpc(new JsonRpc(new HeaderDelimitedMessageHandler(clientFormatter, clientIn, clientOut)), marketplace)
.batchSize(1);
Expand Down Expand Up @@ -239,7 +239,7 @@ void prepareRecipe() {
@Disabled("Disabled until https://github.com/openrewrite/rewrite/pull/5260 is complete")
@Test
void runRecipe() {
CountDownLatch latch = new CountDownLatch(1);
var latch = new CountDownLatch(1);
rewriteRun(
spec -> spec
.recipe(client.prepareRecipe("org.openrewrite.text.Find",
Expand Down Expand Up @@ -415,9 +415,9 @@ void singleRpcRecipeNoBatch() {

@Test
void getCursor() {
Cursor parent = new Cursor(null, Cursor.ROOT_VALUE);
Cursor c1 = new Cursor(parent, 0);
Cursor c2 = new Cursor(c1, 1);
var parent = new Cursor(null, Cursor.ROOT_VALUE);
var c1 = new Cursor(parent, 0);
var c2 = new Cursor(c1, 1);

Cursor clientC2 = server.getCursor(client.getCursorIds(c2), null);
assertThat(clientC2.<Integer>getValue()).isEqualTo(1);
Expand Down
Loading