@@ -49,6 +49,7 @@ class ResumableFileDownloadSerializerTest {
49
49
private static final Instant DATE1 = parseIso8601Date ("2022-05-13T21:55:52.529Z" );
50
50
private static final Instant DATE2 = parseIso8601Date ("2022-05-15T21:50:11.308Z" );
51
51
private static final Map <String , GetObjectRequest > GET_OBJECT_REQUESTS ;
52
+ private static final String ETAG = "acbd18db4cc2f85cedef654fccc4a4d8" ;
52
53
53
54
static {
54
55
Map <String , GetObjectRequest > requests = new HashMap <>();
@@ -82,6 +83,7 @@ void serializeDeserialize_fromStoredString_ShouldWork() {
82
83
.getObjectRequest (GET_OBJECT_REQUESTS .get ("ALL_TYPES" )))
83
84
.bytesTransferred (1000L )
84
85
.fileLastModified (parseIso8601Date ("2022-03-08T10:15:30Z" ))
86
+ .s3ObjectEtag (ETAG )
85
87
.totalSizeInBytes (5000L )
86
88
.s3ObjectLastModified (parseIso8601Date ("2022-03-10T08:21:00Z" ))
87
89
.build ();
@@ -147,6 +149,7 @@ void serializeDeserialize_withCompletedParts_persistCompletedParts() {
147
149
.getObjectRequest (GET_OBJECT_REQUESTS .get ("ALL_TYPES" )))
148
150
.bytesTransferred (1000L )
149
151
.fileLastModified (parseIso8601Date ("2022-03-08T10:15:30Z" ))
152
+ .s3ObjectEtag (ETAG )
150
153
.totalSizeInBytes (5000L )
151
154
.s3ObjectLastModified (parseIso8601Date ("2022-03-10T08:21:00Z" ))
152
155
.completedParts (Arrays .asList (1 , 2 , 3 ))
@@ -170,26 +173,31 @@ public static Collection<ResumableFileDownload> downloadObjects() {
170
173
private static List <ResumableFileDownload > differentGetObjects () {
171
174
return GET_OBJECT_REQUESTS .values ()
172
175
.stream ()
173
- .map (request -> resumableFileDownload (1000L , null , DATE1 , null , downloadRequest (PATH , request )))
176
+ .map (request -> resumableFileDownload (1000L , null , DATE1 , null , null , downloadRequest (PATH ,
177
+ request )))
174
178
.collect (Collectors .toList ());
175
179
}
176
180
177
181
private static List <ResumableFileDownload > differentDownloadSettings () {
178
182
DownloadFileRequest request = downloadRequest (PATH , GET_OBJECT_REQUESTS .get ("STANDARD" ));
179
183
return Arrays .asList (
180
- resumableFileDownload (null , null , null , null , request ),
181
- resumableFileDownload (1000L , null , null , null , request ),
182
- resumableFileDownload (1000L , null , DATE1 , null , request ),
183
- resumableFileDownload (1000L , 2000L , DATE1 , DATE2 , request ),
184
- resumableFileDownload (Long .MAX_VALUE , Long .MAX_VALUE , DATE1 , DATE2 , request ),
185
- resumableFileDownload (1000L , 2000L , DATE1 , DATE2 , request , Arrays .asList (1 , 2 , 3 ))
184
+ resumableFileDownload (null , null , null , null , null , request ),
185
+ resumableFileDownload (1000L , null , null , null , null , request ),
186
+ resumableFileDownload (1000L , null , DATE1 , null , null , request ),
187
+ resumableFileDownload (1000L , 2000L , DATE1 , DATE2 , null , request ),
188
+ resumableFileDownload (Long .MAX_VALUE , Long .MAX_VALUE , DATE1 , DATE2 , null , request ),
189
+ resumableFileDownload (1000L , 2000L , DATE1 , DATE2 , null , request , Arrays .asList (1 , 2 , 3 )),
190
+ resumableFileDownload (1000L , 2000L , DATE1 , DATE2 , ETAG , request , Arrays .asList (1 , 2 , 3 )),
191
+ resumableFileDownload (1000L , 2000L , DATE1 , DATE2 , ETAG , request ),
192
+ resumableFileDownload (1000L , 2000L , DATE1 , null , ETAG , request )
186
193
);
187
194
}
188
195
189
196
private static ResumableFileDownload resumableFileDownload (Long bytesTransferred ,
190
197
Long totalSizeInBytes ,
191
198
Instant fileLastModified ,
192
199
Instant s3ObjectLastModified ,
200
+ String s3ObjectEtag ,
193
201
DownloadFileRequest request ) {
194
202
ResumableFileDownload .Builder builder = ResumableFileDownload .builder ()
195
203
.downloadFileRequest (request )
@@ -203,16 +211,20 @@ private static ResumableFileDownload resumableFileDownload(Long bytesTransferred
203
211
if (s3ObjectLastModified != null ) {
204
212
builder .s3ObjectLastModified (s3ObjectLastModified );
205
213
}
214
+ if (s3ObjectEtag != null ) {
215
+ builder .s3ObjectEtag (s3ObjectEtag );
216
+ }
206
217
return builder .build ();
207
218
}
208
219
private static ResumableFileDownload resumableFileDownload (Long bytesTransferred ,
209
220
Long totalSizeInBytes ,
210
221
Instant fileLastModified ,
211
222
Instant s3ObjectLastModified ,
223
+ String s3ObjectEtag ,
212
224
DownloadFileRequest request ,
213
225
List <Integer > completedParts ) {
214
226
ResumableFileDownload dl = resumableFileDownload (
215
- bytesTransferred , totalSizeInBytes , fileLastModified , s3ObjectLastModified , request );
227
+ bytesTransferred , totalSizeInBytes , fileLastModified , s3ObjectLastModified , s3ObjectEtag , request );
216
228
return dl .copy (b -> b .completedParts (completedParts ));
217
229
}
218
230
@@ -225,17 +237,21 @@ private static DownloadFileRequest downloadRequest(Path path, GetObjectRequest r
225
237
226
238
private static final String SERIALIZED_DOWNLOAD_OBJECT = "{\" bytesTransferred\" :1000,\" fileLastModified\" :1646734530.000,"
227
239
+ "\" totalSizeInBytes\" :5000,\" s3ObjectLastModified\" :1646900460"
228
- + ".000,\" downloadFileRequest\" :{\" destination\" :\" test/request\" ,"
240
+ + ".000,\" s3ObjectEtag\" :\" acbd18db4cc2f85cedef654fccc4a4d8\" ,"
241
+ + "\" downloadFileRequest\" :{\" destination\" :\" test/request\" ,"
229
242
+ "\" getObjectRequest\" :{\" Bucket\" :\" BUCKET\" ,"
230
243
+ "\" If-Modified-Since\" :1577880630.000,\" Key\" :\" KEY\" ,"
231
244
+ "\" x-amz-request-payer\" :\" requester\" ,\" partNumber\" :1,"
232
245
+ "\" x-amz-checksum-mode\" :\" ENABLED\" }},\" completedParts\" :[]}" ;
233
246
247
+
248
+
234
249
private static final String SERIALIZED_DOWNLOAD_OBJECT_WITH_COMPLETED_PARTS =
235
250
"{\" bytesTransferred\" :1000,"
236
251
+ "\" fileLastModified\" :1646734530.000,"
237
252
+ "\" totalSizeInBytes\" :5000,\" s3ObjectLastModified\" :1646900460"
238
- + ".000,\" downloadFileRequest\" :{\" destination\" :\" test/request\" ,"
253
+ + ".000,\" s3ObjectEtag\" :\" acbd18db4cc2f85cedef654fccc4a4d8\" ,"
254
+ + "\" downloadFileRequest\" :{\" destination\" :\" test/request\" ,"
239
255
+ "\" getObjectRequest\" :{\" Bucket\" :\" BUCKET\" ,"
240
256
+ "\" If-Modified-Since\" :1577880630.000,\" Key\" :\" KEY\" ,"
241
257
+ "\" x-amz-request-payer\" :\" requester\" ,\" partNumber\" :1,"
0 commit comments