use of com.microsoft.azure.sdk.iot.service.IotHubConnectionString in project azure-iot-sdk-java by Azure.
the class IotHubConnectionStringTest method getUrlJobsThrowsOnNullJobID.
@Test(expected = IllegalArgumentException.class)
public void getUrlJobsThrowsOnNullJobID() throws IOException, IllegalArgumentException {
// arrange
final String iotHubName = "b.c.d";
final String hostName = "HOSTNAME." + iotHubName;
final String sharedAccessKeyName = "ACCESSKEYNAME";
final String policyName = "SharedAccessKey";
final String sharedAccessKey = "1234567890abcdefghijklmnopqrstvwxyz=";
final String connectionString = "HostName=" + hostName + ";SharedAccessKeyName=" + sharedAccessKeyName + ";" + policyName + "=" + sharedAccessKey;
final String jobId = null;
final IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
// act
iotHubConnectionString.getUrlJobs(jobId).toString();
}
use of com.microsoft.azure.sdk.iot.service.IotHubConnectionString in project azure-iot-sdk-java by Azure.
the class IotHubConnectionStringTest method getUrlDeviceListGoodCase.
// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_12_005: [The function shall create a URL object from the given integer using the following format: https:hostname/devices/?maxCount=XX&api-version=201X-XX-XX]
@Test
public void getUrlDeviceListGoodCase() throws IOException, IllegalArgumentException {
// arrange
Integer maxCount = 10;
final String iotHubName = "b.c.d";
final String hostName = "HOSTNAME." + iotHubName;
final String sharedAccessKeyName = "ACCESSKEYNAME";
final String policyName = "SharedAccessKey";
final String sharedAccessKey = "1234567890abcdefghijklmnopqrstvwxyz=";
final String connectionString = "HostName=" + hostName + ";SharedAccessKeyName=" + sharedAccessKeyName + ";" + policyName + "=" + sharedAccessKey;
final IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
final String expected = "https://HOSTNAME.b.c.d/devices/?top=10&" + URL_API_VERSION;
// act
String actual = iotHubConnectionString.getUrlDeviceList(maxCount).toString();
// assert
assertEquals("DeviceList URL mismatch!", expected, actual);
}
use of com.microsoft.azure.sdk.iot.service.IotHubConnectionString in project azure-iot-sdk-java by Azure.
the class IotHubConnectionStringTest method getUrlDeviceStatisticsGoodCase.
// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_12_006: [The function shall create a URL object from the object properties using the following format: https:hostname/statistics/devices?api-version=201X-XX-XX]
@Test
public void getUrlDeviceStatisticsGoodCase() throws IOException {
// arrange
final String iotHubName = "b.c.d";
final String hostName = "HOSTNAME." + iotHubName;
final String sharedAccessKeyName = "ACCESSKEYNAME";
final String policyName = "SharedAccessKey";
final String sharedAccessKey = "1234567890abcdefghijklmnopqrstvwxyz=";
final String connectionString = "HostName=" + hostName + ";SharedAccessKeyName=" + sharedAccessKeyName + ";" + policyName + "=" + sharedAccessKey;
final IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
final String expected = "https://HOSTNAME.b.c.d/statistics/devices?" + URL_API_VERSION;
// act
String actual = iotHubConnectionString.getUrlDeviceStatistics().toString();
// assert
assertEquals("Device Statistics mismatch!", expected, actual);
}
use of com.microsoft.azure.sdk.iot.service.IotHubConnectionString in project azure-iot-sdk-java by Azure.
the class IotHubConnectionStringTest method getUrlConfigurationConfigurationNameEmpty.
// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_28_004: [The function shall throw IllegalArgumentException if the input string is empty or null]
// assert
@Test(expected = IllegalArgumentException.class)
public void getUrlConfigurationConfigurationNameEmpty() throws IOException, IllegalArgumentException {
// arrange
final String configurationId = "";
final String iotHubName = "b.c.d";
final String hostName = "HOSTNAME." + iotHubName;
final String sharedAccessKeyName = "ACCESSKEYNAME";
final String policyName = "SharedAccessKey";
final String sharedAccessKey = "1234567890abcdefghijklmnopqrstvwxyz=";
final String connectionString = "HostName=" + hostName + ";SharedAccessKeyName=" + sharedAccessKeyName + ";" + policyName + "=" + sharedAccessKey;
final IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
// act
iotHubConnectionString.getUrlConfiguration(configurationId);
}
use of com.microsoft.azure.sdk.iot.service.IotHubConnectionString in project azure-iot-sdk-java by Azure.
the class IotHubConnectionStringTest method getUrlModuleModuleNameNull.
// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_28_002: [The function shall throw IllegalArgumentException if the moduleId string is empty or null]
// assert
@Test(expected = IllegalArgumentException.class)
public void getUrlModuleModuleNameNull() throws IOException, IllegalArgumentException {
// arrange
final String deviceId = "somedevice";
final String moduleId = null;
final String iotHubName = "b.c.d";
final String hostName = "HOSTNAME." + iotHubName;
final String sharedAccessKeyName = "ACCESSKEYNAME";
final String policyName = "SharedAccessKey";
final String sharedAccessKey = "1234567890abcdefghijklmnopqrstvwxyz=";
final String connectionString = "HostName=" + hostName + ";SharedAccessKeyName=" + sharedAccessKeyName + ";" + policyName + "=" + sharedAccessKey;
final IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
// act
iotHubConnectionString.getUrlModule(deviceId, moduleId);
}
Aggregations