assertj-assertions-generator
assertj-assertions-generator copied to clipboard
hasXXX assertions generate invalid code when XXX is an Iterable of an interface type.
Given a class:
public class Blah {
private List<CharSequence> sequences;
public List<CharSequence> getSequences() { return sequences; }
}
the AbstractBlahAssert is generated with code such as:
public S hasSequences(interface java.lang.CharSequence... sequences) { ... }
(note the "interface" keyword in there.)
This is the result of org.assertj.assertions.generator.util.ClassUtil#getTypeDeclaration correctly handling situations where the contained type is a class:
String name = typeVariable.getName(); // capture#1-of ? extends class java.lang.String
name = removeAll(name, "capture#\\d+-of\\s+"); // extends class java.lang.String
name = removeAll(name, " class"); // extends java.lang.String
typeDeclaration.append(name); // List<? extends java.lang.String>
But not when it's an interface:
String name = typeVariable.getName(); // capture#1-of ? extends interface java.lang.CharSequence
name = removeAll(name, "capture#\\d+-of\\s+"); // extends interface java.lang.CharSequence
name = removeAll(name, " class"); // extends interface java.lang.CharSequence
typeDeclaration.append(name); // List<? extends interface java.lang.CharSequence>
Thanks for reporting this ! I'm a bit afraid the generator has fallen under my radar, super busy at the moment :(
I'll try to review your PR in the next few weeks, ping me if I don't!