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
@@ -0,0 +1,222 @@
package org.openrewrite.java.testing.junit5;
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
package org.openrewrite.java.testing.junit5;
/*
* Copyright 2025 the original author or authors.
* <p>
* Licensed under the Moderne Source Available License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://docs.moderne.io/licensing/moderne-source-available-license
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openrewrite.java.testing.junit5;

Comment on lines +7 to +12
import org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.JavaType;
import org.openrewrite.java.tree.Statement;
import org.openrewrite.java.tree.TypeUtils;

import static java.util.Objects.requireNonNull;
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 org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.JavaType;
import org.openrewrite.java.tree.Statement;
import org.openrewrite.java.tree.TypeUtils;
import static java.util.Objects.requireNonNull;
import org.openrewrite.java.tree.J;

// return mi;
// }
// }.visit(tree, 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>() {

Comment on lines +182 to +183
}.visit(j, ctx);
return j;
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
}.visit(j, ctx);
return j;
}.visit(j, ctx);

}

@DocumentExample
// TODO: methods receiving MockResponse - maybe add comment instructing to double check?
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
// TODO: methods receiving MockResponse - maybe add comment instructing to double check?
@DocumentExample
@Test
void shouldUpgradeMavenDependency() {
rewriteRun(
mavenProject("project",
srcTestJava(
//language=java
java(
"""
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
class Test {
void test() {
MockWebServer server = new MockWebServer();
server.enqueue(
new MockResponse().setHeader("Content-Type", "application/json")
// new MockResponse()
// .setHeader("Content-Type", "application/json")
// .setResponseCode(200)
// .setBody("{}")
);
// RecordedRequest recordedRequest = server.takeRequest();
}
}
""",
"""
import mockwebserver3.MockResponse;
import mockwebserver3.MockWebServer;
import mockwebserver3.RecordedRequest;
class Test {
void test() {
MockWebServer server = new MockWebServer();
server.enqueue(
new MockResponse()
// .setHeader("Content-Type", "application/json")
// .setResponseCode(200)
// .setBody("{}")
);
// RecordedRequest recordedRequest = server.takeRequest();
}
}
"""
)
),
//language=xml
pomXml(
"""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>4.10.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
""",
spec -> spec.after(pom ->
assertThat(pom)
.doesNotContain("<artifactId>mockwebserver</artifactId>")
.contains("<artifactId>mockwebserver3</artifactId>")
.containsPattern("<version>5\\.(.*)</version>")
.actual()
)
)
)
);
}
// TODO: methods receiving MockResponse - maybe add comment instructing to double check?

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.

2 participants