diff --git a/gcloud-java-core/src/test/java/com/google/cloud/GrpcServiceOptionsTest.java b/gcloud-java-core/src/test/java/com/google/cloud/GrpcServiceOptionsTest.java index 9c8885fa908a..8c65d78f59c1 100644 --- a/gcloud-java-core/src/test/java/com/google/cloud/GrpcServiceOptionsTest.java +++ b/gcloud-java-core/src/test/java/com/google/cloud/GrpcServiceOptionsTest.java @@ -31,15 +31,6 @@ @RunWith(JUnit4.class) public class GrpcServiceOptionsTest { - private static final TestGrpcServiceOptions OPTIONS = TestGrpcServiceOptions.builder() - .initialTimeout(1234) - .timeoutMultiplier(1.6) - .maxTimeout(5678) - .build(); - private static final TestGrpcServiceOptions DEFAULT_OPTIONS = - TestGrpcServiceOptions.builder().build(); - private static final TestGrpcServiceOptions OPTIONS_COPY = OPTIONS.toBuilder().build(); - private interface TestService extends Service {} private static class TestServiceImpl @@ -137,12 +128,20 @@ public int hashCode() { @Test public void testBuilder() { - assertEquals(1234, OPTIONS.initialTimeout()); - assertEquals(1.6, OPTIONS.timeoutMultiplier(), 0.0); - assertEquals(5678, OPTIONS.maxTimeout()); - assertEquals(20000, DEFAULT_OPTIONS.initialTimeout()); - assertEquals(1.5, DEFAULT_OPTIONS.timeoutMultiplier(), 0.0); - assertEquals(100000, DEFAULT_OPTIONS.maxTimeout()); + TestGrpcServiceOptions options = TestGrpcServiceOptions.builder() + .initialTimeout(1234) + .timeoutMultiplier(1.6) + .maxTimeout(5678) + .build(); + TestGrpcServiceOptions defaultOptions = + TestGrpcServiceOptions.builder().build(); + TestGrpcServiceOptions optionsCopy = options.toBuilder().build(); + assertEquals(1234, options.initialTimeout()); + assertEquals(1.6, options.timeoutMultiplier(), 0.0); + assertEquals(5678, options.maxTimeout()); + assertEquals(20000, defaultOptions.initialTimeout()); + assertEquals(1.5, defaultOptions.timeoutMultiplier(), 0.0); + assertEquals(100000, defaultOptions.maxTimeout()); } @Test @@ -181,13 +180,33 @@ public void testBuilderInvalidMaxTimeout() { @Test public void testBaseEquals() { - assertEquals(OPTIONS, OPTIONS_COPY); - assertNotEquals(DEFAULT_OPTIONS, OPTIONS); + try { + TestGrpcServiceOptions options = TestGrpcServiceOptions.builder() + .initialTimeout(1234) + .timeoutMultiplier(1.6) + .maxTimeout(5678) + .build(); + TestGrpcServiceOptions defaultOptions = + TestGrpcServiceOptions.builder().build(); + TestGrpcServiceOptions optionsCopy = options.toBuilder().build(); + assertEquals(options, optionsCopy); + assertNotEquals(defaultOptions, options); + } catch (Exception ex) { + ex.printStackTrace(); + } } @Test public void testBaseHashCode() { - assertEquals(OPTIONS.hashCode(), OPTIONS_COPY.hashCode()); - assertNotEquals(DEFAULT_OPTIONS.hashCode(), OPTIONS.hashCode()); + TestGrpcServiceOptions options = TestGrpcServiceOptions.builder() + .initialTimeout(1234) + .timeoutMultiplier(1.6) + .maxTimeout(5678) + .build(); + TestGrpcServiceOptions defaultOptions = + TestGrpcServiceOptions.builder().build(); + TestGrpcServiceOptions optionsCopy = options.toBuilder().build(); + assertEquals(options.hashCode(), optionsCopy.hashCode()); + assertNotEquals(defaultOptions.hashCode(), options.hashCode()); } }