use of com.microsoft.azure.sdk.iot.service.IotHubConnectionString in project azure-iot-sdk-java by Azure.
the class IotHubConnectionStringTest method getUrlQueryWithoutJobTypeSucceeds.
// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_21_024: [** If the jobType is null or empty, the function shall not include the jobType in the URL **]**
@Test
public void getUrlQueryWithoutJobTypeSucceeds() 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/jobs/v2/query?jobStatus=jobStatus&" + URL_API_VERSION;
final String jobType = null;
final String jobStatus = "jobStatus";
// act
String actual = iotHubConnectionString.getUrlQuery(jobType, jobStatus).toString();
// assert
assertEquals(actual, expected);
}
use of com.microsoft.azure.sdk.iot.service.IotHubConnectionString in project azure-iot-sdk-java by Azure.
the class IotHubConnectionStringTest method getUrlQueryWithoutJobTypeAndJobStatusSucceeds.
// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_21_024: [** If the jobType is null or empty, the function shall not include the jobType in the URL **]**
// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_21_025: [** If the jobStatus is null or empty, the function shall not include the jobStatus in the URL **]**
@Test
public void getUrlQueryWithoutJobTypeAndJobStatusSucceeds() 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/jobs/v2/query?" + URL_API_VERSION;
final String jobType = null;
final String jobStatus = null;
// act
String actual = iotHubConnectionString.getUrlQuery(jobType, jobStatus).toString();
// assert
assertEquals(actual, expected);
}
use of com.microsoft.azure.sdk.iot.service.IotHubConnectionString in project azure-iot-sdk-java by Azure.
the class IotHubConnectionStringTest method getUrlModuleOnDeviceDeviceGoodCase.
// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_28_009: [The function shall create a URL object from the given
// deviceId using the following format: https:hostname/devices/deviceId/modules?api-version=201X-XX-XX]
@Test
public void getUrlModuleOnDeviceDeviceGoodCase() throws IOException, IllegalArgumentException {
// arrange
final String deviceId = "xxx-device";
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/xxx-device/modules?" + URL_API_VERSION;
// act
String actual = iotHubConnectionString.getUrlModulesOnDevice(deviceId).toString();
// assert
assertEquals("Device 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 getUrlConfigurationListMaxCountNull.
// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_28_006: [The constructor shall throw NullPointerException if the input integer is null]
// assert
@Test(expected = IllegalArgumentException.class)
public void getUrlConfigurationListMaxCountNull() throws IOException, IllegalArgumentException {
// arrange
Integer maxCount = 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.getUrlConfigurationsList(maxCount);
}
use of com.microsoft.azure.sdk.iot.service.IotHubConnectionString in project azure-iot-sdk-java by Azure.
the class IotHubConnectionStringTest method getUrlImportExportJobSucceeds.
/*
** Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_15_009: [The function shall create a URL object from the object properties using the following format: https:hostname/jobs/jobId?api-version=201X-XX-XX.]
*/
@Test
public void getUrlImportExportJobSucceeds() 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 IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
final String jobId = "testJobId";
final String expected = "https://HOSTNAME.b.c.d/jobs/testJobId?" + URL_API_VERSION;
// act
String actual = iotHubConnectionString.getUrlImportExportJob(jobId).toString();
// assert
assertEquals(actual, expected);
}
Aggregations