File tree Expand file tree Collapse file tree
google-cloud-storage/src/test/java/com/google/cloud/storage Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5656import java .time .Clock ;
5757import java .time .OffsetDateTime ;
5858import java .time .ZoneOffset ;
59+ import java .time .temporal .ChronoUnit ;
5960import java .util .Arrays ;
6061import java .util .List ;
6162import java .util .stream .Collectors ;
@@ -316,7 +317,9 @@ public void batch() throws Exception {
316317 batch .submit ();
317318 assertAll (
318319 () -> assertThat (r1 ).isNotNull (),
319- () -> assertThat (r2 .get ().getCustomTimeOffsetDateTime ()).isEqualTo (now ),
320+ () ->
321+ assertThat (r2 .get ().getCustomTimeOffsetDateTime ().truncatedTo (ChronoUnit .MILLIS ))
322+ .isEqualTo (now .truncatedTo (ChronoUnit .MILLIS )),
320323 () -> assertThat (r3 .get ()).isTrue (),
321324 () -> {
322325 IterableSubject subject = headers .assertRequestHeader (batchHeaderKey );
Original file line number Diff line number Diff line change 4848import java .time .Clock ;
4949import java .time .OffsetDateTime ;
5050import java .time .ZoneOffset ;
51+ import java .time .temporal .ChronoUnit ;
5152import java .util .List ;
5253import java .util .stream .Collectors ;
5354import java .util .stream .IntStream ;
@@ -238,15 +239,17 @@ public void batchSuccessiveUpdatesWork() {
238239 })
239240 .collect (Collectors .toList ());
240241
241- OffsetDateTime now1 = Clock .systemUTC ().instant ().atOffset (ZoneOffset .UTC );
242+ OffsetDateTime now1 =
243+ Clock .systemUTC ().instant ().atOffset (ZoneOffset .UTC ).truncatedTo (ChronoUnit .MILLIS );
242244
243245 List <Blob > update1 =
244246 storage .update (
245247 blobs .stream ()
246248 .map (id -> BlobInfo .newBuilder (id ).setCustomTimeOffsetDateTime (now1 ).build ())
247249 .collect (Collectors .toList ()));
248250
249- OffsetDateTime now2 = Clock .systemUTC ().instant ().atOffset (ZoneOffset .UTC );
251+ OffsetDateTime now2 =
252+ Clock .systemUTC ().instant ().atOffset (ZoneOffset .UTC ).truncatedTo (ChronoUnit .MILLIS );
250253 List <Blob > update2 =
251254 storage .update (
252255 blobs .stream ()
@@ -255,7 +258,10 @@ public void batchSuccessiveUpdatesWork() {
255258
256259 assertThat (
257260 update2 .stream ()
258- .filter (b -> !now2 .equals (b .getCustomTimeOffsetDateTime ()))
261+ .filter (
262+ b ->
263+ !now2 .equals (
264+ b .getCustomTimeOffsetDateTime ().truncatedTo (ChronoUnit .MILLIS )))
259265 .map (BlobInfo ::getBlobId )
260266 .map (BlobId ::toGsUtilUriWithGeneration )
261267 .collect (Collectors .toList ()))
Original file line number Diff line number Diff line change 4747import java .time .Clock ;
4848import java .time .OffsetDateTime ;
4949import java .time .ZoneOffset ;
50+ import java .time .temporal .ChronoUnit ;
5051import java .util .Arrays ;
5152import java .util .List ;
5253import java .util .stream .Collectors ;
@@ -206,7 +207,9 @@ public void batch() throws Exception {
206207 batch .submit ();
207208 assertAll (
208209 () -> assertThat (r1 ).isNotNull (),
209- () -> assertThat (r2 .get ().getCustomTimeOffsetDateTime ()).isEqualTo (now ),
210+ () ->
211+ assertThat (r2 .get ().getCustomTimeOffsetDateTime ().truncatedTo (ChronoUnit .MILLIS ))
212+ .isEqualTo (now .truncatedTo (ChronoUnit .MILLIS )),
210213 () -> assertThat (r3 .get ()).isTrue (),
211214 () -> {
212215 IterableSubject subject =
You can’t perform that action at this time.
0 commit comments