use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice 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.DeviceTwinDevice 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.DeviceTwinDevice in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method getterGetsMapsRep.
/*
**Tests_SRS_DEVICETWINDEVICE_25_026: [** This method shall return the reportedProperties map**]**
*/
@Test
public void getterGetsMapsRep() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
Map<String, Object> testRep = new HashMap<>();
testRep.put("testRep", "repObject");
Deencapsulation.invoke(testDevice, "setReportedProperties", testRep);
//act
Map<String, Object> actualTags = Deencapsulation.invoke(testDevice, "getReportedMap");
//assert
assertEquals(testRep.size(), actualTags.size());
for (Map.Entry<String, Object> test : actualTags.entrySet()) {
assertTrue(test.getKey().equals("testRep"));
assertTrue(test.getValue().equals("repObject"));
}
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method setterSetsMapsRep.
/*
**Tests_SRS_DEVICETWINDEVICE_25_022: [** This method shall save the reportedProperties map**]**
*/
@Test
public void setterSetsMapsRep() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
Map<String, Object> testRep = new HashMap<>();
testRep.put("testRep", "repObject");
//act
Deencapsulation.invoke(testDevice, "setReportedProperties", testRep);
//assert
Map<String, Object> actualTags = Deencapsulation.invoke(testDevice, "getReportedMap");
assertEquals(testRep.size(), actualTags.size());
for (Map.Entry<String, Object> test : actualTags.entrySet()) {
assertTrue(test.getKey().equals("testRep"));
assertTrue(test.getValue().equals("repObject"));
}
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice 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