### Question:
SpannerExceptionUtil { public static R2dbcException createR2dbcException(int errorCode, String message) { return createR2dbcException(errorCode, message, null); }  static R2dbcException createR2dbcException(int errorCode, String message); static R2dbcException createR2dbcException(Throwable baseException);  }### Answer:
@Test public void testCreateR2dbcException() { R2dbcException exception = SpannerExceptionUtil.createR2dbcException( Code.ALREADY_EXISTS_VALUE, "test"); assertThat(exception).isInstanceOf(R2dbcDataIntegrityViolationException.class); assertThat(exception).hasMessage("test"); }
@Test public void testNonRetryableException() { assertThat(createR2dbcException(new IllegalArgumentException())) .isInstanceOf(R2dbcNonTransientResourceException.class); assertThat(createR2dbcException((new IOException()))) .isInstanceOf(R2dbcNonTransientResourceException.class); StatusRuntimeException nonRetryableException = new StatusRuntimeException(Status.PERMISSION_DENIED); assertThat(createR2dbcException(nonRetryableException)) .isInstanceOf(R2dbcPermissionDeniedException.class); }
@Test public void testRetryableInternalException() { StatusRuntimeException retryableException = new StatusRuntimeException( Status.INTERNAL.withDescription("HTTP/2 error code: INTERNAL_ERROR"), null); assertThat(createR2dbcException(retryableException)) .isInstanceOf(R2dbcTransientResourceException.class); }
@Test public void testRetryableExceptionWithDelay() { RetryInfo retryInfo = RetryInfo.newBuilder() .setRetryDelay(Duration.newBuilder().setSeconds(22L)) .build(); Metadata errorMetadata = new Metadata(); errorMetadata.put(ProtoUtils.keyForProto(RetryInfo.getDefaultInstance()), retryInfo); StatusRuntimeException retryableException = new StatusRuntimeException(Status.RESOURCE_EXHAUSTED, errorMetadata); assertThat(createR2dbcException(retryableException)) .isInstanceOf(R2dbcTransientResourceException.class); }