use of com.microsoft.azure.sdk.iot.service.devicetwin.Pair 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.Pair 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.Pair in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method tagsToStringReturnsTags.
/*
**Tests_SRS_DEVICETWINDEVICE_25_016: [** This method shall convert the tags map to string (if present) and return **]**
*/
@Test
public void tagsToStringReturnsTags() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
Set<Pair> testTags = new HashSet<>();
testTags.add(new Pair("testTag1", "tagObject1"));
testTags.add(new Pair("testTag2", "tagObject2"));
testDevice.setTags(testTags);
//act
String testDeviceString = testDevice.tagsToString();
//assert
assertTrue(testDeviceString.contains("testTag1"));
assertTrue(testDeviceString.contains("tagObject1"));
assertTrue(testDeviceString.contains("testTag2"));
assertTrue(testDeviceString.contains("tagObject2"));
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.Pair in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method getReportedPropGets.
/*
**Tests_SRS_DEVICETWINDEVICE_25_005: [** This method shall convert the reported properties map to a set of pairs and return with it. **]**
*/
@Test
public void getReportedPropGets() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
Map<String, Object> repMap = new HashMap<>();
repMap.put("testRep", "repObject");
Deencapsulation.setField(testDevice, "reportedProperties", repMap);
//act
Set<Pair> actualRepProp = testDevice.getReportedProperties();
//assert
assertEquals(repMap.size(), actualRepProp.size());
for (Pair test : actualRepProp) {
assertTrue(test.getKey().equals("testRep"));
assertTrue(test.getValue().equals("repObject"));
}
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.Pair in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method desiredToStringReturnsDesired.
/*
**Tests_SRS_DEVICETWINDEVICE_25_018: [** This method shall convert the desiredProperties map to string (if present) and return **]**
*/
@Test
public void desiredToStringReturnsDesired() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
Set<Pair> testDesProp = new HashSet<>();
testDesProp.add(new Pair("testDes1", "desObject1"));
testDesProp.add(new Pair("testDes2", "desObject2"));
testDevice.setDesiredProperties(testDesProp);
//act
String testDeviceString = testDevice.desiredPropertiesToString();
//assert
assertTrue(testDeviceString.contains("testDes1"));
assertTrue(testDeviceString.contains("desObject1"));
assertTrue(testDeviceString.contains("testDes2"));
assertTrue(testDeviceString.contains("desObject2"));
}
Aggregations