Skip to content

Commit 4b2352a

Browse files
committed
---
yaml --- r: 6351 b: refs/heads/tswast-patch-1 c: 4db34b7 h: refs/heads/master i: 6349: 75009ab 6347: 2ec885e 6343: 5b36928 6335: a353f43
1 parent 309d8ef commit 4b2352a

4 files changed

Lines changed: 84 additions & 4 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: 10e1cb4e548e7df576b2e3125d5bb08d3e8b559d
60+
refs/heads/tswast-patch-1: 4db34b7d4e4e3949ffb9d5647a67a8c06497e301
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BatchResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public boolean equals(Object obj) {
133133
BatchResponse other = (BatchResponse) obj;
134134
return Objects.equals(deleteResult, other.deleteResult)
135135
&& Objects.equals(updateResult, other.updateResult)
136-
&& Objects.equals(updateResult, other.updateResult);
136+
&& Objects.equals(getResult, other.getResult);
137137
}
138138

139139
/**

branches/tswast-patch-1/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BatchRequestTest.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static com.google.gcloud.storage.Storage.PredefinedAcl.PUBLIC_READ;
2020
import static org.junit.Assert.assertEquals;
2121
import static org.junit.Assert.assertFalse;
22+
import static org.junit.Assert.assertNotEquals;
2223
import static org.junit.Assert.assertTrue;
2324

2425
import com.google.common.collect.Iterables;
@@ -82,4 +83,56 @@ public void testBatchRequest() {
8283
assertTrue(Iterables.isEmpty(get.getValue()));
8384
assertFalse(gets.hasNext());
8485
}
86+
87+
@Test
88+
public void testEquals() {
89+
BatchRequest request = BatchRequest.builder()
90+
.delete("b1", "o1")
91+
.delete("b1", "o2")
92+
.update(BlobInfo.builder("b2", "o1").build())
93+
.update(BlobInfo.builder("b2", "o2").build())
94+
.get("b3", "o1")
95+
.get("b3", "o2")
96+
.build();
97+
BatchRequest requestEquals = BatchRequest.builder()
98+
.delete("b1", "o1")
99+
.delete("b1", "o2")
100+
.update(BlobInfo.builder("b2", "o1").build())
101+
.update(BlobInfo.builder("b2", "o2").build())
102+
.get("b3", "o1")
103+
.get("b3", "o2")
104+
.build();
105+
BatchRequest requestNotEquals1 = BatchRequest.builder()
106+
.delete("b1", "o1")
107+
.delete("b1", "o3")
108+
.update(BlobInfo.builder("b2", "o1").build())
109+
.update(BlobInfo.builder("b2", "o2").build())
110+
.get("b3", "o1")
111+
.get("b3", "o2")
112+
.build();
113+
BatchRequest requestNotEquals2 = BatchRequest.builder()
114+
.delete("b1", "o1")
115+
.delete("b1", "o2")
116+
.update(BlobInfo.builder("b2", "o1").build())
117+
.update(BlobInfo.builder("b2", "o3").build())
118+
.get("b3", "o1")
119+
.get("b3", "o2")
120+
.build();
121+
BatchRequest requestNotEquals3 = BatchRequest.builder()
122+
.delete("b1", "o1")
123+
.delete("b1", "o2")
124+
.update(BlobInfo.builder("b2", "o1").build())
125+
.update(BlobInfo.builder("b2", "o2").build())
126+
.get("b3", "o1")
127+
.get("b3", "o3")
128+
.build();
129+
assertEquals(request, requestEquals);
130+
assertEquals(request.hashCode(), requestEquals.hashCode());
131+
assertNotEquals(request, requestNotEquals1);
132+
assertNotEquals(request.hashCode(), requestNotEquals1.hashCode());
133+
assertNotEquals(request, requestNotEquals2);
134+
assertNotEquals(request.hashCode(), requestNotEquals2.hashCode());
135+
assertNotEquals(request, requestNotEquals3);
136+
assertNotEquals(request.hashCode(), requestNotEquals3.hashCode());
137+
}
85138
}

branches/tswast-patch-1/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BatchResponseTest.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.gcloud.storage;
1818

1919
import static org.junit.Assert.assertEquals;
20+
import static org.junit.Assert.assertNotEquals;
2021

2122
import com.google.common.collect.ImmutableList;
2223
import com.google.gcloud.storage.BatchResponse.Result;
@@ -34,12 +35,38 @@ public class BatchResponseTest {
3435
@Test
3536
public void testBatchResponse() {
3637
List<Result<Boolean>> deletes = ImmutableList.of(Result.of(true), Result.of(false));
37-
List<Result<BlobInfo>> updates = ImmutableList.of(Result.of(BLOB_INFO_1), Result.of(BLOB_INFO_2));
38+
List<Result<BlobInfo>> updates =
39+
ImmutableList.of(Result.of(BLOB_INFO_1), Result.of(BLOB_INFO_2));
3840
List<Result<BlobInfo>> gets = ImmutableList.of(Result.of(BLOB_INFO_2), Result.of(BLOB_INFO_3));
3941
BatchResponse response = new BatchResponse(deletes, updates, gets);
40-
4142
assertEquals(deletes, response.deletes());
4243
assertEquals(updates, response.updates());
4344
assertEquals(gets, response.gets());
4445
}
46+
47+
@Test
48+
public void testEquals() {
49+
List<Result<Boolean>> deletes = ImmutableList.of(Result.of(true), Result.of(false));
50+
List<Result<BlobInfo>> updates =
51+
ImmutableList.of(Result.of(BLOB_INFO_1), Result.of(BLOB_INFO_2));
52+
List<Result<BlobInfo>> gets = ImmutableList.of(Result.of(BLOB_INFO_2), Result.of(BLOB_INFO_3));
53+
List<Result<Boolean>> otherDeletes = ImmutableList.of(Result.of(false), Result.of(true));
54+
List<Result<BlobInfo>> otherUpdates =
55+
ImmutableList.of(Result.of(BLOB_INFO_2), Result.of(BLOB_INFO_3));
56+
List<Result<BlobInfo>> otherGets =
57+
ImmutableList.of(Result.of(BLOB_INFO_1), Result.of(BLOB_INFO_2));
58+
BatchResponse response = new BatchResponse(deletes, updates, gets);
59+
BatchResponse responseEquals = new BatchResponse(deletes, updates, gets);
60+
BatchResponse responseNotEquals1 = new BatchResponse(otherDeletes, updates, gets);
61+
BatchResponse responseNotEquals2 = new BatchResponse(deletes, otherUpdates, gets);
62+
BatchResponse responseNotEquals3 = new BatchResponse(deletes, updates, otherGets);
63+
assertEquals(response, responseEquals);
64+
assertEquals(response.hashCode(), responseEquals.hashCode());
65+
assertNotEquals(response, responseNotEquals1);
66+
assertNotEquals(response.hashCode(), responseNotEquals1.hashCode());
67+
assertNotEquals(response, responseNotEquals2);
68+
assertNotEquals(response.hashCode(), responseNotEquals2.hashCode());
69+
assertNotEquals(response, responseNotEquals3);
70+
assertNotEquals(response.hashCode(), responseNotEquals3.hashCode());
71+
}
4572
}

0 commit comments

Comments
 (0)