Search in sources :

Example 21 with FileUploadNotification

use of com.microsoft.azure.sdk.iot.service.FileUploadNotification in project azure-iot-sdk-java by Azure.

the class FileUploadNotificationReceiverTest method receiveAsync.

// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATIONRECEIVER_25_012: [ The function shall create an async wrapper around the receive() function call using the default timeout ]
@Test
public void receiveAsync() throws Exception {
    // Arrange
    final String hostName = "xxx";
    final String userName = "xxx";
    final String sasToken = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    FileUploadNotificationReceiver fileUploadNotificationReceiver = Deencapsulation.newInstance(FileUploadNotificationReceiver.class, hostName, userName, sasToken, iotHubServiceClientProtocol, mockedProxyOptions, mockedSslContext);
    // Act
    CompletableFuture<FileUploadNotification> completableFuture = fileUploadNotificationReceiver.receiveAsync();
    completableFuture.get();
    // Assert
    new Verifications() {

        {
            amqpFileUploadNotificationReceive.receive(Deencapsulation.getField(fileUploadNotificationReceiver, "DEFAULT_TIMEOUT_MS"));
            times = 1;
            fileUploadNotificationReceiver.receive();
            times = 1;
        }
    };
}
Also used : FileUploadNotification(com.microsoft.azure.sdk.iot.service.FileUploadNotification) FileUploadNotificationReceiver(com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver) Verifications(mockit.Verifications) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 22 with FileUploadNotification

use of com.microsoft.azure.sdk.iot.service.FileUploadNotification in project azure-iot-sdk-java by Azure.

the class FileUploadNotificationReceiverTest method receiveWithTimeoutAsync.

// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATIONRECEIVER_25_013: [ The function shall create an async wrapper around the receive(long timeoutMs) function call ]
@Test
public void receiveWithTimeoutAsync() throws Exception {
    // Arrange
    long timeoutMs = 1000;
    final String hostName = "xxx";
    final String userName = "xxx";
    final String sasToken = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    FileUploadNotificationReceiver fileUploadNotificationReceiver = Deencapsulation.newInstance(FileUploadNotificationReceiver.class, hostName, userName, sasToken, iotHubServiceClientProtocol, mockedProxyOptions, mockedSslContext);
    // Act
    CompletableFuture<FileUploadNotification> completableFuture = fileUploadNotificationReceiver.receiveAsync(timeoutMs);
    completableFuture.get();
    // Assert
    new Verifications() {

        {
            amqpFileUploadNotificationReceive.receive(timeoutMs);
            times = 1;
            fileUploadNotificationReceiver.receive(anyLong);
            times = 1;
        }
    };
}
Also used : FileUploadNotification(com.microsoft.azure.sdk.iot.service.FileUploadNotification) FileUploadNotificationReceiver(com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver) Verifications(mockit.Verifications) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 23 with FileUploadNotification

use of com.microsoft.azure.sdk.iot.service.FileUploadNotification in project azure-iot-sdk-java by Azure.

the class FileUploadNotificationReceiverTest method receiveAsync.

// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATIONRECEIVER_25_012: [ The function shall create an async wrapper around the receive() function call using the default timeout ]
@Test
public void receiveAsync() throws Exception {
    // Arrange
    final String hostName = "xxx";
    final String userName = "xxx";
    final String sasToken = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    FileUploadNotificationReceiver fileUploadNotificationReceiver = Deencapsulation.newInstance(FileUploadNotificationReceiver.class, hostName, userName, sasToken, iotHubServiceClientProtocol);
    // Act
    CompletableFuture<FileUploadNotification> completableFuture = fileUploadNotificationReceiver.receiveAsync();
    completableFuture.get();
    // Assert
    new Verifications() {

        {
            amqpFileUploadNotificationReceive.receive(Deencapsulation.getField(fileUploadNotificationReceiver, "DEFAULT_TIMEOUT_MS"));
            times = 1;
            fileUploadNotificationReceiver.receive();
            times = 1;
        }
    };
}
Also used : FileUploadNotification(com.microsoft.azure.sdk.iot.service.FileUploadNotification) FileUploadNotificationReceiver(com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver) Verifications(mockit.Verifications) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 24 with FileUploadNotification

