Search in sources :

Example 31 with IotHubTransportMessage

use of com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage in project azure-iot-sdk-java by Azure.

the class DeviceTwinMessageTest method getTwinOpGets.

/*
    **Tests_SRS_DEVICETWINMESSAGE_25_010: [**The function shall return the operation type either set by the setter or the default (DEVICE_OPERATION_UNKNOWN) if unset so far.**]**
     */
@Test
public void getTwinOpGets() {
    // arrange
    final byte[] actualData = {};
    IotHubTransportMessage msg = new IotHubTransportMessage(actualData, MessageType.DEVICE_TWIN);
    msg.setDeviceOperationType(DeviceOperations.DEVICE_OPERATION_TWIN_UPDATE_REPORTED_PROPERTIES_RESPONSE);
    // act
    DeviceOperations op = msg.getDeviceOperationType();
    // assert
    assertEquals(op, DeviceOperations.DEVICE_OPERATION_TWIN_UPDATE_REPORTED_PROPERTIES_RESPONSE);
}
Also used : DeviceOperations(com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceOperations) IotHubTransportMessage(com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage) Test(org.junit.Test)

Example 32 with IotHubTransportMessage

use of com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage in project azure-iot-sdk-java by Azure.

the class DeviceTwinMessageTest method constructorSetsRequiredPrivateMembers.

/*
    **Tests_SRS_DEVICETWINMESSAGE_25_001: [**The constructor shall save the message body by calling super with the body as parameter.**]**
     */
@Test
public void constructorSetsRequiredPrivateMembers() {
    // arrange
    final byte[] actualData = {};
    // act
    IotHubTransportMessage msg = new IotHubTransportMessage(actualData, MessageType.DEVICE_TWIN);
    // assert
    String actualVersion = Deencapsulation.getField(msg, "version");
    String actualRequestId = Deencapsulation.getField(msg, "requestId");
    String actualStatus = Deencapsulation.getField(msg, "status");
    DeviceOperations operationType = Deencapsulation.getField(msg, "operationType");
    assertNull(actualVersion);
    assertNull(actualRequestId);
    assertNull(actualStatus);
    assertEquals(operationType, DeviceOperations.DEVICE_OPERATION_UNKNOWN);
}
Also used : DeviceOperations(com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceOperations) IotHubTransportMessage(com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage) Test(org.junit.Test)

Example 33 with IotHubTransportMessage

use of com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage in project azure-iot-sdk-java by Azure.

the class DeviceTwinMessageTest method setRequestIdSets.

/*
    **Tests_SRS_DEVICETWINMESSAGE_25_005: [**The function shall save the request id.**]**
     */
@Test
public void setRequestIdSets() {
    // arrange
    final byte[] actualData = {};
    IotHubTransportMessage msg = new IotHubTransportMessage(actualData, MessageType.DEVICE_TWIN);
    // act
    msg.setRequestId("12");
    // assert
    assertEquals(msg.getRequestId(), "12");
}
Also used : IotHubTransportMessage(com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage) Test(org.junit.Test)

Example 34 with IotHubTransportMessage

use of com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage in project azure-iot-sdk-java by Azure.

the class DeviceTwinMessageTest method gettersGetDefaultsIfNotSet.

@Test
public void gettersGetDefaultsIfNotSet() {
    // arrange
    final byte[] actualData = {};
    IotHubTransportMessage msg = new IotHubTransportMessage(actualData, MessageType.DEVICE_TWIN);
    // act
    String testVersion = msg.getVersion();
    String testRequestId = msg.getRequestId();
    String testStatus = msg.getStatus();
    DeviceOperations testOpType = msg.getDeviceOperationType();
    // assert
    String actualVersion = Deencapsulation.getField(msg, "version");
    String actualRequestId = Deencapsulation.getField(msg, "requestId");
    String actualStatus = Deencapsulation.getField(msg, "status");
    DeviceOperations operationType = Deencapsulation.getField(msg, "operationType");
    assertEquals(actualRequestId, testRequestId);
    assertEquals(actualStatus, testStatus);
    assertEquals(actualVersion, testVersion);
}
Also used : DeviceOperations(com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceOperations) IotHubTransportMessage(com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage) Test(org.junit.Test)

Example 35 with IotHubTransportMessage

use of com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage in project azure-iot-sdk-java by Azure.

the class DeviceTwinMessageTest method getRequestIdGets.

/*
    **Tests_SRS_DEVICETWINMESSAGE_25_006: [**The function shall return the value of the request id either set by the setter or the default (null) if unset so far.**]**
     */
@Test
public void getRequestIdGets() {
    // arrange
    final byte[] actualData = {};
    IotHubTransportMessage msg = new IotHubTransportMessage(actualData, MessageType.DEVICE_TWIN);
    msg.setRequestId("12");
    // act
    String requestId = msg.getRequestId();
    // assert
    assertEquals(requestId, "12");
}
Also used : IotHubTransportMessage(com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage) Test(org.junit.Test)

Aggregations

IotHubTransportMessage (com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage)129 Test (org.junit.Test)108 Message (com.microsoft.azure.sdk.iot.device.Message)37 MutablePair (org.apache.commons.lang3.tuple.MutablePair)33 Pair (org.apache.commons.lang3.tuple.Pair)33 DeviceTwin (com.microsoft.azure.sdk.iot.device.DeviceTwin)30 MqttDeviceTwin (com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttDeviceTwin)25 HashMap (java.util.HashMap)24 DeviceOperations (com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceOperations)16 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)16 MessageType (com.microsoft.azure.sdk.iot.device.MessageType)14 Verifications (mockit.Verifications)10 MqttDeviceMethod (com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttDeviceMethod)8 NonStrictExpectations (mockit.NonStrictExpectations)8 IOException (java.io.IOException)5 FileUploadTask (com.microsoft.azure.sdk.iot.device.fileupload.FileUploadTask)4 MessageCallback (com.microsoft.azure.sdk.iot.device.MessageCallback)3 MethodResult (com.microsoft.azure.sdk.iot.device.edge.MethodResult)3 HttpsTransportManager (com.microsoft.azure.sdk.iot.device.transport.https.HttpsTransportManager)3 HashSet (java.util.HashSet)3