GoogleCloudStorageExceptions { public static IOException createCompositeException(Collection<IOException> innerExceptions) { checkArgument( innerExceptions != null && !innerExceptions.isEmpty(), "innerExceptions (%s) must be not null and contain at least one element", innerExceptions); Iterator<IOException> innerExceptionIterator = innerExceptions.iterator(); if (innerExceptions.size() == 1) { return innerExceptionIterator.next(); } IOException combined = new IOException("Multiple IOExceptions."); while (innerExceptionIterator.hasNext()) { combined.addSuppressed(innerExceptionIterator.next()); } return combined; } private  GoogleCloudStorageExceptions(); static FileNotFoundException createFileNotFoundException(
      String bucketName, String objectName, @Nullable IOException cause); static FileNotFoundException createFileNotFoundException(
      StorageResourceId resourceId, @Nullable IOException cause); static IOException createCompositeException(Collection<IOException> innerExceptions); static GoogleJsonResponseException createJsonResponseException(
      GoogleJsonError e, HttpHeaders responseHeaders);  }
@Test public void testConstructorThrowsWhenInnerExceptionsAreEmpty() { List<IOException> emptyList = ImmutableList.of(); assertThrows(IllegalArgumentException.class, () -> createCompositeException(emptyList)); }
@Test public void testConstructorThrowsWhenInnerExceptionsAreNull() { assertThrows( IllegalArgumentException.class, () -> createCompositeException( null)); }
@Test public void createCompositeException_withSingleInnerException() { IOException inner = new IOException("inner exception"); IOException compositeException = createCompositeException(ImmutableList.of(inner)); assertThat(inner).isSameInstanceAs(compositeException); }
@Test public void createCompositeException_withMultipleInnerExceptions() { IOException inner1 = new IOException("inner exception 1"); IOException inner2 = new IOException("inner exception 2"); IOException compositeException = createCompositeException(ImmutableList.of(inner1, inner2)); assertThat(inner1).isNotSameInstanceAs(compositeException); assertThat(inner2).isNotSameInstanceAs(compositeException); assertThat(compositeException).hasMessageThat().isEqualTo("Multiple IOExceptions."); assertThat(compositeException.getSuppressed()).isEqualTo(new Throwable[] {inner1, inner2}); assertThat(compositeException.getSuppressed()[0]).isSameInstanceAs(inner1); assertThat(compositeException.getSuppressed()[1]).isSameInstanceAs(inner2); }