### Question:
UpdateOrientationRoutine implements OrientationSensor.Listener { @Override public void onOrientationChanged(final int degrees) { cameraExecutor.execute(new Runnable() { @Override public void run() { try { cameraDevice.setDisplayOrientation(degrees); } catch (RuntimeException e) { logger.log("Failed to perform cameraDevice.setDisplayOrientation(" + degrees + ") e: " + e.getMessage()); } } }); } UpdateOrientationRoutine(CameraDevice cameraDevice,
                                    OrientationSensor orientationSensor,
                                    Executor cameraExecutor,
                                    Logger logger); void start(); void stop(); @Override void onOrientationChanged(final int degrees);  }### Answer:
@Test public void onOrientationChanged() throws Exception { testee.onOrientationChanged(90); verify(cameraDevice).setDisplayOrientation(90); verifyZeroInteractions(logger); }
@Test public void onOrientationChangedFailed() throws Exception { RuntimeException exception = new RuntimeException("test"); doThrow(exception) .when(cameraDevice) .setDisplayOrientation(anyInt()); testee.onOrientationChanged(90); verify(cameraDevice).setDisplayOrientation(90); verify(logger).log(anyString()); }