use of com.microsoft.azure.sdk.iot.service.FileUploadNotification in project azure-iot-sdk-java by Azure.

the class FileUploadNotificationTest method getBlobUriGets.

//Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATION_25_003: [ The getter for Blob Uri ]
@Test
public void getBlobUriGets() throws IOException {
    //arrange
    final String actualBlobUri = "TestblobUri";
    FileUploadNotification testFileUploadNotification = new FileUploadNotification(mockDeviceId, actualBlobUri, mockBlobName, mockLastUpdatedTimeDate, mockBlobSizeInBytes, mockEnqueuedTimeUtcDate);
    //act
    final String testBlobUri = testFileUploadNotification.getBlobUri();
    //assert
    assertEquals(testBlobUri, actualBlobUri);
}
Also used : FileUploadNotification(com.microsoft.azure.sdk.iot.service.FileUploadNotification) Test(org.junit.Test)

Example 25 with FileUploadNotification

use of com.microsoft.azure.sdk.iot.service.FileUploadNotification in project azure-iot-sdk-java by Azure.

the class FileUploadNotificationTest method constructorThrowsOnNullSize.

// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATION_25_002: [** If any of the parameters are null or empty then this method shall throw IllegalArgumentException.**]
@Test(expected = IllegalArgumentException.class)
public void constructorThrowsOnNullSize() throws IOException {
    //arrange
    final String actualDeviceId = "TestDeviceId";
    final String actualBlobUri = "TestblobUri";
    final String actualBlobName = "TestBlobName";
    final Date actualLastUpdatedTimeDate = new Date();
    final Long actualBlobSizeInBytes = null;
    final Date actualEnqueuedTimeUtcDate = new Date();
    //act
    FileUploadNotification testFileUploadNotification = new FileUploadNotification(actualDeviceId, actualBlobUri, actualBlobName, actualLastUpdatedTimeDate, actualBlobSizeInBytes, actualEnqueuedTimeUtcDate);
    //assert
    assertEquals(testFileUploadNotification.getDeviceId(), actualDeviceId);
    assertEquals(testFileUploadNotification.getBlobName(), actualBlobName);
    assertEquals(testFileUploadNotification.getBlobUri(), actualBlobUri);
    assertEquals(testFileUploadNotification.getLastUpdatedTimeDate(), actualLastUpdatedTimeDate);
    assertEquals(testFileUploadNotification.getBlobSizeInBytes(), actualBlobSizeInBytes);
    assertEquals(testFileUploadNotification.getEnqueuedTimeUtcDate(), actualEnqueuedTimeUtcDate);
}
Also used : FileUploadNotification(com.microsoft.azure.sdk.iot.service.FileUploadNotification) Date(java.util.Date) Test(org.junit.Test)

Aggregations

FileUploadNotification (com.microsoft.azure.sdk.iot.service.FileUploadNotification)39 Test (org.junit.Test)36 Date (java.util.Date)24 FileUploadNotificationReceiver (com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver)6 IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)4 Verifications (mockit.Verifications)4 IOException (java.io.IOException)3 FeedbackBatch (com.microsoft.azure.sdk.iot.service.FeedbackBatch)2 FeedbackReceiver (com.microsoft.azure.sdk.iot.service.FeedbackReceiver)2 FeedbackRecord (com.microsoft.azure.sdk.iot.service.FeedbackRecord)2 Message (com.microsoft.azure.sdk.iot.service.Message)2 ServiceClient (com.microsoft.azure.sdk.iot.service.ServiceClient)2 ServiceClientOptions (com.microsoft.azure.sdk.iot.service.ServiceClientOptions)2 IotHubException (com.microsoft.azure.sdk.iot.service.exceptions.IotHubException)2 FileUploadNotificationParser (com.microsoft.azure.sdk.iot.deps.serializer.FileUploadNotificationParser)1