ViewTarget implements Target<Bitmap>, DrawableFactory { public MirageTask go() { if (request == null) throw new IllegalStateException("Can not call this method without settings request instance"); if (isFit) { View v = getView(); if (v != null) { if (v.getWidth() > 0 && v.getHeight() > 0) { request.dynamicResample(Math.max(v.getWidth(), v.getHeight())); request.resize(v.getWidth(), v.getHeight()); } else { fitImageLater(); mirageTask = request.createGoTask(); return mirageTask; } } } return request.go(); } ViewTarget(V view);  ViewTarget(MirageRequest request, V view); V getView(); ViewTarget<V> placeHolder(@DrawableRes int resourceId); ViewTarget<V> placeHolder(Drawable drawable); ViewTarget<V> error(@DrawableRes int resourceId); ViewTarget<V> error(Drawable drawable); ViewTarget<V> animation(MirageAnimation<V> animation); MirageAnimation<V> animation(); ViewTarget<V> fade(); ViewTarget<V> fit(); ViewTarget<V> drawableFactory(DrawableFactory factory); MirageTask go(); Drawable getPlaceHolderDrawable(); int getPlaceHolderResourceId(); Drawable getErrorDrawable(); int getErrorResourceId(); @Override void onPreparingLoad(); @Override void onResult(Bitmap bitmap, Mirage.Source source, MirageRequest request); @Override void onError(Exception e, Mirage.Source source, MirageRequest request); @Override void onCancel(); @Override Drawable createDrawable(Context context, Bitmap bitmap);  }
@Test public void testGo() { Mirage mirage = Mockito.mock(Mirage.class); MirageRequest request = new MirageRequest(); request.mirage(mirage).uri(Uri.parse("http: Mockito.when(mirage.go((MirageRequest)Mockito.any())).thenReturn(Mockito.mock(MirageTask.class)); ImageView imageView = new ImageView(RuntimeEnvironment.application); ImageViewTarget target = new ImageViewTarget(request, imageView); target.go(); Mockito.verify(mirage, Mockito.times(1)).go(request); }
@Test public void testGoWithNoRequest() { ImageView imageView = new ImageView(RuntimeEnvironment.application); ImageViewTarget target = new ImageViewTarget(imageView); try { target.go(); Assert.fail("This should thrown an error without a request on it"); } catch (IllegalStateException e) { Assert.assertNotNull(e); } }