私は、GWT MVP フレームワーク + GWT Editors フレームワークを使用していくつかの小さなプロジェクトに取り組んできました。次のように宣言されたフィールドを持つ Views インターフェイスがあります。
@Path("field")
IsEditor<ValueBoxEditor<Long>> getField();
ビューの実装は次のようになります。
@UiField
IsEditor<ValueBoxEditor<Long>> field;
public IsEditor<ValueBoxEditor<Long>> getField(){
return field;
}
私のアクティビティには、対応するビューへの参照があり、(アクティビティで)次のようなことをしなければならない場合:
view.getField.setEnable(true);
にキャストする必要があります
((ValueBoxBase<Long>)view.getField()).setEnable(true);
その後、このユニットをテストすることはできません。私のテストでは、結果としてMock(IsEditor<ValueBoxEditor<Long>>)
を返すように View の動作を定義しているためです。view.getFiled()
java.lang.ClassCastException: com.google.gwt.editor.client.IsEditor$
$EnhancerByMockitoWithCGLIB$$e8c00c36 cannot be cast to
com.google.gwt.user.client.ui.ValueBoxBase
キャストを行わずにActivityからViewsコンポーネントのメソッドを呼び出すベストプラクティスは何ですか?