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);
// Act
CompletableFuture<FileUploadNotification> completableFuture = fileUploadNotificationReceiver.receiveAsync(timeoutMs);
completableFuture.get();
// Assert
new Verifications() {
{
amqpFileUploadNotificationReceive.receive(timeoutMs);
times = 1;
fileUploadNotificationReceiver.receive(anyLong);
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.service.FileUploadNotification in project azure-iot-sdk-java by Azure.
the class FileUploadNotificationTest method constructorThrowsOnEmptyBlobName.
// 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 constructorThrowsOnEmptyBlobName() throws IOException {
//arrange
final String actualDeviceId = "TestDeviceId";
final String actualBlobUri = "TestblobUri";
final String actualBlobName = "";
final Date actualLastUpdatedTimeDate = new Date();
final Long actualBlobSizeInBytes = 10000L;
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);
}
use of com.microsoft.azure.sdk.iot.service.FileUploadNotification in project azure-iot-sdk-java by Azure.
the class FileUploadNotificationTest method constructorThrowsOnNullBlobUri.
// 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 constructorThrowsOnNullBlobUri() throws IOException {
//arrange
final String actualDeviceId = "TestDeviceId";
final String actualBlobUri = null;
final String actualBlobName = "TestBlobName";
final Date actualLastUpdatedTimeDate = new Date();
final Long actualBlobSizeInBytes = 10000L;
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);
}
use of com.microsoft.azure.sdk.iot.service.FileUploadNotification in project azure-iot-sdk-java by Azure.
the class FileUploadNotificationTest method constructorThrowsOnNullEnqueuedTime.
// 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 constructorThrowsOnNullEnqueuedTime() throws IOException {
//arrange
final String actualDeviceId = null;
final String actualBlobUri = "TestblobUri";
final String actualBlobName = "TestBlobName";
final Date actualLastUpdatedTimeDate = new Date();
final Long actualBlobSizeInBytes = 10000L;
final Date actualEnqueuedTimeUtcDate = null;
//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);
}
use of com.microsoft.azure.sdk.iot.service.FileUploadNotification in project azure-iot-sdk-java by Azure.
the class FileUploadNotificationTest method getDeviceIdGets.
// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATION_25_003: [** The getter for device ID **]
@Test
public void getDeviceIdGets() throws IOException {
//arrange
final String actualDeviceId = "TestDeviceId";
FileUploadNotification testFileUploadNotification = new FileUploadNotification(actualDeviceId, mockBlobUri, mockBlobName, mockLastUpdatedTimeDate, mockBlobSizeInBytes, mockEnqueuedTimeUtcDate);
//act
final String testDeviceId = testFileUploadNotification.getDeviceId();
//assert
assertEquals(testDeviceId, actualDeviceId);
}
Aggregations