2016-08-10 4 views
1

Java 8でAssertJ 3.5.2のConditionクラスの使用方法を調べるときにこの問題が発生しました。一般的な型のListに対してConditionインスタンスを作成できますが、エラーが発生しますEclipseのメッセージ私はそれを使用しよう:AssertJジェネリックの問題型付きリストの条件

Condition<List<MyBean>> listCond = 
     new Condition<>(list -> true, "test"); // OK 

this.assertThat(myList).has(listCond); // DOES NOT COMPILE 

私が取得エラーメッセージは次のとおりです。

The method has(Condition<? super List<? extends MyBean>>) in the type 
AbstractListAssert<capture#8-of ?,List<? extends MyBean>,MyBean,ObjectAssert<MyBean>> is not 
applicable for the arguments (Condition<List<MyBean>>) 

は、リストの全体的なチェックを行うにはAssertJで、このためのソリューションまたは別のアプローチがあります(アイテムだけでなく、シーケンスや集計に基づくチェック)?

答えて

2

私はこのようなあなたの状態を宣言すると、コンパイルエラーを解決する必要があることを信じている:

Condition<? super List<? extends MyBean>> listCond = new Condition<>(list -> true, "test"); 
関連する問題