use of com.microsoft.azure.sdk.iot.device.DeviceTwin.Device 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.Device 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.Device in project azure-iot-sdk-java by Azure.
the class DeviceTest method setReportedPropertyCannotAddNullProperty.
/*
**Tests_SRS_DEVICE_25_004: [**If the parameter reportedProp is null then this method shall throw IllegalArgumentException**]**
*/
@Test(expected = IllegalArgumentException.class)
public void setReportedPropertyCannotAddNullProperty() {
//arrange
Device testDev = new Device() {
@Override
public void PropertyCall(String propertyKey, Object propertyValue, Object context) {
}
};
//act
testDev.setReportedProp(null);
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.Device in project azure-iot-sdk-java by Azure.
the class DeviceTest method setDesiredPropertyCallbackCannotAddNullProperty.
/*
**Tests_SRS_DEVICE_25_007: [**If the parameter desiredProp is null then this method shall throw IllegalArgumentException**]**
*/
@Test(expected = IllegalArgumentException.class)
public void setDesiredPropertyCallbackCannotAddNullProperty() {
//arrange
Device testDev = new Device() {
@Override
public void PropertyCall(String propertyKey, Object propertyValue, Object context) {
}
};
Property test = new Property("DesiredProp1", null);
//act
testDev.setDesiredPropertyCallback(null, testDev, null);
}
use of com.microsoft.azure.sdk.iot.device.DeviceTwin.Device in project azure-iot-sdk-java by Azure.
the class DeviceTest method setReportedPropertyAddsToAlteredReportedProperty.
/*
**Tests_SRS_DEVICE_25_003: [**If the already existing property is altered and added then the this method shall replace the old one.**]**
*/
@Test
public void setReportedPropertyAddsToAlteredReportedProperty() {
//arrange
Device testDev = new Device() {
@Override
public void PropertyCall(String propertyKey, Object propertyValue, Object context) {
}
};
Property test = new Property("RepProp1", "RepValue1");
testDev.setReportedProp(test);
test.setValue("RepValue2");
//act
testDev.setReportedProp(test);
//assert
HashSet<Property> testRepProp = testDev.getReportedProp();
assertTrue(testRepProp.contains(test));
assertTrue(testRepProp.size() == 1);
}