Search in sources :

Example 1 with AmqpFileUploadNotificationReceive

use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFileUploadNotificationReceive 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 2 with AmqpFileUploadNotificationReceive

use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFileUploadNotificationReceive in project azure-iot-sdk-java by Azure.

the class AmqpFileUploadNotificationReceiveTest method onFeedbackReceivedCallFlowOk.

// Tests_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVE_25_010: [The function shall parse the received Json string to FeedbackBath object]
@Test
public void onFeedbackReceivedCallFlowOk(@Mocked FileUploadNotification mockedNotification) {
    // Arrange
    final String hostName = "aaa";
    final String userName = "bbb";
    final String sasToken = "ccc";
    final String jsonData = "[]";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    AmqpFileUploadNotificationReceive amqpFileUploadNotificationReceive = new AmqpFileUploadNotificationReceive(hostName, userName, sasToken, iotHubServiceClientProtocol);
    // Act
    amqpFileUploadNotificationReceive.onFeedbackReceived(jsonData);
    //assert
    new Verifications() {

        {
            mockNotificationParser.getBlobName();
            times = 1;
            mockNotificationParser.getBlobSizeInBytesTag();
            times = 1;
            mockNotificationParser.getBlobUri();
            times = 1;
            mockNotificationParser.getDeviceId();
            times = 1;
            mockNotificationParser.getEnqueuedTimeUtc();
            times = 1;
            mockNotificationParser.getLastUpdatedTime();
            times = 1;
        }
    };
}
Also used : 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 AmqpFileUploadNotificationReceive

use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFileUploadNotificationReceive in project azure-iot-sdk-java by Azure.

the class AmqpFileUploadNotificationReceiveTest method onReactorInitCallFlowAndInitOk.

// Tests_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVE_25_002: [The event handler shall set the member AmqpsReceiveHandler object to handle the given connection events]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVE_25_003: [The function shall create an AmqpsReceiveHandler object to handle reactor events]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVE_25_004: [The function shall invalidate the member AmqpsReceiveHandler object]
@Test
public void onReactorInitCallFlowAndInitOk() throws IOException {
    // Arrange
    final String hostName = "aaa";
    final String userName = "bbb";
    final String sasToken = "ccc";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    AmqpFileUploadNotificationReceive amqpFileUploadNotificationReceive = new AmqpFileUploadNotificationReceive(hostName, userName, sasToken, iotHubServiceClientProtocol);
    amqpFileUploadNotificationReceive.open();
    // Assert
    new Expectations() {

        {
            reactor = event.getReactor();
            connection = reactor.connection(Deencapsulation.getField(amqpFileUploadNotificationReceive, "amqpReceiveHandler"));
        }
    };
    // Act
    amqpFileUploadNotificationReceive.onReactorInit(event);
    // Assert
    assertNotNull(Deencapsulation.getField(amqpFileUploadNotificationReceive, "amqpReceiveHandler"));
    // Clean up
    amqpFileUploadNotificationReceive.close();
}
Also used : Expectations(mockit.Expectations) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) AmqpFileUploadNotificationReceive(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFileUploadNotificationReceive) Test(org.junit.Test)

Example 4 with AmqpFileUploadNotificationReceive

use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFileUploadNotificationReceive 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, mockedProxyOptions, mockedSslContext);
    new Verifications() {

        {
            new AmqpFileUploadNotificationReceive(anyString, anyString, anyString, iotHubServiceClientProtocol, (ProxyOptions) any, (SSLContext) any);
            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 5 with AmqpFileUploadNotificationReceive

use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFileUploadNotificationReceive in project azure-iot-sdk-java by Azure.

the class AmqpFileUploadNotificationReceiveTest method receiveExceptionThrow.

// Tests_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVE_25_008: [The function shall throw IOException if the send handler object is not initialized]
// Assert
@Test(expected = IOException.class)
public void receiveExceptionThrow() throws IOException, InterruptedException {
    // Arrange
    final String hostName = "aaa";
    final String userName = "bbb";
    final String sasToken = "ccc";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    int timeoutMs = 1;
    AmqpFileUploadNotificationReceive amqpFileUploadNotificationReceive = new AmqpFileUploadNotificationReceive(hostName, userName, sasToken, iotHubServiceClientProtocol);
    // Act
    amqpFileUploadNotificationReceive.receive(timeoutMs);
}
Also used : IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) AmqpFileUploadNotificationReceive(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFileUploadNotificationReceive) Test(org.junit.Test)

Aggregations

IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)12 AmqpFileUploadNotificationReceive (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFileUploadNotificationReceive)12 Test (org.junit.Test)12 Verifications (mockit.Verifications)4 Expectations (mockit.Expectations)3 FileUploadNotificationReceiver (com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver)2 AmqpFileUploadNotificationReceivedHandler (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFileUploadNotificationReceivedHandler)1