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