Search in sources :

Example 11 with MessageType

use of com.microsoft.azure.sdk.iot.device.MessageType 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 12 with MessageType

use of com.microsoft.azure.sdk.iot.device.MessageType 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 13 with MessageType

use of com.microsoft.azure.sdk.iot.device.MessageType 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 14 with MessageType

use of com.microsoft.azure.sdk.iot.device.MessageType 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)

Example 15 with MessageType

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

the class IotHubTransportMessageTest method setMethodNameSetsTheMethodName.

/*
     **Tests_SRS_IOTHUBTRANSPORTMESSAGE_12_013: [**The function shall set the methodName.**]**
     */
@Test
public void setMethodNameSetsTheMethodName() {
    // arrange
    String methodNameStr = "abcdefg";
    byte[] data = new byte[1];
    MessageType messageType = MessageType.DEVICE_TWIN;
    IotHubTransportMessage iotHubTransportMessage = new IotHubTransportMessage(data, messageType);
    // act
    iotHubTransportMessage.setMethodName(methodNameStr);
    // assert
    assertEquals(methodNameStr, iotHubTransportMessage.getMethodName());
}
Also used : IotHubTransportMessage(com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage) MessageType(com.microsoft.azure.sdk.iot.device.MessageType) Test(org.junit.Test)

Aggregations

MessageType (com.microsoft.azure.sdk.iot.device.MessageType)15 IotHubTransportMessage (com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage)14 Test (org.junit.Test)14 DeviceOperations (com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceOperations)3 IotHubConnectionString (com.microsoft.azure.sdk.iot.device.IotHubConnectionString)1 Message (com.microsoft.azure.sdk.iot.device.Message)1 MessageProperty (com.microsoft.azure.sdk.iot.device.MessageProperty)1 Date (java.util.Date)1