SettableImageProxyBundle implements ImageProxyBundle { void addImageProxy(ImageProxy imageProxy) { synchronized (mLock) { if (mClosed) { return; } Integer captureId = (Integer) imageProxy.getImageInfo().getTag(); if (captureId == null) { throw new IllegalArgumentException("CaptureId is null."); } CallbackToFutureAdapter.Completer<ImageProxy> completer = mCompleters.get(captureId); if (completer != null) { mOwnedImageProxies.add(imageProxy); completer.set(imageProxy); } else { throw new IllegalArgumentException( "ImageProxyBundle does not contain this id: " + captureId); } } } SettableImageProxyBundle(List<Integer> captureIds); @Override ListenableFuture<ImageProxy> getImageProxy(int captureId); @Override List<Integer> getCaptureIds();  }
@Test(expected = IllegalArgumentException.class) public void exceptionWhenAddingImageWithInvalidCaptureId() { ImageInfo imageInfo = new FakeImageInfo(); ImageProxy imageProxy = new FakeImageProxy(); ((FakeImageInfo) imageInfo).setTag(CAPTURE_ID_NONEXISTANT); ((FakeImageProxy) imageProxy).setImageInfo(imageInfo); mImageProxyBundle.addImageProxy(imageProxy); }