From 828bb82675683b277d56bc2a560ee4a513243198 Mon Sep 17 00:00:00 2001 From: Kristen O'Leary Date: Thu, 20 Jan 2022 17:23:32 -0500 Subject: [PATCH 1/3] fix: UpdateAppProfileRequest equals and hashcode should build proto --- .../v2/models/UpdateAppProfileRequest.java | 4 +- .../admin/v2/models/AppProfileTest.java | 70 +++++++++++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-) 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 1697b47f761a..49d4c5d7024b 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 f8d8f3fb661a..6d6ac0727cf0 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,74 @@ 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()); + } } From 7560ff816bde838fffc3815d5ab301f9b40eb8a8 Mon Sep 17 00:00:00 2001 From: Kristen O'Leary Date: Thu, 20 Jan 2022 17:46:34 -0500 Subject: [PATCH 2/3] lint --- .../admin/v2/models/AppProfileTest.java | 83 ++++++++++--------- 1 file changed, 42 insertions(+), 41 deletions(-) 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 6d6ac0727cf0..64f334bb09df 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 @@ -118,16 +118,16 @@ public void testNoPolicyError() { @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()); + 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); @@ -135,16 +135,16 @@ public void testEquals() { 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()); + 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); @@ -153,16 +153,16 @@ public void testEquals() { @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()); + 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); @@ -170,18 +170,19 @@ public void testHashCode() { 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()); + 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()); + assertThat(updateAppProfileRequest.hashCode()) + .isNotEqualTo(updateAppProfileRequest3.hashCode()); } } From 702ddc55d9bcb2438656acdb6fad185d887de129 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 20 Jan 2022 22:47:46 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../admin/v2/models/AppProfileTest.java | 83 ++++++++++--------- 1 file changed, 42 insertions(+), 41 deletions(-) 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 6d6ac0727cf0..64f334bb09df 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 @@ -118,16 +118,16 @@ public void testNoPolicyError() { @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()); + 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); @@ -135,16 +135,16 @@ public void testEquals() { 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()); + 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); @@ -153,16 +153,16 @@ public void testEquals() { @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()); + 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); @@ -170,18 +170,19 @@ public void testHashCode() { 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()); + 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()); + assertThat(updateAppProfileRequest.hashCode()) + .isNotEqualTo(updateAppProfileRequest3.hashCode()); } }