use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method reportedToStringReturnsReported.
/*
**Tests_SRS_DEVICETWINDEVICE_25_020: [** This method shall convert the reportedProperties map to string (if present) and return **]**
*/
@Test
public void reportedToStringReturnsReported() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
Map<String, Object> testRepProp = new HashMap<>();
testRepProp.put("testRep1", "repObject1");
testRepProp.put("testRep2", "repObject2");
Deencapsulation.invoke(testDevice, "setReportedProperties", testRepProp);
//act
String testDeviceString = testDevice.reportedPropertiesToString();
//assert
assertTrue(testDeviceString.contains("testRep1"));
assertTrue(testDeviceString.contains("repObject1"));
assertTrue(testDeviceString.contains("testRep2"));
assertTrue(testDeviceString.contains("repObject2"));
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method getTwinObjectGets.
/*
Tests_SRS_DEVICETWINDEVICE_25_028: [ This method shall return the twinObject for this device]
*/
@Test
public void getTwinObjectGets() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
//act
TwinParser testDeviceTwinParserObject = Deencapsulation.invoke(testDevice, "getTwinParser");
//assert
assertNotNull(testDeviceTwinParserObject);
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method getTwinObjectUniquePerDevice.
@Test
public void getTwinObjectUniquePerDevice() {
//arrange
DeviceTwinDevice testDevice1 = new DeviceTwinDevice("testDevice1");
DeviceTwinDevice testDevice2 = new DeviceTwinDevice("testDevice2");
//act
TwinParser testDeviceTwinParserObject1 = Deencapsulation.invoke(testDevice1, "getTwinParser");
TwinParser testDeviceTwinParserObject2 = Deencapsulation.invoke(testDevice2, "getTwinParser");
//assert
assertNotEquals(testDeviceTwinParserObject1, testDeviceTwinParserObject2);
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method setDesiredPropSets.
/*
**Tests_SRS_DEVICETWINDEVICE_25_011: [** This method shall convert the set of pairs of desiredProperties to a map and save it. **]**
*/
@Test
public void setDesiredPropSets() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
Set<Pair> testDesProp = new HashSet<>();
testDesProp.add(new Pair("testDes", "desObject"));
//act
testDevice.setDesiredProperties(testDesProp);
//assert
Set<Pair> actualDesProp = testDevice.getDesiredProperties();
assertEquals(testDesProp.size(), actualDesProp.size());
for (Pair test : actualDesProp) {
assertTrue(test.getKey().equals("testDes"));
assertTrue(test.getValue().equals("desObject"));
}
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method getTagsGetsEmptyIfNotPresent.
/*
**Tests_SRS_DEVICETWINDEVICE_25_010: [** If the tags map is null then this method shall return empty set of pairs.**]**
*/
@Test
public void getTagsGetsEmptyIfNotPresent() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
//act
Set<Pair> actualTags = testDevice.getTags();
//assert
assertNotNull(actualTags);
assertTrue(actualTags.size() == 0);
}
Aggregations