Search in sources :

Example 1 with FileUploadNotificationReceiver

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

the class FileUploadNotificationReceiverTest method receiveCallReceiveTimeout.

// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATIONRECEIVER_25_007: [ The function shall call receive(long timeoutMs) function with the default timeout ]
@Test
public void receiveCallReceiveTimeout() 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
    fileUploadNotificationReceiver.receive();
    // Assert
    new Verifications() {

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

Example 2 with FileUploadNotificationReceiver

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

the class FileUploadNotificationReceiverTest method constructorSaveProperties.

// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATIONRECEIVER_25_002: [** The constructor shall create a new instance of AmqpFileUploadNotificationReceive object **]**
@Test
public void constructorSaveProperties() throws Exception {
    // Arrange
    final String hostName = "aaa";
    final String userName = "bbb";
    final String sasToken = "ccc";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    // Act
    FileUploadNotificationReceiver fileUploadNotificationReceiver = Deencapsulation.newInstance(FileUploadNotificationReceiver.class, hostName, userName, sasToken, iotHubServiceClientProtocol);
    new Verifications() {

        {
            new AmqpFileUploadNotificationReceive(anyString, anyString, anyString, iotHubServiceClientProtocol);
            times = 1;
        }
    };
}
Also used : FileUploadNotificationReceiver(com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver) Verifications(mockit.Verifications) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) AmqpFileUploadNotificationReceive(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFileUploadNotificationReceive) Test(org.junit.Test)

Example 3 with FileUploadNotificationReceiver

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

the class FileUploadNotificationReceiverTest method receiveWithTimeoutReceiverNull.

// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATIONRECEIVER_25_008: [ The function shall throw IOException if the member AmqpFileUploadNotificationReceive object has not been initialized ]
// Assert
@Test(expected = IOException.class)
public void receiveWithTimeoutReceiverNull() 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);
    Deencapsulation.setField(fileUploadNotificationReceiver, "amqpFileUploadNotificationReceive", null);
    // Act
    fileUploadNotificationReceiver.receive(timeoutMs);
}
Also used : FileUploadNotificationReceiver(com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 4 with FileUploadNotificationReceiver

use of com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver 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);
    // 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 5 with FileUploadNotificationReceiver

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

the class FileUploadNotificationReceiverTest method closeAsync.

// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATIONRECEIVER_25_011: [ The function shall create an async wrapper around the close() function call ]
@Test
public void closeAsync() 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<Void> completableFuture = fileUploadNotificationReceiver.closeAsync();
    completableFuture.get();
    // Assert
    new Verifications() {

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

Aggregations

FileUploadNotificationReceiver (com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver)17 IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)17 Test (org.junit.Test)17 Verifications (mockit.Verifications)9 FileUploadNotification (com.microsoft.azure.sdk.iot.service.FileUploadNotification)2 AmqpFileUploadNotificationReceive (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFileUploadNotificationReceive)1