Search in sources :

Example 1 with AmqpFeedbackReceivedEvent

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

the class AmqpFileUploadNotificationReceivedHandlerTest method amqpReceiveHandlerCallFlowAndInitOk.

// Tests_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVEDHANDLER_25_001: [The constructor shall copy all input parameters to private member variables for event processing]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVEDHANDLER_25_002: [The constructor shall initialize a new Handshaker (Proton) object to handle communication handshake]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVEDHANDLER_25_003: [The constructor shall initialize a new FlowController (Proton) object to handle communication handshake]
@Test
public void amqpReceiveHandlerCallFlowAndInitOk() {
    // Arrange
    final String hostName = "aaa";
    final String userName = "bbb";
    final String sasToken = "ccc";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    // Assert
    new Expectations() {

        {
            handshaker = new Handshaker();
            flowcontroller = new FlowController();
        }
    };
    // Act
    Object amqpReceiveHandler = Deencapsulation.newInstance(AmqpFileUploadNotificationReceivedHandler.class, hostName, userName, sasToken, iotHubServiceClientProtocol, amqpFeedbackReceivedEvent);
    final String _hostName = Deencapsulation.getField(amqpReceiveHandler, "hostName");
    final String _userName = Deencapsulation.getField(amqpReceiveHandler, "userName");
    final String _sasToken = Deencapsulation.getField(amqpReceiveHandler, "sasToken");
    AmqpFeedbackReceivedEvent _amqpFeedbackReceivedEvent = Deencapsulation.getField(amqpReceiveHandler, "amqpFeedbackReceivedEvent");
    // Assert
    assertEquals(hostName + ":5671", _hostName);
    assertEquals(userName, _userName);
    assertEquals(sasToken, _sasToken);
    assertEquals(amqpFeedbackReceivedEvent, _amqpFeedbackReceivedEvent);
}
Also used : Expectations(mockit.Expectations) AmqpFeedbackReceivedEvent(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFeedbackReceivedEvent) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 2 with AmqpFeedbackReceivedEvent

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

the class AmqpReceiveHandlerTest method amqpReceiveHandler_call_flow_and_init_ok.

// Tests_SRS_SERVICE_SDK_JAVA_AMQPFEEDBACKRECEIVEDHANDLER_12_001: [The constructor shall copy all input parameters to private member variables for event processing]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPFEEDBACKRECEIVEDHANDLER_12_002: [The constructor shall initialize a new Handshaker (Proton) object to handle communication handshake]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPFEEDBACKRECEIVEDHANDLER_12_003: [The constructor shall initialize a new FlowController (Proton) object to handle communication handshake]
@Test
public void amqpReceiveHandler_call_flow_and_init_ok() {
    // Arrange
    final String hostName = "aaa";
    final String userName = "bbb";
    final String sasToken = "ccc";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    // Assert
    new Expectations() {

        {
            handshaker = new Handshaker();
            flowcontroller = new FlowController();
        }
    };
    // Act
    AmqpFeedbackReceivedHandler amqpReceiveHandler = new AmqpFeedbackReceivedHandler(hostName, userName, sasToken, iotHubServiceClientProtocol, amqpFeedbackReceivedEvent);
    final String _hostName = Deencapsulation.getField(amqpReceiveHandler, "hostName");
    final String _userName = Deencapsulation.getField(amqpReceiveHandler, "userName");
    final String _sasToken = Deencapsulation.getField(amqpReceiveHandler, "sasToken");
    AmqpFeedbackReceivedEvent _amqpFeedbackReceivedEvent = Deencapsulation.getField(amqpReceiveHandler, "amqpFeedbackReceivedEvent");
    // Assert
    assertEquals(hostName + ":5671", _hostName);
    assertEquals(userName, _userName);
    assertEquals(sasToken, _sasToken);
    assertEquals(amqpFeedbackReceivedEvent, _amqpFeedbackReceivedEvent);
}
Also used : Expectations(mockit.Expectations) AmqpFeedbackReceivedEvent(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFeedbackReceivedEvent) AmqpFeedbackReceivedHandler(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFeedbackReceivedHandler) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Aggregations

IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)2 AmqpFeedbackReceivedEvent (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFeedbackReceivedEvent)2 Expectations (mockit.Expectations)2 Test (org.junit.Test)2 AmqpFeedbackReceivedHandler (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFeedbackReceivedHandler)1