Search in sources :

Example 96 with IotHubTransportMessage

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

the class IotHubTransportMessageTest method getRequestIdGetsTheRequestId.

/*
     **Tests_SRS_IOTHUBTRANSPORTMESSAGE_12_007: [**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 getRequestIdGetsTheRequestId() {
    // arrange
    String requestIdStr = "abcdefg";
    byte[] data = new byte[1];
    MessageType messageType = MessageType.DEVICE_TWIN;
    IotHubTransportMessage iotHubTransportMessage = new IotHubTransportMessage(data, messageType);
    iotHubTransportMessage.setRequestId(requestIdStr);
    // act
    String requestId = iotHubTransportMessage.getRequestId();
    // assert
    assertEquals(requestIdStr, requestId);
}
Also used : IotHubTransportMessage(com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage) MessageType(com.microsoft.azure.sdk.iot.device.MessageType) Test(org.junit.Test)

Example 97 with IotHubTransportMessage

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

the class IotHubTransportMessageTest method constructorWithByteArraySavesMessageData.

/*
    **Tests_SRS_IOTHUBTRANSPORTMESSAGE_12_002: [**The constructor shall save the message body by calling super with the body as parameter.**]**
     */
@Test
public void constructorWithByteArraySavesMessageData() {
    // arrange
    byte[] data = new byte[1];
    // act
    IotHubTransportMessage iotHubTransportMessage = new IotHubTransportMessage(data, MessageType.DEVICE_TELEMETRY);
    // assert
    assertEquals(data[0], iotHubTransportMessage.getBytes()[0]);
}
Also used : IotHubTransportMessage(com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage) Test(org.junit.Test)

Example 98 with IotHubTransportMessage

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

the class IotHubTransportMessageTest method getStatusGetsTheStatus.

/*
     **Tests_SRS_IOTHUBTRANSPORTMESSAGE_12_009: [**The function shall return the value of the status either set by the setter or the default (null) if unset so far.**]**
     */
@Test
public void getStatusGetsTheStatus() {
    // arrange
    String StatusStr = "abcdefg";
    byte[] data = new byte[1];
    MessageType messageType = MessageType.DEVICE_TWIN;
    IotHubTransportMessage iotHubTransportMessage = new IotHubTransportMessage(data, messageType);
    iotHubTransportMessage.setStatus(StatusStr);
    // act
    String Status = iotHubTransportMessage.getStatus();
    // assert
    assertEquals(StatusStr, Status);
}
Also used : IotHubTransportMessage(com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage) MessageType(com.microsoft.azure.sdk.iot.device.MessageType) Test(org.junit.Test)

Example 99 with IotHubTransportMessage

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

the class IotHubTransportMessageTest method getMethodNameGetsTheMethodName.

/*
     **Tests_SRS_IOTHUBTRANSPORTMESSAGE_12_014: [**The function shall return the methodName either set by the setter or the default (null) if unset so far.**]**
     */
@Test
public void getMethodNameGetsTheMethodName() {
    // arrange
    String methodNameStr = "abcdefg";
    byte[] data = new byte[1];
    MessageType messageType = MessageType.DEVICE_TWIN;
    IotHubTransportMessage iotHubTransportMessage = new IotHubTransportMessage(data, messageType);
    iotHubTransportMessage.setMethodName(methodNameStr);
    // act
    String methodName = iotHubTransportMessage.getMethodName();
    // assert
    assertEquals(methodNameStr, methodName);
}
Also used : IotHubTransportMessage(com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage) MessageType(com.microsoft.azure.sdk.iot.device.MessageType) Test(org.junit.Test)

Example 100 with IotHubTransportMessage

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

the class IotHubTransportMessageTest method constructorWithByteArraySetsMessageType.

/*
    **Tests_SRS_IOTHUBTRANSPORTMESSAGE_12_003: [**The constructor shall set the messageType to the given value by calling the super with the given value.**]**
    **Tests_SRS_IOTHUBTRANSPORTMESSAGE_12_015: [**The constructor shall initialize version, requestId and status to null.**]**
    **Tests_SRS_IOTHUBTRANSPORTMESSAGE_12_016: [**The constructor shall initialize operationType to UNKNOWN**]**
     */
@Test
public void constructorWithByteArraySetsMessageType() {
    // arrange
    byte[] data = new byte[1];
    MessageType messageType = MessageType.DEVICE_TWIN;
    // act
    IotHubTransportMessage iotHubTransportMessage = new IotHubTransportMessage(data, messageType);
    // assert
    assertEquals(messageType, iotHubTransportMessage.getMessageType());
    assertNull(iotHubTransportMessage.getVersion());
    assertNull(iotHubTransportMessage.getRequestId());
    assertNull(iotHubTransportMessage.getStatus());
    assertEquals(DEVICE_OPERATION_UNKNOWN, iotHubTransportMessage.getDeviceOperationType());
}
Also used : IotHubTransportMessage(com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage) MessageType(com.microsoft.azure.sdk.iot.device.MessageType) 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