assertj / assertj/assertj-generator

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

Open
#133 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
72
Forks
47
Avg merge
1d 16h
Merged PRs (30d)
2

Description

Given a class:
```java
public class Blah {
private List sequences;
public List getSequences() { return sequences; }
}
```

the AbstractBlahAssert is generated with code such as:

```java
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:

```java
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
```

But not when it's an interface:

```java
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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.