diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateAppProfileRequest.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateAppProfileRequest.java index 1697b47f76..49d4c5d702 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateAppProfileRequest.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateAppProfileRequest.java @@ -151,11 +151,11 @@ public boolean equals(Object o) { UpdateAppProfileRequest that = (UpdateAppProfileRequest) o; return Objects.equal(instanceId, that.instanceId) && Objects.equal(appProfileId, that.appProfileId) - && Objects.equal(proto, that.proto); + && Objects.equal(proto.build(), that.proto.build()); } @Override public int hashCode() { - return Objects.hashCode(instanceId, appProfileId, proto); + return Objects.hashCode(instanceId, appProfileId, proto.build()); } } diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/AppProfileTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/AppProfileTest.java index f8d8f3fb66..64f334bb09 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/AppProfileTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/AppProfileTest.java @@ -114,4 +114,75 @@ public void testNoPolicyError() { assertThat(actualException).isInstanceOf(IllegalArgumentException.class); } + + @Test + public void testEquals() { + AppProfile profile = + AppProfile.fromProto( + com.google.bigtable.admin.v2.AppProfile.newBuilder() + .setName(AppProfileName.of("my-project", "my-instance", "my-profile").toString()) + .setDescription("my description") + .setMultiClusterRoutingUseAny( + com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny.newBuilder() + .addAllClusterIds(ImmutableList.of("cluster-id-1", "cluster-id-2")) + .build()) + .setEtag("my-etag") + .build()); + + UpdateAppProfileRequest updateAppProfileRequest = UpdateAppProfileRequest.of(profile); + UpdateAppProfileRequest updateAppProfileRequest2 = UpdateAppProfileRequest.of(profile); + + assertThat(updateAppProfileRequest).isEqualTo(updateAppProfileRequest2); + + AppProfile profile2 = + AppProfile.fromProto( + com.google.bigtable.admin.v2.AppProfile.newBuilder() + .setName(AppProfileName.of("my-project-2", "my-instance", "my-profile").toString()) + .setDescription("my description") + .setMultiClusterRoutingUseAny( + com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny.newBuilder() + .addAllClusterIds(ImmutableList.of("cluster-id-1", "cluster-id-2")) + .build()) + .setEtag("my-etag") + .build()); + UpdateAppProfileRequest updateAppProfileRequest3 = UpdateAppProfileRequest.of(profile2); + + assertThat(updateAppProfileRequest).isNotEqualTo(updateAppProfileRequest3); + } + + @Test + public void testHashCode() { + AppProfile profile = + AppProfile.fromProto( + com.google.bigtable.admin.v2.AppProfile.newBuilder() + .setName(AppProfileName.of("my-project", "my-instance", "my-profile").toString()) + .setDescription("my description") + .setMultiClusterRoutingUseAny( + com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny.newBuilder() + .addAllClusterIds(ImmutableList.of("cluster-id-1", "cluster-id-2")) + .build()) + .setEtag("my-etag") + .build()); + + UpdateAppProfileRequest updateAppProfileRequest = UpdateAppProfileRequest.of(profile); + UpdateAppProfileRequest updateAppProfileRequest2 = UpdateAppProfileRequest.of(profile); + + assertThat(updateAppProfileRequest.hashCode()).isEqualTo(updateAppProfileRequest2.hashCode()); + + AppProfile profile2 = + AppProfile.fromProto( + com.google.bigtable.admin.v2.AppProfile.newBuilder() + .setName(AppProfileName.of("my-project-2", "my-instance", "my-profile").toString()) + .setDescription("my description") + .setMultiClusterRoutingUseAny( + com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny.newBuilder() + .addAllClusterIds(ImmutableList.of("cluster-id-1", "cluster-id-2")) + .build()) + .setEtag("my-etag") + .build()); + UpdateAppProfileRequest updateAppProfileRequest3 = UpdateAppProfileRequest.of(profile2); + + assertThat(updateAppProfileRequest.hashCode()) + .isNotEqualTo(updateAppProfileRequest3.hashCode()); + } }