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);
}
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]);
}
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);
}
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);
}
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());
}
Aggregations