Search in sources :

Example 26 with DeviceTwinDevice

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

the class DeviceTwinDeviceTest method getTagsGets.

/*
    **Tests_SRS_DEVICETWINDEVICE_25_009: [** This method shall convert the tags map to a set of pairs and return with it. **]**
     */
@Test
public void getTagsGets() {
    //arrange
    DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
    Set<Pair> testTags = new HashSet<>();
    testTags.add(new Pair("testTag", "tagObject"));
    testDevice.setTags(testTags);
    //act
    Set<Pair> actualTags = testDevice.getTags();
    //assert
    assertEquals(testTags.size(), actualTags.size());
    for (Pair test : actualTags) {
        assertTrue(test.getKey().equals("testTag"));
        assertTrue(test.getValue().equals("tagObject"));
    }
}
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 27 with DeviceTwinDevice

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

the class DeviceTwinDeviceTest method tagsToStringReturnsEmptyIfTagsEmpty.

/*
    **Tests_SRS_DEVICETWINDEVICE_25_017: [** This method shall return an empty string if tags map is empty or null and return **]**
     */
@Test
public void tagsToStringReturnsEmptyIfTagsEmpty() {
    //arrange
    DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
    //act
    String testDeviceString = testDevice.tagsToString();
    //assert
    assertTrue(testDeviceString.length() == 0);
}
Also used : DeviceTwinDevice(com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice) Test(org.junit.Test)

Example 28 with DeviceTwinDevice

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

the class DeviceTwinDeviceTest method repToStringReturnsEmptyIfTagsEmpty.

/*
    **Tests_SRS_DEVICETWINDEVICE_25_021: [** This method shall return an empty string if reportedProperties map is empty or null and return **]**
     */
@Test
public void repToStringReturnsEmptyIfTagsEmpty() {
    //arrange
    DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
    //act
    String testDeviceString = testDevice.reportedPropertiesToString();
    //assert
    assertTrue(testDeviceString.length() == 0);
}
Also used : DeviceTwinDevice(com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice) Test(org.junit.Test)

Example 29 with DeviceTwinDevice

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

the class DeviceTwinDeviceTest method getReportedPropGetsEmptyIfNotPresent.

/*
    **Tests_SRS_DEVICETWINDEVICE_25_006: [** If the reported properties map is null then this method shall return empty set of pairs.**]**
     */
@Test
public void getReportedPropGetsEmptyIfNotPresent() {
    //arrange
    DeviceTwinDevice testDevice = new DeviceTwinDevice("testDevice");
    //act
    Set<Pair> actualRepProp = testDevice.getReportedProperties();
    //assert
    assertNotNull(actualRepProp);
    assertTrue(actualRepProp.size() == 0);
}
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 30 with DeviceTwinDevice

use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice 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)

Aggregations

DeviceTwinDevice (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice)35 Test (org.junit.Test)33 Pair (com.microsoft.azure.sdk.iot.service.devicetwin.Pair)20 HashMap (java.util.HashMap)12 HashSet (java.util.HashSet)10 Map (java.util.Map)6 TwinParser (com.microsoft.azure.sdk.iot.deps.serializer.TwinParser)2 DeviceClient (com.microsoft.azure.sdk.iot.device.DeviceClient)1 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