use of com.microsoft.azure.sdk.iot.device.DeviceTwin.Property in project azure-iot-sdk-java by Azure.
the class DeviceTest method getReportedPropertiesReturnsMapsOfProperties.
/*
**Tests_SRS_DEVICE_25_001: [**This method shall return a HashSet of properties that user has set by calling setReportedProp.**]**
*/
@Test
public void getReportedPropertiesReturnsMapsOfProperties() {
//arrange
Device testDev = new Device() {
@Override
public void PropertyCall(String propertyKey, Object propertyValue, Object context) {
}
};
Property test = new Property("RepProp1", "RepValue1");
//act
testDev.setReportedProp(test);
HashSet<Property> testRepProp = testDev.getReportedProp();
//assert
assertTrue(testRepProp.contains(test));
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.Property 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.Property in project azure-iot-sdk-java by Azure.
the class DeviceTest method setReportedPropertyAddsToReportedProperty.
/*
**Tests_SRS_DEVICE_25_002: [**The function shall add the new property to the map.**]**
*/
@Test
public void setReportedPropertyAddsToReportedProperty() {
//arrange
Device testDev = new Device() {
@Override
public void PropertyCall(String propertyKey, Object propertyValue, Object context) {
}
};
Property test = new Property("RepProp1", "RepValue1");
//act
testDev.setReportedProp(test);
//assert
HashSet<Property> testRepProp = testDev.getReportedProp();
assertTrue(testRepProp.contains(test));
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.Property 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.Property 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);
}
Aggregations