use of com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair in project azure-iot-sdk-java by Azure.
the class DeviceTest method freeEmptiesAllProperties.
/*
**Tests_SRS_DEVICE_25_009: [**The method shall remove all the reported and desired properties set by the user so far and mark existing collections as null to be garbage collected.**]**
*/
@Test
public void freeEmptiesAllProperties() {
//arrange
Device testDev = new Device() {
@Override
public void PropertyCall(String propertyKey, Object propertyValue, Object context) {
}
};
Property testDes = new Property("DesiredProp1", null);
Property testRep = new Property("DesiredProp1", null);
testDev.setDesiredPropertyCallback(testDes, testDev, null);
testDev.setReportedProp(testRep);
//act
testDev.clean();
//assert
HashMap<Property, Pair<PropertyCallBack<String, Object>, Object>> testDesiredMap = testDev.getDesiredProp();
HashSet<Property> testRepMap = testDev.getReportedProp();
assertNull(testDesiredMap);
assertNull(testRepMap);
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair in project azure-iot-sdk-java by Azure.
the class DeviceTest method getDesiredPropertiesReturnsMapsOfProperties.
/*
**Tests_SRS_DEVICE_25_005: [**The function shall return the HashMap containing the property and its callback and context pair set by the user so far.**]**
*/
@Test
public void getDesiredPropertiesReturnsMapsOfProperties() {
//arrange
Device testDev = new Device() {
@Override
public void PropertyCall(String propertyKey, Object propertyValue, Object context) {
}
};
Property test = new Property("DesiredProp1", null);
testDev.setDesiredPropertyCallback(test, testDev, null);
//act
HashMap<Property, Pair<PropertyCallBack<String, Object>, Object>> testDesiredMap = testDev.getDesiredProp();
//assert
assertNotNull(testDesiredMap);
assertEquals(testDesiredMap.get(test).getKey(), testDev);
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair in project azure-iot-sdk-java by Azure.
the class DeviceTest method setDesiredPropertyCallbackCanAddNullCB.
@Test
public void setDesiredPropertyCallbackCanAddNullCB() {
//arrange
Device testDev = new Device() {
@Override
public void PropertyCall(String propertyKey, Object propertyValue, Object context) {
}
};
Property test = new Property("DesiredProp1", null);
//act
testDev.setDesiredPropertyCallback(test, null, null);
//assert
HashMap<Property, Pair<PropertyCallBack<String, Object>, Object>> testDesiredMap = testDev.getDesiredProp();
assertNotNull(testDesiredMap);
assertEquals(testDesiredMap.get(test).getKey(), null);
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair in project azure-iot-sdk-java by Azure.
the class DeviceTest method setDesiredPropertyCallbackAddsToDesiredProperty.
/*
**Tests_SRS_DEVICE_25_006: [**The function shall add the property and its callback and context pair to the user map of desired properties.**]**
*/
@Test
public void setDesiredPropertyCallbackAddsToDesiredProperty() {
//arrange
Device testDev = new Device() {
@Override
public void PropertyCall(String propertyKey, Object propertyValue, Object context) {
}
};
Property test = new Property("DesiredProp1", null);
//act
testDev.setDesiredPropertyCallback(test, testDev, null);
//assert
HashMap<Property, Pair<PropertyCallBack<String, Object>, Object>> testDesiredMap = testDev.getDesiredProp();
assertNotNull(testDesiredMap);
assertEquals(testDesiredMap.get(test).getKey(), testDev);
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair in project azure-iot-sdk-java by Azure.
the class DeviceTest method setDesiredPropertyCallbackCanAddNullPair.
/*
**Tests_SRS_DEVICE_25_008: [**This method shall add the parameters to the map even if callback and object pair are null**]**
*/
@Test
public void setDesiredPropertyCallbackCanAddNullPair() {
//arrange
Device testDev = new Device() {
@Override
public void PropertyCall(String propertyKey, Object propertyValue, Object context) {
}
};
Property test = new Property("DesiredProp1", null);
//act
testDev.setDesiredPropertyCallback(test, null, null);
//assert
HashMap<Property, Pair<PropertyCallBack<String, Object>, Object>> testDesiredMap = testDev.getDesiredProp();
assertNotNull(testDesiredMap);
assertEquals(testDesiredMap.get(test).getKey(), null);
}