### Question:
LevelState extends State { @Override public void attach(@NonNull final StateDraweeView view) { view.setOnLevelListener(new StateDraweeView.OnLevelListener() { @Override public void onLevelChange(@NonNull View view1, int level) { setDrawable((StateDraweeView) view1, level); } }); setDrawable(view, defaultLevel); } LevelState(int defaultLevel, @DrawableRes int defaultRes); @Override void attach(@NonNull final StateDraweeView view); @Override void detach(@NonNull final StateDraweeView view); @Override String toString();  }### Answer:
@Test public void test_Attach() { StateDraweeView view = Mockito.spy(new StateDraweeView(RuntimeEnvironment.application)); LevelState state = new LevelState(0, R.drawable.ui_ic_clear); state.attach(view); Mockito.verify(view).setOnLevelListener(Mockito.any(StateDraweeView.OnLevelListener.class)); }