Search in sources :

Example 26 with Pair

use of com.microsoft.azure.sdk.iot.service.devicetwin.Pair in project azure-iot-sdk-java by Azure.

the class DeviceTwinDeviceTest method setReportedPropSets.

@Test
public void setReportedPropSets() {
    //arrange
    DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
    Map<String, Object> testRepProp = new HashMap<>();
    testRepProp.put("testRep", "repObject");
    //act
    Deencapsulation.invoke(testDevice, "setReportedProperties", testRepProp);
    //assert
    Set<Pair> actualRepProp = testDevice.getReportedProperties();
    assertEquals(testRepProp.size(), actualRepProp.size());
    for (Pair test : actualRepProp) {
        assertTrue(test.getKey().equals("testRep"));
        assertTrue(test.getValue().equals("repObject"));
    }
}
Also used : DeviceTwinDevice(com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice) HashMap(java.util.HashMap) Pair(com.microsoft.azure.sdk.iot.service.devicetwin.Pair) Test(org.junit.Test)

Example 27 with Pair

use of com.microsoft.azure.sdk.iot.service.devicetwin.Pair in project azure-iot-sdk-java by Azure.

the class DeviceTwinDeviceTest method settersAlwaysCreatesNewMaps.

@Test
public void settersAlwaysCreatesNewMaps() {
    //arrange
    DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
    Set<Pair> testDesProp = new HashSet<>();
    testDesProp.add(new Pair("testDes", "desObject"));
    //act
    testDevice.setDesiredProperties(testDesProp);
    //assert
    Set<Pair> actualDesProp = testDevice.getDesiredProperties();
    assertEquals(testDesProp.size(), actualDesProp.size());
    assertNotEquals(testDesProp, actualDesProp);
}
Also used : DeviceTwinDevice(com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice) HashSet(java.util.HashSet) Pair(com.microsoft.azure.sdk.iot.service.devicetwin.Pair) Test(org.junit.Test)

Example 28 with Pair

use of com.microsoft.azure.sdk.iot.service.devicetwin.Pair in project azure-iot-sdk-java by Azure.

the class DeviceTwinDeviceTest method setTagsThrowsIsNullInput.

/*
    **Tests_SRS_DEVICETWINDEVICE_25_008: [** If the tags Set is null then this method shall throw IllegalArgumentException.**]**
     */
@Test(expected = IllegalArgumentException.class)
public void setTagsThrowsIsNullInput() {
    //arrange
    DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
    Set<Pair> testTags = null;
    //act
    testDevice.setTags(testTags);
}
Also used : DeviceTwinDevice(com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice) Pair(com.microsoft.azure.sdk.iot.service.devicetwin.Pair) Test(org.junit.Test)

Example 29 with Pair

use of com.microsoft.azure.sdk.iot.service.devicetwin.Pair in project azure-iot-sdk-java by Azure.

the class DeviceTwinDeviceTest method clearTwinClears.

@Test
public void clearTwinClears() {
    //arrange
    DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
    Map<String, Object> testRep = new HashMap<>();
    testRep.put("testKey", "testObject");
    Deencapsulation.invoke(testDevice, "setDesiredProperties", testRep);
    Deencapsulation.invoke(testDevice, "setTags", testRep);
    //act
    testDevice.clearTwin();
    //assert
    Map<String, Object> actualTags = Deencapsulation.invoke(testDevice, "getTagsMap");
    Map<String, Object> actualDes = Deencapsulation.invoke(testDevice, "getDesiredMap");
    assertNull(actualTags);
    assertNull(actualDes);
    Set<Pair> actualTagsSet = testDevice.getTags();
    assertTrue(actualTagsSet.size() == 0);
    Set<Pair> actualDesSet = testDevice.getDesiredProperties();
    assertTrue(actualDesSet.size() == 0);
}
Also used : DeviceTwinDevice(com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice) HashMap(java.util.HashMap) Pair(com.microsoft.azure.sdk.iot.service.devicetwin.Pair) Test(org.junit.Test)

Example 30 with Pair

use of com.microsoft.azure.sdk.iot.service.devicetwin.Pair in project azure-iot-sdk-java by Azure.

the class PairTest method getValueGets.

/*
    **Tests_SRS_Pair_25_005: [**The function shall return the value for this Pair.**]**
     */
@Test
public void getValueGets() {
    //arrange
    Pair testPair = new Pair("TestKey", "TestObject");
    //act
    Object value = testPair.getValue();
    //assert
    assertNotNull(testPair);
    assertTrue(value.equals("TestObject"));
}
Also used : Pair(com.microsoft.azure.sdk.iot.service.devicetwin.Pair) Test(org.junit.Test)

Aggregations

Pair (com.microsoft.azure.sdk.iot.service.devicetwin.Pair)32 Test (org.junit.Test)23 DeviceTwinDevice (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice)20 HashSet (java.util.HashSet)10 HashMap (java.util.HashMap)5 Property (com.microsoft.azure.sdk.iot.device.DeviceTwin.Property)3 DeviceTwin (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin)1 IotHubException (com.microsoft.azure.sdk.iot.service.exceptions.IotHubException)1 Random (java.util.Random)1 ExecutorService (java.util.concurrent.ExecutorService)1 DeviceConnectionString (tests.integration.com.microsoft.azure.sdk.iot.device.DeviceConnectionString)1