Recipe must be able to instantiate via RecipeIntrospectionUtils

33 Views Asked by At

I followed the steps from "Writing a Java refactoring recipe " pretty much 1 to 1, meaning I have the exact same pom, SayHellopRecipe and SayHelloRecipeTest.

I now expect

If you run the tests right now, you should see that the tests that expect no changes pass, whereas the test that expects changes does not.

to happen, but instead I get the following error:

java.lang.AssertionError: [Recipe must be able to instantiate via RecipeIntrospectionUtils] 
Expecting code not to raise a throwable but caught
  "org.openrewrite.config.RecipeIntrospectionException: Unable to call primary constructor for Recipe class ...
...
fullyQualifiedClassName is marked non-null but is null
    at SayHelloRecipe

What am I doing wrong?

1

There are 1 best solutions below

3
Tim On

did you choose the recipe variant with our without Lombok? It sounds like there might be an issue with the auto generated constructor. Do you have an IDE plugin for Lombok installed, and did you enable Lombok annotation processing?

In the non-Lombok variant there was a small issue which I've just fixed: https://github.com/openrewrite/rewrite-docs/commit/a0bbe81b7930edb4865afed6b4f83168f84ff150

Other than that I was able to get the tests to run up to that first step you've highlighted, with only one expected failure as the recipe implementation still needs to be filled in by the reader.

Adding the link for others that come along:
https://docs.openrewrite.org/authoring-recipes/writing-a-java-refactoring-recipe