Search in sources :

Example 1 with Property

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

Example 2 with Property

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);
}
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 Property

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

Example 4 with Property

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);
}
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 Property

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);
}
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

Property (com.microsoft.azure.sdk.iot.device.DeviceTwin.Property)16 Test (org.junit.Test)13 Device (com.microsoft.azure.sdk.iot.device.DeviceTwin.Device)9 Pair (com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair)5 Pair (com.microsoft.azure.sdk.iot.service.devicetwin.Pair)3 ExecutorService (java.util.concurrent.ExecutorService)1