Search in sources :

Example 1 with UncheckedInterruptedException

use of gov.cms.qpp.conversion.api.exceptions.UncheckedInterruptedException in project qpp-conversion-tool by CMSgov.

the class AuditServiceImplTest method testFileUploadFailureException.

@Test
public void testFileUploadFailureException() throws TimeoutException {
    when(environment.getProperty(Constants.NO_AUDIT_ENV_VARIABLE)).thenReturn(null);
    successfulEncodingPrep();
    problematic();
    final Waiter waiter = new Waiter();
    CompletableFuture<Metadata> future = underTest.success(report);
    future.whenComplete((nada, ex) -> {
        waiter.assertNull(metadata.getQppLocator());
        waiter.assertNull(metadata.getSubmissionLocator());
        waiter.assertTrue(ex.getCause() instanceof UncheckedInterruptedException);
        waiter.resume();
    });
    waiter.await(5000);
}
Also used : Metadata(gov.cms.qpp.conversion.api.model.Metadata) UncheckedInterruptedException(gov.cms.qpp.conversion.api.exceptions.UncheckedInterruptedException) Waiter(net.jodah.concurrentunit.Waiter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with UncheckedInterruptedException

use of gov.cms.qpp.conversion.api.exceptions.UncheckedInterruptedException in project qpp-conversion-tool by CMSgov.

the class StorageServiceImpl method asynchronousAction.

/**
 * Uses the {@link TransferManager} to upload a file.
 *
 * @param objectToActOn The put request.
 * @return The object key in the bucket.
 */
@Override
protected String asynchronousAction(Supplier<PutObjectRequest> objectToActOn) {
    String returnValue;
    PutObjectRequest request = objectToActOn.get();
    try {
        Upload upload = s3TransferManager.upload(request);
        returnValue = upload.waitForUploadResult().getKey();
    } catch (InterruptedException exception) {
        Thread.currentThread().interrupt();
        throw new UncheckedInterruptedException(exception);
    }
    API_LOG.info("Successfully wrote object {} to S3 bucket {}", returnValue, request.getBucketName());
    return returnValue;
}
Also used : Upload(com.amazonaws.services.s3.transfer.Upload) UncheckedInterruptedException(gov.cms.qpp.conversion.api.exceptions.UncheckedInterruptedException) UncheckedInterruptedException(gov.cms.qpp.conversion.api.exceptions.UncheckedInterruptedException) PutObjectRequest(com.amazonaws.services.s3.model.PutObjectRequest)

Aggregations

UncheckedInterruptedException (gov.cms.qpp.conversion.api.exceptions.UncheckedInterruptedException)2 PutObjectRequest (com.amazonaws.services.s3.model.PutObjectRequest)1 Upload (com.amazonaws.services.s3.transfer.Upload)1 Metadata (gov.cms.qpp.conversion.api.model.Metadata)1 Waiter (net.jodah.concurrentunit.Waiter)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1