assertj / assertj-assertions-generator

Custom assertions generator
https://joel-costigliola.github.io/assertj/assertj-assertions-generator.html
Apache License 2.0
62 stars 42 forks source link

Using generateAssertionsInPackage in Maven results in compilation issues #135

Open bbottema opened 4 years ago

bbottema commented 4 years ago

Summary

Some classes for which I generate assertion classes contain methods with parameter types that are in the same package. If I then use <generateAssertionsInPackage> to generate the assertion classes in a different package, they miss the required imports for these types.

Example

public class Holder {
   private Collection<? extends MyCustomClass> values;
}
<plugin>
    <groupId>org.assertj</groupId>
    <artifactId>assertj-assertions-generator-maven-plugin</artifactId>
    <version>2.1.0</version>
    <executions>
        <execution>
            <goals>
                <goal>generate-assertions</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <generateAssertionsInPackage>assertj.generated.assertions</generateAssertionsInPackage>
    </configuration>
</plugin>

Results in the following assertion class:

public class HolderAssert extends AbstractHolderAssert<HolderAssert, Holder> {
   (..)
}
import org.assertj.core.api.AbstractObjectAssert;
import org.assertj.core.internal.Iterables;
import org.assertj.core.util.Objects;

public abstract class AbstractHolderAssert<S extends AbstractHolderAssert<S, A>, A extends Holder> extends AbstractObjectAssert<S, A> {

  (..)

  // class MyCustomClass not imported == compilation error -->
  public S hasValues(MyCustomClass... values) {
    (..)
  }
}
joel-costigliola commented 4 years ago

Thanks for reporting this! I don't have much time these days unfortunately but I can review a PR if someone is keen to tackle that issue.

joel-costigliola commented 4 years ago

This actually belong to https://github.com/joel-costigliola/assertj-assertions-generator