Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Following the Quickstart guide, spring-petclinic-migration does not compile at the end #599

Open
DidierLoiseau opened this issue Oct 4, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@DidierLoiseau
Copy link

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v5.41.0
  • Maven v5.41.0
  • rewrite-spring v5.20.0

How are you running OpenRewrite?

I am using the Maven plugin on spring-petclinic-migration with the SpringBoot2JUnit4to5Migration as described in the quickstart guide, just without OrderImports and the custom recipe:

        <plugin>
            <groupId>org.openrewrite.maven</groupId>
            <artifactId>rewrite-maven-plugin</artifactId>
            <version>5.41.0</version>
            <configuration>
                <activeRecipes>
                    <recipe>org.openrewrite.java.spring.boot2.SpringBoot2JUnit4to5Migration</recipe>
                </activeRecipes>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.openrewrite.recipe</groupId>
                    <artifactId>rewrite-spring</artifactId>
                    <version>5.20.0</version>
                </dependency>
            </dependencies>
        </plugin>

(the tutorial uses version 5.16.0 but it does not seem to make a difference)

What is the smallest, simplest way to reproduce the problem?

Follow the tutorial 😏 then run mvn verify.

What did you expect to see?

The project should compile successfully.

What did you see instead?

PetTypeFormatterTests does not compile because it cannot find MockitoExtension. It appears to be missing the mockito-junit-jupiter dependency:

      <dependency>
          <groupId>org.mockito</groupId>
          <artifactId>mockito-junit-jupiter</artifactId>
          <scope>test</scope>
      </dependency>

It would also be better to set

<junit-jupiter.version>5.11.2</junit-jupiter.version>

instead of forcing the version on the org.junit.jupiter:junit-jupiter dependency, because the mismatching junit-bom gets imported. It might be good to set mockito.version to something more recent as well for consistency, but it will only work if you also update junit-jupiter.version, for API compatibility reasons.

What is the full stack trace of any errors you encountered?

[INFO] --- compiler:3.8.1:testCompile (default-testCompile) @ spring-petclinic ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 11 source files to /home/didier/IdeaProjects/spring-petclinic-migration/target/test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/didier/IdeaProjects/spring-petclinic-migration/src/test/java/org/springframework/samples/petclinic/owner/PetTypeFormatterTests.java:[8,33] package org.mockito.junit.jupiter does not exist
[ERROR] /home/didier/IdeaProjects/spring-petclinic-migration/src/test/java/org/springframework/samples/petclinic/owner/PetTypeFormatterTests.java:[24,13] cannot find symbol
  symbol: class MockitoExtension
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.235 s
[INFO] Finished at: 2024-10-04T20:59:11+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-testCompile) on project spring-petclinic: Compilation failure: Compilation failure: 
[ERROR] /home/didier/IdeaProjects/spring-petclinic-migration/src/test/java/org/springframework/samples/petclinic/owner/PetTypeFormatterTests.java:[8,33] package org.mockito.junit.jupiter does not exist
[ERROR] /home/didier/IdeaProjects/spring-petclinic-migration/src/test/java/org/springframework/samples/petclinic/owner/PetTypeFormatterTests.java:[24,13] cannot find symbol
[ERROR]   symbol: class MockitoExtension
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Are you interested in contributing a fix to OpenRewrite?

Not particularly, migrating to Junit 5 is for old projects now…

Sorry, I should have reported this earlier when I first tried OpenRewrite, instead of remembering it 3 days before Devoxx 😅

@DidierLoiseau DidierLoiseau added the bug Something isn't working label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

1 participant