Search in sources :

Example 1 with Pair

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);
}
Also used : Device(com.microsoft.azure.sdk.iot.device.DeviceTwin.Device) Property(com.microsoft.azure.sdk.iot.device.DeviceTwin.Property) Pair(com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair) Test(org.junit.Test)

Example 2 with Pair

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);
}
Also used : Device(com.microsoft.azure.sdk.iot.device.DeviceTwin.Device) Property(com.microsoft.azure.sdk.iot.device.DeviceTwin.Property) Pair(com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair) Test(org.junit.Test)

Example 3 with Pair

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);
}
Also used : Device(com.microsoft.azure.sdk.iot.device.DeviceTwin.Device) Property(com.microsoft.azure.sdk.iot.device.DeviceTwin.Property) Pair(com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair) Test(org.junit.Test)

Example 4 with Pair

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);
}
Also used : Device(com.microsoft.azure.sdk.iot.device.DeviceTwin.Device) Property(com.microsoft.azure.sdk.iot.device.DeviceTwin.Property) Pair(com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair) Test(org.junit.Test)

Example 5 with Pair

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);
}
Also used : Device(com.microsoft.azure.sdk.iot.device.DeviceTwin.Device) Property(com.microsoft.azure.sdk.iot.device.DeviceTwin.Property) Pair(com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair) Test(org.junit.Test)

Aggregations

Device (com.microsoft.azure.sdk.iot.device.DeviceTwin.Device)5 Pair (com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair)5 Property (com.microsoft.azure.sdk.iot.device.DeviceTwin.Property)5 Test (org.junit.Test)5