Search in sources :

Example 1 with FileUploadNotificationParser

use of com.microsoft.azure.sdk.iot.deps.serializer.FileUploadNotificationParser in project azure-iot-sdk-java by Azure.

the class FileUploadNotificationParserTest method getters_succeed.

/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_006: [The getDeviceId shall return the string stored in `deviceId`.] */
/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_007: [The getBlobUri shall return the string stored in `blobUri`.] */
/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_008: [The getBlobName shall return the string stored in `blobName`.] */
/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_009: [The getLastUpdateTime shall return the string stored in `lastUpdateTime`.] */
/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_010: [The getEnqueuedTimeUtc shall return the string stored in `enqueuedTimeUtc`.] */
/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_011: [The getBlobSizeInBytesTag shall return the integer stored in `blobSizeInBytes`.] */
@Test
public void getters_succeed() {
    // arrange
    String validJson = createJson(VALID_DEVICEID, VALID_BLOB_UTI, VALID_BLOB_NAME, VALID_LAST_UPDATE_TIME, VALID_ENQUEUED_TIME_UTC, VALID_BLOB_SIZE_IN_BYTES);
    FileUploadNotificationParser fileUploadNotificationParser = new FileUploadNotificationParser(validJson);
    Date expectedLastUpdatedTime = new Date(VALID_LAST_UPDATE_TIME_IN_MILLISECONDS);
    Date expectedEnqueuedTimeUtc = new Date(VALID_ENQUEUED_TIME_UTC_IN_MILLISECONDS);
    // act
    // assert
    assertEquals(VALID_DEVICEID, fileUploadNotificationParser.getDeviceId());
    assertEquals(VALID_BLOB_UTI, fileUploadNotificationParser.getBlobUri());
    assertEquals(VALID_BLOB_NAME, fileUploadNotificationParser.getBlobName());
    assertEquals(expectedLastUpdatedTime, fileUploadNotificationParser.getLastUpdatedTime());
    assertEquals(expectedEnqueuedTimeUtc, fileUploadNotificationParser.getEnqueuedTimeUtc());
    assertEquals(VALID_BLOB_SIZE_IN_BYTES, fileUploadNotificationParser.getBlobSizeInBytesTag());
}
Also used : FileUploadNotificationParser(com.microsoft.azure.sdk.iot.deps.serializer.FileUploadNotificationParser) Date(java.util.Date) Test(org.junit.Test)

Example 2 with FileUploadNotificationParser

use of com.microsoft.azure.sdk.iot.deps.serializer.FileUploadNotificationParser in project azure-iot-sdk-java by Azure.

the class FileUploadNotificationParserTest method constructor_json_realCase_succeed.

/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_001: [The constructor shall create an instance of the FileUploadNotification.] */
/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_002: [The constructor shall parse the provided json and initialize `correlationId`, `hostName`, `containerName`, `blobName`, and `sasToken` using the information in the json.] */
@Test
public void constructor_json_realCase_succeed() {
    // arrange
    String validJson = "{" + "\"deviceId\":\"test-device1\"," + "\"blobUri\":\"https://storageaccount.blob.core.windows.net/storage-accout-storageaccount/storageaccount-test/hello_world.txt\"," + "\"blobName\":\"storageaccount-test/hello_world.txt\"," + "\"lastUpdatedTime\":\"2017-05-01T23:29:11+00:00\"," + "\"blobSizeInBytes\":45," + "\"enqueuedTimeUtc\":\"2017-05-01T23:29:13.5700695Z\"}";
    // act
    FileUploadNotificationParser fileUploadNotificationParser = new FileUploadNotificationParser(validJson);
    // assert
    assertFileUploadNotification(fileUploadNotificationParser, "test-device1", "https://storageaccount.blob.core.windows.net/storage-accout-storageaccount/storageaccount-test/hello_world.txt", "storageaccount-test/hello_world.txt", "2017-05-01T23:29:11+00:00", "2017-05-01T23:29:13.5700695Z", 45);
}
Also used : FileUploadNotificationParser(com.microsoft.azure.sdk.iot.deps.serializer.FileUploadNotificationParser) Test(org.junit.Test)

Example 3 with FileUploadNotificationParser

use of com.microsoft.azure.sdk.iot.deps.serializer.FileUploadNotificationParser in project azure-iot-sdk-java by Azure.

the class FileUploadNotificationParserTest method constructor_specialCase_string_null_succeed.

