Search in sources :

Example 11 with FileUploadNotificationReceiver

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

the class FileUploadNotificationReceiverTest method closeCallReceiverClose.

// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATIONRECEIVER_25_006: [ The function shall call close() on the member AmqpFileUploadNotificationReceive object ]
@Test
public void closeCallReceiverClose() 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.close();
    // Assert
    new Verifications() {

        {
            amqpFileUploadNotificationReceive.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)

Example 12 with FileUploadNotificationReceiver

use of com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver 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 13 with FileUploadNotificationReceiver

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

the class FileUploadNotificationReceiverTest method constructorInputSasTokenNull.

// Assert
@Test(expected = IllegalArgumentException.class)
public void constructorInputSasTokenNull() throws Exception {
    // Arrange
    final String hostName = "xxx";
    final String userName = "xxx";
    final String sasToken = null;
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    // Act
    FileUploadNotificationReceiver fileUploadNotificationReceiver = Deencapsulation.newInstance(FileUploadNotificationReceiver.class, hostName, userName, sasToken, iotHubServiceClientProtocol);
}
Also used : FileUploadNotificationReceiver(com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 14 with FileUploadNotificationReceiver

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

the class FileUploadNotificationReceiverTest method receiveWithTimeoutCallReceiveTimeout.

// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATIONRECEIVER_25_009: [ The function shall call receive() on the member AmqpFileUploadNotificationReceive object and return with the result ]
@Test
public void receiveWithTimeoutCallReceiveTimeout() 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
    fileUploadNotificationReceiver.receive(timeoutMs);
    // Assert
    new Verifications() {

        {
            amqpFileUploadNotificationReceive.receive(timeoutMs);
            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 15 with FileUploadNotificationReceiver

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

the class FileUploadNotificationReceiverTest method constructorInputHostNameEmpty.

// Assert
@Test(expected = IllegalArgumentException.class)
public void constructorInputHostNameEmpty() throws Exception {
    // Arrange
    final String hostName = "";
    final String userName = "xxx";
    final String sasToken = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    // Act
    FileUploadNotificationReceiver fileUploadNotificationReceiver = Deencapsulation.newInstance(FileUploadNotificationReceiver.class, hostName, userName, sasToken, iotHubServiceClientProtocol);
}
Also used : FileUploadNotificationReceiver(com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver) 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