Skip to content

Commit 678f049

Browse files
committed
Make ComputeException constructors package scoped, better test coverage
1 parent b0446ba commit 678f049

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

gcloud-java-compute/src/main/java/com/google/gcloud/compute/ComputeException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ public class ComputeException extends BaseServiceException {
3232
private static final Set<Error> RETRYABLE_ERRORS = ImmutableSet.of(new Error(500, null));
3333
private static final long serialVersionUID = -8039359778707845810L;
3434

35-
public ComputeException(int code, String message) {
35+
ComputeException(int code, String message) {
3636
super(code, message, null, true, null);
3737
}
3838

39-
private ComputeException(int code, String message, Throwable cause) {
39+
ComputeException(int code, String message, Throwable cause) {
4040
super(code, message, null, true, cause);
4141
}
4242

gcloud-java-compute/src/test/java/com/google/gcloud/compute/ComputeExceptionTest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static org.junit.Assert.assertEquals;
2424
import static org.junit.Assert.assertFalse;
2525
import static org.junit.Assert.assertNull;
26+
import static org.junit.Assert.assertSame;
2627
import static org.junit.Assert.assertTrue;
2728

2829
import com.google.gcloud.BaseServiceException;
@@ -57,7 +58,15 @@ public void testResourceManagerException() {
5758
assertNull(exception.getMessage());
5859
assertTrue(exception.retryable());
5960
assertTrue(exception.idempotent());
60-
assertEquals(cause, exception.getCause());
61+
assertSame(cause, exception.getCause());
62+
63+
exception = new ComputeException(403, "message", cause);
64+
assertEquals(403, exception.code());
65+
assertEquals("message", exception.getMessage());
66+
assertNull(exception.reason());
67+
assertFalse(exception.retryable());
68+
assertTrue(exception.idempotent());
69+
assertSame(cause, exception.getCause());
6170
}
6271

6372
@Test
@@ -88,7 +97,7 @@ public void testTranslateAndThrow() throws Exception {
8897
assertEquals("message", ex.getMessage());
8998
assertFalse(ex.retryable());
9099
assertTrue(ex.idempotent());
91-
assertEquals(cause, ex.getCause());
100+
assertSame(cause, ex.getCause());
92101
} finally {
93102
verify(exceptionMock);
94103
}

0 commit comments

Comments
 (0)