use of com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceTwinMessage in project azure-iot-sdk-java by Azure.
the class DeviceTwinMessageTest method setStatusIdSets.
/*
**Tests_SRS_DEVICETWINMESSAGE_25_007: [**The function shall save the status.**]**
*/
@Test
public void setStatusIdSets() {
//arrange
final byte[] actualData = {};
DeviceTwinMessage msg = new DeviceTwinMessage(actualData);
//act
msg.setStatus("12");
//assert
assertEquals(msg.getStatus(), "12");
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceTwinMessage in project azure-iot-sdk-java by Azure.
the class DeviceTwinMessageTest method getVersionRetrievesVersion.
/*
**Tests_SRS_DEVICETWINMESSAGE_25_004: [**The function shall return the value of the version either set by the setter or the default (null) if unset so far.**]**
*/
@Test
public void getVersionRetrievesVersion() {
//arrange
final byte[] actualData = {};
DeviceTwinMessage msg = new DeviceTwinMessage(actualData);
msg.setVersion("12");
//act
String version = msg.getVersion();
//assert
assertEquals(version, "12");
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceTwinMessage 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 = {};
DeviceTwinMessage msg = new DeviceTwinMessage(actualData);
msg.setRequestId("12");
//act
String requestId = msg.getRequestId();
//assert
assertEquals(requestId, "12");
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceTwinMessage in project azure-iot-sdk-java by Azure.
the class DeviceTwinMessageTest method getStatusGets.
/*
**Tests_SRS_DEVICETWINMESSAGE_25_008: [**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 getStatusGets() {
//arrange
final byte[] actualData = {};
DeviceTwinMessage msg = new DeviceTwinMessage(actualData);
msg.setStatus("12");
//act
String status = msg.getStatus();
//assert
assertEquals(status, "12");
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceTwinMessage in project azure-iot-sdk-java by Azure.
the class MqttDeviceTwinTest method receiveParsesPatchTopicForDesiredPropertiesNotificationSucceeds.
/*
**Tests_SRS_MQTTDEVICETWIN_25_042: [**If the topic is of type patch for desired properties then this method shall parse further to look for version which if found is set by calling setVersion**]**
*/
@Test
public void receiveParsesPatchTopicForDesiredPropertiesNotificationSucceeds(@Mocked final Mqtt mockMqtt) throws IOException {
final byte[] actualPayload = "UpdateDesiredPropertiesNotificationData".getBytes();
final String expectedTopic = "$iothub/twin/PATCH/properties/desired/" + "?$version=" + mockVersion;
DeviceTwinMessage receivedMessage = null;
try {
//arrange
MqttDeviceTwin testTwin = new MqttDeviceTwin();
String insertTopic = expectedTopic;
ConcurrentSkipListMap<String, byte[]> testMap = new ConcurrentSkipListMap<String, byte[]>();
testMap.put(insertTopic, actualPayload);
Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap);
//act
receivedMessage = (DeviceTwinMessage) testTwin.receive();
} finally {
//assert
assertNotNull(receivedMessage);
assertTrue(receivedMessage.getMessageType() == MessageType.DeviceTwin);
assertTrue(receivedMessage.getDeviceOperationType() == DEVICE_OPERATION_TWIN_SUBSCRIBE_DESIRED_PROPERTIES_RESPONSE);
assertTrue(receivedMessage.getVersion().equals(mockVersion));
assertTrue(receivedMessage.getRequestId() == null);
assertTrue(receivedMessage.getStatus() == null);
}
}
Aggregations