Search in sources :

Example 6 with RegistryManager

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

the class DeviceManagerSample method GetDevice.

private static void GetDevice() throws Exception {
    RegistryManager registryManager = RegistryManager.createFromConnectionString(SampleUtils.iotHubConnectionString);
    Device returnDevice = null;
    try {
        returnDevice = registryManager.getDevice(SampleUtils.deviceId);
        System.out.println("Device: " + returnDevice.getDeviceId());
        System.out.println("Device primary key: " + returnDevice.getPrimaryKey());
        System.out.println("Device secondary key: " + returnDevice.getSecondaryKey());
        System.out.println("Device eTag: " + returnDevice.geteTag());
    } catch (IotHubException iote) {
        iote.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Device(com.microsoft.azure.sdk.iot.service.Device) RegistryManager(com.microsoft.azure.sdk.iot.service.RegistryManager) IOException(java.io.IOException) IotHubException(com.microsoft.azure.sdk.iot.service.exceptions.IotHubException)

Example 7 with RegistryManager

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

the class RegistryStatisticsTests method gettersSucceeds.

@Test
public void gettersSucceeds(@Mocked RegistryManager mockedRegistryManager) throws IOException, IotHubException {
    //arrange
    String connectionString = "HostName=aaa.bbb.ccc;SharedAccessKeyName=XXX;SharedAccessKey=YYY";
    RegistryManager registryManager = RegistryManager.createFromConnectionString(connectionString);
    RegistryStatistics statistics = registryManager.getStatistics();
    //act
    final long disabledDeviceCount = statistics.getDisabledDeviceCount();
    final long enabledDeviceCount = statistics.getEnabledDeviceCount();
    final long totalDeviceCount = statistics.getTotalDeviceCount();
    //assert
    assertEquals(disabledDeviceCount, 0);
    assertEquals(enabledDeviceCount, 0);
    assertEquals(totalDeviceCount, 0);
}
Also used : RegistryStatistics(com.microsoft.azure.sdk.iot.service.RegistryStatistics) RegistryManager(com.microsoft.azure.sdk.iot.service.RegistryManager) Test(org.junit.Test)

Aggregations

RegistryManager (com.microsoft.azure.sdk.iot.service.RegistryManager)7 IotHubException (com.microsoft.azure.sdk.iot.service.exceptions.IotHubException)4 IOException (java.io.IOException)4 Device (com.microsoft.azure.sdk.iot.service.Device)3 RegistryStatistics (com.microsoft.azure.sdk.iot.service.RegistryStatistics)2 Test (org.junit.Test)2 JobProperties (com.microsoft.azure.sdk.iot.service.JobProperties)1 CloudStorageAccount (com.microsoft.azure.storage.CloudStorageAccount)1 CloudBlob (com.microsoft.azure.storage.blob.CloudBlob)1 CloudBlobClient (com.microsoft.azure.storage.blob.CloudBlobClient)1 CloudBlobContainer (com.microsoft.azure.storage.blob.CloudBlobContainer)1 ListBlobItem (com.microsoft.azure.storage.blob.ListBlobItem)1 FileOutputStream (java.io.FileOutputStream)1