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

hasXXX assertions generate invalid code when XXX is an Iterable of an interface type. #133

Open
martinlau opened this issue Sep 30, 2019 · 1 comment · May be fixed by #134
Open

hasXXX assertions generate invalid code when XXX is an Iterable of an interface type. #133

martinlau opened this issue Sep 30, 2019 · 1 comment · May be fixed by #134

Comments

@martinlau
Copy link

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>
@martinlau martinlau changed the title hasBlah assertions generate invalid code when Blah is an Iterable of an interface. hasXXX assertions generate invalid code when XXX is an Iterable of an interface type. Sep 30, 2019
martinlau pushed a commit to martinlau/assertj-assertions-generator that referenced this issue Sep 30, 2019
@joel-costigliola
Copy link
Member

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!

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

Successfully merging a pull request may close this issue.

2 participants