use of com.microsoft.azure.sdk.iot.provisioning.service.contract.ContractApiHttp in project azure-iot-sdk-java by Azure.
the class ContractApiHttpTest method requestThrowsOnNullPath.
/* SRS_HTTP_DEVICE_REGISTRATION_CLIENT_21_008: [If the provided path is null or empty, the request shall throw IllegalArgumentException.*/
@Test(expected = IllegalArgumentException.class)
public void requestThrowsOnNullPath() throws ProvisioningServiceClientException, IOException {
// arrange
new NonStrictExpectations() {
{
new ProvisioningSasToken(mockedProvisioningConnectionString);
result = mockedProvisioningSasToken;
mockedProvisioningSasToken.toString();
result = VALID_SASTOKEN;
mockedProvisioningConnectionString.getHostName();
result = VALID_HOST_NAME;
}
};
ContractApiHttp contractApiHttp = ContractApiHttp.createFromConnectionString(mockedProvisioningConnectionString);
// act
contractApiHttp.request(HttpMethod.PUT, null, VALID_HEADER, VALID_PAYLOAD);
// assert
}
use of com.microsoft.azure.sdk.iot.provisioning.service.contract.ContractApiHttp in project azure-iot-sdk-java by Azure.
the class ContractApiHttpTest method requestSendsHttpRequest.
/* SRS_HTTP_DEVICE_REGISTRATION_CLIENT_21_014: [The request shall send the request to the Device Provisioning Service by using the HttpRequest.send().*/
@Test
public void requestSendsHttpRequest() throws ProvisioningServiceClientException, IOException {
// arrange
ContractApiHttp contractApiHttp = ContractApiHttp.createFromConnectionString(mockedProvisioningConnectionString);
requestNonStrictExpectations();
// act
contractApiHttp.request(HttpMethod.PUT, VALID_PATH, VALID_HEADER, VALID_PAYLOAD);
// assert
new Verifications() {
{
mockedHttpRequest.send();
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.provisioning.service.contract.ContractApiHttp in project azure-iot-sdk-java by Azure.
the class ContractApiHttpTest method requestThrowsOnSasToken.
/* SRS_HTTP_DEVICE_REGISTRATION_CLIENT_21_006: [If the request get problem to create the SAS token, it shall throw IllegalArgumentException.*/
@Test(expected = IllegalArgumentException.class)
public void requestThrowsOnSasToken() throws ProvisioningServiceClientException, IOException {
// arrange
new NonStrictExpectations() {
{
new ProvisioningSasToken(mockedProvisioningConnectionString);
result = new IllegalArgumentException("");
}
};
ContractApiHttp contractApiHttp = ContractApiHttp.createFromConnectionString(mockedProvisioningConnectionString);
// act
contractApiHttp.request(HttpMethod.PUT, VALID_PATH, VALID_HEADER, VALID_PAYLOAD);
// assert
}
Aggregations