use of com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceOperations in project azure-iot-sdk-java by Azure.
the class IotHubTransportMessageTest method getOperationTypeGetsTheOperationType.
/*
**Tests_SRS_IOTHUBTRANSPORTMESSAGE_12_011: [**The function shall return the operation type either set by the setter or the default if unset so far.**]**
*/
@Test
public void getOperationTypeGetsTheOperationType() {
// arrange
DeviceOperations deviceOperations = DeviceOperations.DEVICE_OPERATION_TWIN_GET_REQUEST;
byte[] data = new byte[1];
MessageType messageType = MessageType.DEVICE_TWIN;
IotHubTransportMessage iotHubTransportMessage = new IotHubTransportMessage(data, messageType);
iotHubTransportMessage.setDeviceOperationType(deviceOperations);
// act
DeviceOperations operationType = iotHubTransportMessage.getDeviceOperationType();
// assert
assertEquals(deviceOperations, operationType);
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceOperations in project azure-iot-sdk-java by Azure.
the class IotHubTransportMessageTest method setOperationTypeSetsTheOperationType.
/*
**Tests_SRS_IOTHUBTRANSPORTMESSAGE_12_010: [**The function shall save the device twin operation type.**]**
*/
@Test
public void setOperationTypeSetsTheOperationType() {
// arrange
DeviceOperations deviceOperations = DeviceOperations.DEVICE_OPERATION_TWIN_GET_REQUEST;
byte[] data = new byte[1];
MessageType messageType = MessageType.DEVICE_TWIN;
IotHubTransportMessage iotHubTransportMessage = new IotHubTransportMessage(data, messageType);
// act
iotHubTransportMessage.setDeviceOperationType(deviceOperations);
// assert
assertEquals(deviceOperations, iotHubTransportMessage.getDeviceOperationType());
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceOperations 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
DeviceTwinMessage msg = new DeviceTwinMessage(actualData);
//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);
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceOperations 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 = {};
DeviceTwinMessage msg = new DeviceTwinMessage(actualData);
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);
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceOperations in project azure-iot-sdk-java by Azure.
the class DeviceTwinMessageTest method gettersGetDefaultsIfNotSet.
@Test
public void gettersGetDefaultsIfNotSet() {
//arrange
final byte[] actualData = {};
DeviceTwinMessage msg = new DeviceTwinMessage(actualData);
//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);
}
Aggregations