use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method getTagsGets.
/*
**Tests_SRS_DEVICETWINDEVICE_25_009: [** This method shall convert the tags map to a set of pairs and return with it. **]**
*/
@Test
public void getTagsGets() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
Set<Pair> testTags = new HashSet<>();
testTags.add(new Pair("testTag", "tagObject"));
testDevice.setTags(testTags);
//act
Set<Pair> actualTags = testDevice.getTags();
//assert
assertEquals(testTags.size(), actualTags.size());
for (Pair test : actualTags) {
assertTrue(test.getKey().equals("testTag"));
assertTrue(test.getValue().equals("tagObject"));
}
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method tagsToStringReturnsEmptyIfTagsEmpty.
/*
**Tests_SRS_DEVICETWINDEVICE_25_017: [** This method shall return an empty string if tags map is empty or null and return **]**
*/
@Test
public void tagsToStringReturnsEmptyIfTagsEmpty() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
//act
String testDeviceString = testDevice.tagsToString();
//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 repToStringReturnsEmptyIfTagsEmpty.
/*
**Tests_SRS_DEVICETWINDEVICE_25_021: [** This method shall return an empty string if reportedProperties map is empty or null and return **]**
*/
@Test
public void repToStringReturnsEmptyIfTagsEmpty() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
//act
String testDeviceString = testDevice.reportedPropertiesToString();
//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 getReportedPropGetsEmptyIfNotPresent.
/*
**Tests_SRS_DEVICETWINDEVICE_25_006: [** If the reported properties map is null then this method shall return empty set of pairs.**]**
*/
@Test
public void getReportedPropGetsEmptyIfNotPresent() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
//act
Set<Pair> actualRepProp = testDevice.getReportedProperties();
//assert
assertNotNull(actualRepProp);
assertTrue(actualRepProp.size() == 0);
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method setReportedPropSets.
@Test
public void setReportedPropSets() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
Map<String, Object> testRepProp = new HashMap<>();
testRepProp.put("testRep", "repObject");
//act
Deencapsulation.invoke(testDevice, "setReportedProperties", testRepProp);
//assert
Set<Pair> actualRepProp = testDevice.getReportedProperties();
assertEquals(testRepProp.size(), actualRepProp.size());
for (Pair test : actualRepProp) {
assertTrue(test.getKey().equals("testRep"));
assertTrue(test.getValue().equals("repObject"));
}
}
Aggregations