use of com.microsoft.azure.sdk.iot.service.devicetwin.Pair 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"));
}
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.Pair in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method settersAlwaysCreatesNewMaps.
@Test
public void settersAlwaysCreatesNewMaps() {
//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());
assertNotEquals(testDesProp, actualDesProp);
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.Pair in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method setTagsThrowsIsNullInput.
/*
**Tests_SRS_DEVICETWINDEVICE_25_008: [** If the tags Set is null then this method shall throw IllegalArgumentException.**]**
*/
@Test(expected = IllegalArgumentException.class)
public void setTagsThrowsIsNullInput() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
Set<Pair> testTags = null;
//act
testDevice.setTags(testTags);
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.Pair in project azure-iot-sdk-java by Azure.
the class DeviceTwinDeviceTest method clearTwinClears.
@Test
public void clearTwinClears() {
//arrange
DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
Map<String, Object> testRep = new HashMap<>();
testRep.put("testKey", "testObject");
Deencapsulation.invoke(testDevice, "setDesiredProperties", testRep);
Deencapsulation.invoke(testDevice, "setTags", testRep);
//act
testDevice.clearTwin();
//assert
Map<String, Object> actualTags = Deencapsulation.invoke(testDevice, "getTagsMap");
Map<String, Object> actualDes = Deencapsulation.invoke(testDevice, "getDesiredMap");
assertNull(actualTags);
assertNull(actualDes);
Set<Pair> actualTagsSet = testDevice.getTags();
assertTrue(actualTagsSet.size() == 0);
Set<Pair> actualDesSet = testDevice.getDesiredProperties();
assertTrue(actualDesSet.size() == 0);
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.Pair in project azure-iot-sdk-java by Azure.
the class PairTest method getValueGets.
/*
**Tests_SRS_Pair_25_005: [**The function shall return the value for this Pair.**]**
*/
@Test
public void getValueGets() {
//arrange
Pair testPair = new Pair("TestKey", "TestObject");
//act
Object value = testPair.getValue();
//assert
assertNotNull(testPair);
assertTrue(value.equals("TestObject"));
}
Aggregations