I've stumbled on an issue where AssertJ generates the following code in one of the assertion classes:
public S hasItems(interface ItemInterface... items)
This of course doesn't compile.
An example code that causes the problem is as follows:
public interface EntityInterface {
Set<? extends ItemInterface> getItems();
}
@NoArgsConstructor
@AllArgsConstructor
@Data
@With
public class EntityA implements EntityInterface {
private Set<ItemA> items;
}
@NoArgsConstructor
@AllArgsConstructor
@Data
@With
public class EntityA implements EntityInterface {
private Set<ItemA> items;
}
public interface ItemInterface {
String getName();
}
public class ItemA implements ItemInterface {
public String getName() {
return "ItemA";
}
}
public class ItemA implements ItemInterface {
public String getName() {
return "ItemA";
}
}
I've included the minimum example project that causes this error, so it can be seen firsthand. It can be downloaded from filebin
We're using Lombok's @With annotation among other considerations and need to keep the interfaces.
To fix this, I have tried:
- Changing the getItems method signature to:
<T extends ItemInterface> Set<T> getItems();
which produces:
public S hasItems(T... items)
however T is not known in the context.
- Turning the inteface into a template using:
public interface EntityInterface<T extends ItemInterface>
which didn't make any difference.
Is there a solution that I'm missing?