private static ArchiveRetrievalJobRequest buildArchiveRetrievalRequest( String key, GetOptions getOptions) { ArchiveRetrievalJobRequest.Builder requestBuilder = ArchiveRetrievalJobRequest.builder().archiveId(key); if (getOptions != null) { int size = getOptions.getRanges().size(); checkArgument(size <= 1, "The number of ranges should be zero or one"); if (size == 1) { requestBuilder.range(ContentRange.fromString(getOptions.getRanges().get(0))); } } return requestBuilder.build(); }
@Test(groups = {"live", "livelong", "longtest"}) public void testCompleteMultipartUpload() { String uploadId = api.initiateMultipartUpload(VAULT_NAME, PART_SIZE); ImmutableMap.Builder<Integer, HashCode> hashes = ImmutableMap.builder(); hashes.put( 0, api.uploadPart( VAULT_NAME, uploadId, ContentRange.fromPartNumber(0, PART_SIZE), buildPayload(PART_SIZE * MiB))); hashes.put( 1, api.uploadPart( VAULT_NAME, uploadId, ContentRange.fromPartNumber(1, PART_SIZE), buildPayload(PART_SIZE * MiB))); archiveId = api.completeMultipartUpload(VAULT_NAME, uploadId, hashes.build(), PART_SIZE * 2 * MiB); assertThat(archiveId).isNotNull(); }