Search in sources :

Example 1 with FileUploadStatusCallBack

use of com.microsoft.azure.sdk.iot.device.fileupload.FileUploadStatusCallBack in project azure-iot-sdk-java by Azure.

the class FileUploadTest method callbackDeleteFileUploadInProgressThrows.

@Test
public void callbackDeleteFileUploadInProgressThrows(@Mocked final LinkedBlockingDeque<?> mockFileUploadInProgressQueue) throws IOException {
    // arrange
    final Map<String, Object> context = new HashMap<>();
    constructorExpectations();
    new NonStrictExpectations() {

        {
            new LinkedBlockingDeque<>();
            result = mockFileUploadInProgressQueue;
            mockFileUploadInProgressQueue.remove(mockFileUploadInProgress);
            result = new UnsupportedOperationException();
        }
    };
    FileUpload fileUpload = new FileUpload(mockConfig);
    IotHubEventCallback testFileUploadStatusCallBack = new FileUploadStatusCallBack();
    // act
    testFileUploadStatusCallBack.execute(IotHubStatusCode.OK_EMPTY, mockFileUploadInProgress);
    // assert
    new Verifications() {

        {
            Deencapsulation.invoke(mockFileUploadInProgress, "triggerCallback", new Class[] { IotHubStatusCode.class }, IotHubStatusCode.OK_EMPTY);
            times = 1;
        }
    };
}
Also used : IotHubEventCallback(com.microsoft.azure.sdk.iot.device.IotHubEventCallback) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) HashMap(java.util.HashMap) FileUpload(com.microsoft.azure.sdk.iot.device.fileupload.FileUpload) FileUploadStatusCallBack(com.microsoft.azure.sdk.iot.device.fileupload.FileUploadStatusCallBack) Test(org.junit.Test)

Example 2 with FileUploadStatusCallBack

use of com.microsoft.azure.sdk.iot.device.fileupload.FileUploadStatusCallBack in project azure-iot-sdk-java by Azure.

the class FileUploadTest method callbackBypassStatus.

/* Tests_SRS_FILEUPLOAD_21_014: [The constructor shall create an Event callback `fileUploadStatusCallBack` to receive the upload status.] */
/* Tests_SRS_FILEUPLOAD_21_019: [The FileUploadStatusCallBack shall implements the `IotHubEventCallback` as result of the FileUploadTask.] */
/* Tests_SRS_FILEUPLOAD_21_020: [The FileUploadStatusCallBack shall call the `statusCallback` reporting the received status.] */
@Test
public void callbackBypassStatus() throws IOException {
    // arrange
    final Map<String, Object> context = new HashMap<>();
    constructorExpectations();
    FileUpload fileUpload = new FileUpload(mockConfig);
    IotHubEventCallback testFileUploadStatusCallBack = new FileUploadStatusCallBack();
    // act
    testFileUploadStatusCallBack.execute(IotHubStatusCode.OK_EMPTY, mockFileUploadInProgress);
    // assert
    new Verifications() {

        {
            Deencapsulation.invoke(mockFileUploadInProgress, "triggerCallback", new Class[] { IotHubStatusCode.class }, IotHubStatusCode.OK_EMPTY);
            times = 1;
        }
    };
}
Also used : IotHubEventCallback(com.microsoft.azure.sdk.iot.device.IotHubEventCallback) HashMap(java.util.HashMap) FileUpload(com.microsoft.azure.sdk.iot.device.fileupload.FileUpload) FileUploadStatusCallBack(com.microsoft.azure.sdk.iot.device.fileupload.FileUploadStatusCallBack) Test(org.junit.Test)

Example 3 with FileUploadStatusCallBack

use of com.microsoft.azure.sdk.iot.device.fileupload.FileUploadStatusCallBack in project azure-iot-sdk-java by Azure.

the class FileUploadTest method callbackDeleteFileUploadInProgress.

/* Tests_SRS_FILEUPLOAD_21_021: [The FileUploadStatusCallBack shall delete the `FileUploadInProgress` that store this file upload context.] */
@Test
public void callbackDeleteFileUploadInProgress(@Mocked final LinkedBlockingDeque<?> mockFileUploadInProgressQueue) throws IOException {
    // arrange
    final Map<String, Object> context = new HashMap<>();
    new NonStrictExpectations() {

        {
            new HttpsTransportManager(mockConfig);
            result = mockHttpsTransportManager;
            Executors.newScheduledThreadPool(10);
            result = mockScheduler;
            new LinkedBlockingDeque<>();
            result = mockFileUploadInProgressQueue;
        }
    };
    FileUpload fileUpload = new FileUpload(mockConfig);
    IotHubEventCallback testFileUploadStatusCallBack = new FileUploadStatusCallBack();
    // act
    testFileUploadStatusCallBack.execute(IotHubStatusCode.OK_EMPTY, mockFileUploadInProgress);
    // assert
    new Verifications() {

        {
            mockFileUploadInProgressQueue.remove(mockFileUploadInProgress);
            times = 1;
        }
    };
}
Also used : HttpsTransportManager(com.microsoft.azure.sdk.iot.device.transport.https.HttpsTransportManager) IotHubEventCallback(com.microsoft.azure.sdk.iot.device.IotHubEventCallback) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) HashMap(java.util.HashMap) FileUpload(com.microsoft.azure.sdk.iot.device.fileupload.FileUpload) FileUploadStatusCallBack(com.microsoft.azure.sdk.iot.device.fileupload.FileUploadStatusCallBack) Test(org.junit.Test)

Aggregations

IotHubEventCallback (com.microsoft.azure.sdk.iot.device.IotHubEventCallback)3 FileUpload (com.microsoft.azure.sdk.iot.device.fileupload.FileUpload)3 FileUploadStatusCallBack (com.microsoft.azure.sdk.iot.device.fileupload.FileUploadStatusCallBack)3 HashMap (java.util.HashMap)3 Test (org.junit.Test)3 LinkedBlockingDeque (java.util.concurrent.LinkedBlockingDeque)2 HttpsTransportManager (com.microsoft.azure.sdk.iot.device.transport.https.HttpsTransportManager)1