Skip to content

Commit

Permalink
Make ComputeException constructors package scoped, better test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mziccard committed Apr 20, 2016
1 parent b0446ba commit 678f049
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public class ComputeException extends BaseServiceException {
private static final Set<Error> RETRYABLE_ERRORS = ImmutableSet.of(new Error(500, null));
private static final long serialVersionUID = -8039359778707845810L;

public ComputeException(int code, String message) {
ComputeException(int code, String message) {
super(code, message, null, true, null);
}

private ComputeException(int code, String message, Throwable cause) {
ComputeException(int code, String message, Throwable cause) {
super(code, message, null, true, cause);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import com.google.gcloud.BaseServiceException;
Expand Down Expand Up @@ -57,7 +58,15 @@ public void testResourceManagerException() {
assertNull(exception.getMessage());
assertTrue(exception.retryable());
assertTrue(exception.idempotent());
assertEquals(cause, exception.getCause());
assertSame(cause, exception.getCause());

exception = new ComputeException(403, "message", cause);
assertEquals(403, exception.code());
assertEquals("message", exception.getMessage());
assertNull(exception.reason());
assertFalse(exception.retryable());
assertTrue(exception.idempotent());
assertSame(cause, exception.getCause());
}

@Test
Expand Down Expand Up @@ -88,7 +97,7 @@ public void testTranslateAndThrow() throws Exception {
assertEquals("message", ex.getMessage());
assertFalse(ex.retryable());
assertTrue(ex.idempotent());
assertEquals(cause, ex.getCause());
assertSame(cause, ex.getCause());
} finally {
verify(exceptionMock);
}
Expand Down

0 comments on commit 678f049

Please sign in to comment.