Skip to content

Conversation

@steve-aom-elliott
Copy link
Contributor

What's changed?

  • New artifactId corrected from mockwebserver3-junit5 to mockwebserver3
  • In-progress work for changing how some classes are built / manipulated. Previously there were many methods existing on MockResponse. Now everything has to be switched to using MockResponse.Builder to change all these values.

What's your motivation?

Compilation failures after previous setup's migration ran.

Anything in particular you'd like reviewers to focus on?

  • Trying to see if I can cut down on additional recipe calls given there are a fair number of methods yet to migrate.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@steve-aom-elliott steve-aom-elliott self-assigned this Nov 21, 2025
@steve-aom-elliott steve-aom-elliott added bug Something isn't working dependencies Pull requests that update a dependency file test provided junit labels Nov 21, 2025
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Nov 21, 2025
@steve-aom-elliott steve-aom-elliott force-pushed the 1589-correcting-mockwebserver-migration branch 3 times, most recently from 630c51b to 58ef5a9 Compare November 27, 2025 21:47
@steve-aom-elliott
Copy link
Contributor Author

I'm going to try to look into whether I can set up a single visitor to perform all the type changes needed prior to using the JavaTemplate to write the .build() chaining in, as the problem I'm hitting here is that I'm changing MockResponse fields to MockResponse.Builder fields, return types from some of the methods of MockResponse to be on MockResponse.Builder instead, followed by introducing a .build() call that belongs to MockResponse.Builder but returns MockResponse, meaning ChangeType recipe effectively breaks the type attribution, but covers a lot of the scenarios otherwise that I'd want to be changing. Going to probably roll my own visitor that combines functionality from some of the other ones, or create a visitor that is capable of altering a method invocation's signature's parameter types, which I don't believe we have easily accessible a the moment.

@steve-aom-elliott steve-aom-elliott force-pushed the 1589-correcting-mockwebserver-migration branch from 58ef5a9 to 9f40caf Compare December 11, 2025 14:13
@steve-aom-elliott steve-aom-elliott force-pushed the 1589-correcting-mockwebserver-migration branch from 9f40caf to 7855d82 Compare December 12, 2025 22:09
@steve-aom-elliott steve-aom-elliott force-pushed the 1589-correcting-mockwebserver-migration branch from 7855d82 to 2cf1e69 Compare January 7, 2026 15:38
steve-aom-elliott and others added 5 commits January 15, 2026 11:31
…padding (including the newline), leading to it changing wrapping.
…uild()`, and backpatching the parameter types onto the various method invocations. Feels like there could be a lot of improvement still with how this done, as it feels pretty hacky right now.
@dsgrieve dsgrieve force-pushed the 1589-correcting-mockwebserver-migration branch from 71b567c to de9f20c Compare January 15, 2026 16:34
Comment on lines 49 to 51
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static java.util.stream.Collectors.toSet;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static java.util.stream.Collectors.toSet;
import static java.util.stream.Collectors.toList;

Comment on lines +61 to +62
private static final JavaType.FullyQualified newMockResponseBuilderType = (JavaType.FullyQualified) JavaType.buildType(NEW_MOCKRESPONSE_FQN_BUILDER);
private static final JavaType.FullyQualified newMockResponseType = (JavaType.FullyQualified) JavaType.buildType(NEW_MOCKRESPONSE_FQN);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static final JavaType.FullyQualified newMockResponseBuilderType = (JavaType.FullyQualified) JavaType.buildType(NEW_MOCKRESPONSE_FQN_BUILDER);
private static final JavaType.FullyQualified newMockResponseType = (JavaType.FullyQualified) JavaType.buildType(NEW_MOCKRESPONSE_FQN);
private static final JavaType.FullyQualified newMockResponseBuilderType = (JavaType.FullyQualified) JavaType.buildType(NEW_MOCKRESPONSE_FQN_BUILDER);

NEW_PACKAGE_NAME,
false
).getVisitor().visit(j, ctx);
j = new JavaIsoVisitor<ExecutionContext>() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
j = new JavaIsoVisitor<ExecutionContext>() {
return new JavaIsoVisitor<ExecutionContext>() {


// Wrap MockResponse.Builder arguments with .build()
Cursor methodCursor = getCursor();
replacement = mi.withArguments(ListUtils.map(mi.getArguments(), (index, arg) -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
replacement = mi.withArguments(ListUtils.map(mi.getArguments(), (index, arg) -> {
return mi.withArguments(ListUtils.map(mi.getArguments(), (index, arg) -> {

import static org.assertj.core.api.Assertions.assertThat;
import static org.openrewrite.java.Assertions.java;
import static org.openrewrite.java.Assertions.mavenProject;
import static org.openrewrite.java.Assertions.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import static org.openrewrite.java.Assertions.*;
import static org.openrewrite.java.Assertions.java;
import static org.openrewrite.java.Assertions.mavenProject;

dsgrieve and others added 8 commits January 15, 2026 12:06
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…pMockWebServerTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…bServerMockResponse.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dependencies Pull requests that update a dependency file junit test provided

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

4 participants