/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_002: [The constructor shall parse the provided json and initialize `correlationId`, `hostName`, `containerName`, `blobName`, and `sasToken` using the information in the json.] */
@Test
public void constructor_specialCase_string_null_succeed() {
    // arrange
    String validJson = "{\n" + "    \"deviceId\": \"null\",\n" + "    \"blobUri\": \"" + VALID_BLOB_UTI + "\",\n" + "    \"blobName\": \"" + VALID_BLOB_NAME + "\",\n" + "    \"lastUpdatedTime\": \"" + VALID_LAST_UPDATE_TIME + "\",\n" + "    \"blobSizeInBytes\": " + VALID_BLOB_SIZE_IN_BYTES + ",\n" + "    \"enqueuedTimeUtc\": \"" + VALID_ENQUEUED_TIME_UTC + "\"\n" + "}";
    // act
    FileUploadNotificationParser fileUploadNotificationParser = new FileUploadNotificationParser(validJson);
    // assert
    assertFileUploadNotification(fileUploadNotificationParser, "null", VALID_BLOB_UTI, VALID_BLOB_NAME, VALID_LAST_UPDATE_TIME, VALID_ENQUEUED_TIME_UTC, VALID_BLOB_SIZE_IN_BYTES);
}
Also used : FileUploadNotificationParser(com.microsoft.azure.sdk.iot.deps.serializer.FileUploadNotificationParser) Test(org.junit.Test)

Example 4 with FileUploadNotificationParser

use of com.microsoft.azure.sdk.iot.deps.serializer.FileUploadNotificationParser in project azure-iot-sdk-java by Azure.

the class FileUploadNotificationParserTest method getters_succeed.

/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_006: [The getDeviceId shall return the string stored in `deviceId`.] */
/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_007: [The getBlobUri shall return the string stored in `blobUri`.] */
/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_008: [The getBlobName shall return the string stored in `blobName`.] */
/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_009: [The getLastUpdateTime shall return the string stored in `lastUpdateTime`.] */
/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_010: [The getEnqueuedTimeUtc shall return the string stored in `enqueuedTimeUtc`.] */
/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_011: [The getBlobSizeInBytesTag shall return the integer stored in `blobSizeInBytes`.] */
@Test
public void getters_succeed() {
    // arrange
    String validJson = createJson(VALID_DEVICEID, VALID_BLOB_UTI, VALID_BLOB_NAME, VALID_LAST_UPDATE_TIME, VALID_ENQUEUED_TIME_UTC, VALID_BLOB_SIZE_IN_BYTES);
    FileUploadNotificationParser fileUploadNotificationParser = new FileUploadNotificationParser(validJson);
    Date expectedLastUpdatedTime = new Date(VALID_LAST_UPDATE_TIME_IN_MILLISECONDS);
    Date expectedEnqueuedTimeUtc = new Date(VALID_ENQUEUED_TIME_UTC_IN_MILLISECONDS);
    // act
    // assert
    assertEquals(VALID_DEVICEID, fileUploadNotificationParser.getDeviceId());
    assertEquals(VALID_BLOB_UTI, fileUploadNotificationParser.getBlobUri());
    assertEquals(VALID_BLOB_NAME, fileUploadNotificationParser.getBlobName());
    assertEquals(expectedLastUpdatedTime, fileUploadNotificationParser.getLastUpdatedTime());
    assertEquals(expectedEnqueuedTimeUtc, fileUploadNotificationParser.getEnqueuedTimeUtc());
    assertEquals(VALID_BLOB_SIZE_IN_BYTES, fileUploadNotificationParser.getBlobSizeInBytesTag());
}
Also used : FileUploadNotificationParser(com.microsoft.azure.sdk.iot.deps.serializer.FileUploadNotificationParser) Date(java.util.Date) Test(org.junit.Test)

Example 5 with FileUploadNotificationParser

use of com.microsoft.azure.sdk.iot.deps.serializer.FileUploadNotificationParser in project azure-iot-sdk-java by Azure.

the class FileUploadNotificationParserTest method constructor_json_succeed.

/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_001: [The constructor shall create an instance of the FileUploadNotification.] */
/* Tests_SRS_FILE_UPLOAD_NOTIFICATION_21_002: [The constructor shall parse the provided json and initialize `correlationId`, `hostName`, `containerName`, `blobName`, and `sasToken` using the information in the json.] */
@Test
public void constructor_json_succeed() {
    // arrange
    String validJson = createJson(VALID_DEVICEID, VALID_BLOB_UTI, VALID_BLOB_NAME, VALID_LAST_UPDATE_TIME, VALID_ENQUEUED_TIME_UTC, VALID_BLOB_SIZE_IN_BYTES);
    // act
    FileUploadNotificationParser fileUploadNotificationParser = new FileUploadNotificationParser(validJson);
    // assert
    assertFileUploadNotification(fileUploadNotificationParser, VALID_DEVICEID, VALID_BLOB_UTI, VALID_BLOB_NAME, VALID_LAST_UPDATE_TIME, VALID_ENQUEUED_TIME_UTC, VALID_BLOB_SIZE_IN_BYTES);
}
Also used : FileUploadNotificationParser(com.microsoft.azure.sdk.iot.deps.serializer.FileUploadNotificationParser) Test(org.junit.Test)

Aggregations

FileUploadNotificationParser (com.microsoft.azure.sdk.iot.deps.serializer.FileUploadNotificationParser)10 Test (org.junit.Test)9 Date (java.util.Date)2 FileUploadNotification (com.microsoft.azure.sdk.iot.service.FileUploadNotification)1 IOException (java.io.IOException)1