Skip to content

Commit c9f1ed8

Browse files
fix: UpdateAppProfileRequest equals and hashcode should build proto (#1142)
* fix: UpdateAppProfileRequest equals and hashcode should build proto * lint * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent dfb6085 commit c9f1ed8

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateAppProfileRequest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ public boolean equals(Object o) {
151151
UpdateAppProfileRequest that = (UpdateAppProfileRequest) o;
152152
return Objects.equal(instanceId, that.instanceId)
153153
&& Objects.equal(appProfileId, that.appProfileId)
154-
&& Objects.equal(proto, that.proto);
154+
&& Objects.equal(proto.build(), that.proto.build());
155155
}
156156

157157
@Override
158158
public int hashCode() {
159-
return Objects.hashCode(instanceId, appProfileId, proto);
159+
return Objects.hashCode(instanceId, appProfileId, proto.build());
160160
}
161161
}

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/AppProfileTest.java

+71
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,75 @@ public void testNoPolicyError() {
114114

115115
assertThat(actualException).isInstanceOf(IllegalArgumentException.class);
116116
}
117+
118+
@Test
119+
public void testEquals() {
120+
AppProfile profile =
121+
AppProfile.fromProto(
122+
com.google.bigtable.admin.v2.AppProfile.newBuilder()
123+
.setName(AppProfileName.of("my-project", "my-instance", "my-profile").toString())
124+
.setDescription("my description")
125+
.setMultiClusterRoutingUseAny(
126+
com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny.newBuilder()
127+
.addAllClusterIds(ImmutableList.of("cluster-id-1", "cluster-id-2"))
128+
.build())
129+
.setEtag("my-etag")
130+
.build());
131+
132+
UpdateAppProfileRequest updateAppProfileRequest = UpdateAppProfileRequest.of(profile);
133+
UpdateAppProfileRequest updateAppProfileRequest2 = UpdateAppProfileRequest.of(profile);
134+
135+
assertThat(updateAppProfileRequest).isEqualTo(updateAppProfileRequest2);
136+
137+
AppProfile profile2 =
138+
AppProfile.fromProto(
139+
com.google.bigtable.admin.v2.AppProfile.newBuilder()
140+
.setName(AppProfileName.of("my-project-2", "my-instance", "my-profile").toString())
141+
.setDescription("my description")
142+
.setMultiClusterRoutingUseAny(
143+
com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny.newBuilder()
144+
.addAllClusterIds(ImmutableList.of("cluster-id-1", "cluster-id-2"))
145+
.build())
146+
.setEtag("my-etag")
147+
.build());
148+
UpdateAppProfileRequest updateAppProfileRequest3 = UpdateAppProfileRequest.of(profile2);
149+
150+
assertThat(updateAppProfileRequest).isNotEqualTo(updateAppProfileRequest3);
151+
}
152+
153+
@Test
154+
public void testHashCode() {
155+
AppProfile profile =
156+
AppProfile.fromProto(
157+
com.google.bigtable.admin.v2.AppProfile.newBuilder()
158+
.setName(AppProfileName.of("my-project", "my-instance", "my-profile").toString())
159+
.setDescription("my description")
160+
.setMultiClusterRoutingUseAny(
161+
com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny.newBuilder()
162+
.addAllClusterIds(ImmutableList.of("cluster-id-1", "cluster-id-2"))
163+
.build())
164+
.setEtag("my-etag")
165+
.build());
166+
167+
UpdateAppProfileRequest updateAppProfileRequest = UpdateAppProfileRequest.of(profile);
168+
UpdateAppProfileRequest updateAppProfileRequest2 = UpdateAppProfileRequest.of(profile);
169+
170+
assertThat(updateAppProfileRequest.hashCode()).isEqualTo(updateAppProfileRequest2.hashCode());
171+
172+
AppProfile profile2 =
173+
AppProfile.fromProto(
174+
com.google.bigtable.admin.v2.AppProfile.newBuilder()
175+
.setName(AppProfileName.of("my-project-2", "my-instance", "my-profile").toString())
176+
.setDescription("my description")
177+
.setMultiClusterRoutingUseAny(
178+
com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny.newBuilder()
179+
.addAllClusterIds(ImmutableList.of("cluster-id-1", "cluster-id-2"))
180+
.build())
181+
.setEtag("my-etag")
182+
.build());
183+
UpdateAppProfileRequest updateAppProfileRequest3 = UpdateAppProfileRequest.of(profile2);
184+
185+
assertThat(updateAppProfileRequest.hashCode())
186+
.isNotEqualTo(updateAppProfileRequest3.hashCode());
187+
}
117188
}

0 commit comments

Comments
 (0)