Source:
<code>public void verify_partitioned_buckets_in_download_presigned_urls() throws Exception { AmazonServiceException firstException = new AmazonServiceException("Didn't find Object Id in bucket"); firstException.setStatusCode(HttpStatus.NOT_FOUND.value()); int bucketPoolSize = 32; int bucketKeySize = 2; ReflectionTestUtils.setField(service, "bucketPoolSize", bucketPoolSize); ReflectionTestUtils.setField(service, "bucketKeySize", bucketKeySize); ObjectURLGenerator urlGen = new AmazonURLGenerator(); ReflectionTestUtils.setField(urlGen, "s3Client", ObjectDownloadServiceStubFactory.createS3ClientForRadosGW(endpointUrl)); ReflectionTestUtils.setField(service, "urlGenerator", urlGen); when(s3Client.getObject(Mockito.any())).thenThrow(firstException); <START> List<Part> parts = ObjectDownloadServiceStubFactory.createParts(5); END> ObjectSpecification os = ObjectDownloadServiceStubFactory.createObjectSpecification(objectId, ObjectKeys.getObjectKey(dataDir, objectId), 104857600); os.setParts(parts); os.setRelocated(false); ObjectDownloadService sut = spy(service); doReturn(os).when(sut).getSpecification(objectId); val objSpec = sut.download(objectId, 0, 104857600, false); Part p = objSpec.getParts().get(0); URL url = new URL(p.getUrl()); String path = url.getPath(); if (path.startsWith("/")) { path = path.substring(1, path.length() - 1); } String bucket = Splitter.on('/').trimResults().omitEmptyStrings().split(path).iterator().next(); assertTrue((dataBucketName.length() < bucket.length()) && (bucket.startsWith(dataBucketName))); Pattern pattern = Pattern.compile(".+\\.\\d+$"); assertTrue(pattern.matcher(bucket).matches()); System.out.println(); }</code><technical_language>A lot more vals please</technical_language>

Target:
public void verify_partitioned_buckets_in_download_presigned_urls() throws Exception { val firstException = new AmazonServiceException("Didn't find Object Id in bucket"); firstException.setStatusCode(HttpStatus.NOT_FOUND.value()); int bucketPoolSize = 32; int bucketKeySize = 2; namingService.setBucketPoolSize(bucketPoolSize); namingService.setBucketKeySize(bucketKeySize); val urlGen = new AmazonURLGenerator(); ReflectionTestUtils.setField(urlGen, "s3Client", ObjectDownloadServiceStubFactory.createS3ClientForRadosGW(endpointUrl)); ReflectionTestUtils.setField(service, "urlGenerator", urlGen); when(s3Client.getObject(Mockito.any())).thenThrow(firstException); val parts = ObjectDownloadServiceStubFactory.createParts(5); val os = ObjectDownloadServiceStubFactory.createObjectSpecification(objectId, ObjectKeys.getObjectKey(dataDir, objectId), 104857600); os.setParts(parts); os.setRelocated(false); val sut = spy(service); doReturn(os).when(sut).getSpecification(objectId); val objSpec = sut.download(objectId, 0, 104857600, false); val p = objSpec.getParts().get(0); val url = new URL(p.getUrl()); String path = url.getPath(); if (path.startsWith("/")) { path = path.substring(1, path.length() - 1); } val bucket = Splitter.on('/').trimResults().omitEmptyStrings().split(path).iterator().next(); assertTrue((objectBucketName.length() < bucket.length()) && (bucket.startsWith(objectBucketName))); val pattern = Pattern.compile(".+\\.\\d+$"); assertTrue(pattern.matcher(bucket).matches()); System.out.println(); }