Search in sources :

Example 31 with FeedbackReceiver

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

the class FeedbackReceiverTest method receive_call_receive_timeout_without_deviceId.

// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_008: [The function shall call receive(long timeoutMs) function with the default timeout]
@Test
public void receive_call_receive_timeout_without_deviceId() throws Exception {
    // Arrange
    String hostName = "xxx";
    String userName = "xxx";
    String sasToken = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol);
    // Assert
    new Expectations() {

        {
            amqpReceive.receive(Deencapsulation.getField(feedbackReceiver, "DEFAULT_TIMEOUT_MS"));
        }
    };
    // Act
    feedbackReceiver.receive();
}
Also used : Expectations(mockit.Expectations) FeedbackReceiver(com.microsoft.azure.sdk.iot.service.FeedbackReceiver) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 32 with FeedbackReceiver

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

the class FeedbackReceiverTest method constructor_input_hostName_null.

// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_001: [The constructor shall throw IllegalArgumentException if any the input string is null or empty]
// Assert
@Test(expected = IllegalArgumentException.class)
public void constructor_input_hostName_null() throws Exception {
    // Arrange
    String hostName = null;
    String userName = "xxx";
    String sasToken = "xxx";
    String deviceId = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    // Act
    FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
}
Also used : FeedbackReceiver(com.microsoft.azure.sdk.iot.service.FeedbackReceiver) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 33 with FeedbackReceiver

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

the class FeedbackReceiverTest method constructor_input_hostName_empty.

// Assert
@Test(expected = IllegalArgumentException.class)
public void constructor_input_hostName_empty() throws Exception {
    // Arrange
    String hostName = "";
    String userName = "xxx";
    String sasToken = "xxx";
    String deviceId = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    // Act
    FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
}
Also used : FeedbackReceiver(com.microsoft.azure.sdk.iot.service.FeedbackReceiver) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 34 with FeedbackReceiver

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

the class FeedbackReceiverTest method open_call_receiver_open.

// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_005: [The function shall call open() on the member AMQPReceive object]
@Test
public void open_call_receiver_open() throws Exception {
    // Arrange
    String hostName = "xxx";
    String userName = "xxx";
    String sasToken = "xxx";
    String deviceId = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
    // Assert
    new Expectations() {

        {
            amqpReceive.open();
        }
    };
    // Act
    feedbackReceiver.open();
}
Also used : Expectations(mockit.Expectations) FeedbackReceiver(com.microsoft.azure.sdk.iot.service.FeedbackReceiver) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 35 with FeedbackReceiver

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

the class FeedbackReceiverTest method constructor_input_userName_empty.

// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_001: [The constructor shall throw IllegalArgumentException if any the input string is null or empty]
// Assert
@Test(expected = IllegalArgumentException.class)
public void constructor_input_userName_empty() throws Exception {
    // Arrange
    String hostName = "xxx";
    String userName = "";
    String sasToken = "xxx";
    String deviceId = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    // Act
    FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
}
Also used : FeedbackReceiver(com.microsoft.azure.sdk.iot.service.FeedbackReceiver) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Aggregations

FeedbackReceiver (com.microsoft.azure.sdk.iot.service.FeedbackReceiver)40 IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)40 Test (org.junit.Test)40 Expectations (mockit.Expectations)19 FeedbackBatch (com.microsoft.azure.sdk.iot.service.FeedbackBatch)4 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)2 ServiceClient (com.microsoft.azure.sdk.iot.service.ServiceClient)2 AmqpReceive (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpReceive)1