@Test
public void testGetError() {

  // Test the case where We get back an error set through an error code set in
  // TerrapinSingleResponse.
  ByteBuffer key = ByteBuffer.wrap(KEY);
  TerrapinGetRequest request = prepareGetRequest();
  TerrapinResponse response = new TerrapinResponse().setResponseMap(ImmutableMap.of(
      key, new TerrapinSingleResponse().setErrorCode(TerrapinGetErrorCode.OTHER)));
  when(mockClient1.getMany(eq(FILESET), eq(Sets.newHashSet(key)))).thenReturn(
      Future.value(response));
  Try<TerrapinSingleResponse> singleResponseTry = serviceIface.get(request).get(
      Duration.forever());
  assertTrue(singleResponseTry.isThrow());
  assertEquals(TerrapinGetErrorCode.OTHER,
      ((TerrapinGetException)((Throw)singleResponseTry).e()).getErrorCode());
  // Test the case where the call to the client library itself bails out due to a
  // legit error.
  when(mockClient1.getMany(eq(FILESET), eq(Sets.newHashSet(key)))).thenReturn(
          Future.<TerrapinResponse>exception(new TerrapinGetException("Failed.",
                  TerrapinGetErrorCode.FILE_SET_NOT_FOUND)));
  singleResponseTry = serviceIface.get(request).get(Duration.forever());
  assertTrue(singleResponseTry.isThrow());
  assertEquals(TerrapinGetErrorCode.FILE_SET_NOT_FOUND,
      ((TerrapinGetException)((Throw)singleResponseTry).e()).getErrorCode());
  // Test the case where the call to the client library bails out due to a runtime
  // exception.
  when(mockClient1.getMany(eq(FILESET), eq(Sets.newHashSet(key)))).thenThrow(
      new RuntimeException(new NullPointerException()));
  singleResponseTry = serviceIface.get(request).get(Duration.forever());
  assertTrue(singleResponseTry.isThrow());
  assertEquals(TerrapinGetErrorCode.OTHER,
      ((TerrapinGetException)((Throw)singleResponseTry).e()).getErrorCode());
}