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

Using generateAssertionsInPackage in Maven results in compilation issues #135

Open
bbottema opened this issue Dec 3, 2019 · 2 comments
Open

Comments

@bbottema
Copy link

bbottema commented Dec 3, 2019

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
Copy link
Member

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
Copy link
Member

@joel-costigliola joel-costigliola transferred this issue from assertj/assertj Dec 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants