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