use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method desToStringReturnsEmptyIfTagsEmpty.
/*
**Tests_SRS_DEVICETWINDEVICE_25_019: [** This method shall return an empty string if desiredProperties map is empty or null and return **]**
*/
@Test
public void desToStringReturnsEmptyIfTagsEmpty() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
//act
String testDeviceString = testDevice.desiredPropertiesToString();
//assert
assertTrue(testDeviceString.length() == 0);
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method getDesiredPropGets.
/*
**Tests_SRS_DEVICETWINDEVICE_25_013: [** This method shall convert the desiredProperties map to a set of pairs and return with it. **]**
*/
@Test
public void getDesiredPropGets() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
Set<Pair> testDesProp = new HashSet<>();
testDesProp.add(new Pair("testDes", "desObject"));
testDevice.setDesiredProperties(testDesProp);
//act
Set<Pair> actualDesProp = testDevice.getDesiredProperties();
//assert
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 clearClearsMapsTags.
@Test
public void clearClearsMapsTags() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
Map<String, Object> testTags = new HashMap<>();
testTags.put("testTag", "tagObject");
Deencapsulation.invoke(testDevice, "setTags", testTags);
//act
testDevice.clearTags();
//assert
Map<String, Object> actualTags = Deencapsulation.invoke(testDevice, "getDesiredMap");
assertNull(actualTags);
Set<Pair> actualTagsSet = testDevice.getTags();
assertTrue(actualTagsSet.size() == 0);
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method getDeviceIdGets.
/*
**Tests_SRS_DEVICETWINDEVICE_25_004: [** This method shall return the device id **]**
*/
@Test
public void getDeviceIdGets() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
//act
String devId = testDevice.getDeviceId();
//assert
assertTrue(devId.equals("testDevice"));
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method getterGetsMapsTags.
/*
**Tests_SRS_DEVICETWINDEVICE_25_025: [** This method shall return the tags map**]**
*/
@Test
public void getterGetsMapsTags() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
Map<String, Object> testTags = new HashMap<>();
testTags.put("testTag", "tagObject");
Deencapsulation.invoke(testDevice, "setTags", testTags);
//act
Map<String, Object> actualTags = Deencapsulation.invoke(testDevice, "getTagsMap");
//assert
assertEquals(testTags.size(), actualTags.size());
for (Map.Entry<String, Object> test : actualTags.entrySet()) {
assertTrue(test.getKey().equals("testTag"));
assertTrue(test.getValue().equals("tagObject"));
}
}
Aggregations