use of com.epam.pipeline.entity.datastorage.DataStorageException in project cloud-pipeline by epam.
the class S3HelperTest method testMoveFileShouldThrowIfFileSizeExceedsTheLimit.
@Test
public void testMoveFileShouldThrowIfFileSizeExceedsTheLimit() {
final ObjectListing singleFileListing = new ObjectListing();
singleFileListing.setCommonPrefixes(Collections.singletonList(OLD_PATH));
when(amazonS3.listObjects(any(ListObjectsRequest.class))).thenReturn(singleFileListing);
final ObjectMetadata fileMetadata = new ObjectMetadata();
fileMetadata.setContentLength(EXCEEDED_OBJECT_SIZE);
when(amazonS3.getObjectMetadata(any())).thenReturn(fileMetadata);
assertThrows(e -> e instanceof DataStorageException && e.getMessage().contains(SIZE_EXCEEDS_EXCEPTION_MESSAGE), () -> helper.moveFile(BUCKET, OLD_PATH, NEW_PATH));
}
use of com.epam.pipeline.entity.datastorage.DataStorageException in project cloud-pipeline by epam.
the class S3HelperTest method testMoveFolderShouldThrowIfAtLeastOneOfItsFilesSizeExceedTheLimit.
@Test
public void testMoveFolderShouldThrowIfAtLeastOneOfItsFilesSizeExceedTheLimit() {
final ObjectListing sourceListing = new ObjectListing();
sourceListing.setCommonPrefixes(Collections.singletonList(OLD_PATH));
final ObjectListing destinationListing = new ObjectListing();
destinationListing.setCommonPrefixes(Collections.emptyList());
final ObjectListing bucketListing = spy(new ObjectListing());
final S3ObjectSummary fileSummary = new S3ObjectSummary();
fileSummary.setKey(OLD_PATH + "/someBigFile");
fileSummary.setSize(EXCEEDED_OBJECT_SIZE);
when(bucketListing.getObjectSummaries()).thenReturn(Collections.singletonList(fileSummary));
when(amazonS3.listObjects(any(ListObjectsRequest.class))).thenReturn(sourceListing, destinationListing, bucketListing);
assertThrows(e -> e instanceof DataStorageException && e.getMessage().contains(SIZE_EXCEEDS_EXCEPTION_MESSAGE), () -> helper.moveFolder(BUCKET, OLD_PATH, NEW_PATH));
}
use of com.epam.pipeline.entity.datastorage.DataStorageException in project cloud-pipeline by epam.
the class S3HelperTest method testRestoreFileVersionShouldThrowIfFileSizeExceedsTheLimit.
@Test
public void testRestoreFileVersionShouldThrowIfFileSizeExceedsTheLimit() {
final ObjectMetadata fileMetadata = new ObjectMetadata();
fileMetadata.setContentLength(EXCEEDED_OBJECT_SIZE);
when(amazonS3.getObjectMetadata(any())).thenReturn(fileMetadata);
assertThrows(e -> e instanceof DataStorageException && e.getMessage().contains(SIZE_EXCEEDS_EXCEPTION_MESSAGE), () -> helper.restoreFileVersion(BUCKET, OLD_PATH, VERSION));
}
Aggregations