use of com.microsoft.azure.sdk.iot.device.ResponseMessage in project azure-iot-sdk-java by Azure.
the class FileUploadTask method getFileUploadSasUri.
public FileUploadSasUriResponse getFileUploadSasUri(FileUploadSasUriRequest request) throws IOException {
IotHubTransportMessage message = new IotHubTransportMessage(request.toJson());
message.setIotHubMethod(IotHubMethod.POST);
ResponseMessage responseMessage;
httpsTransportManager.open();
responseMessage = httpsTransportManager.getFileUploadSasUri(message);
httpsTransportManager.close();
String responseMessagePayload = validateServiceStatusCode(responseMessage, "Failed to get the file upload SAS URI");
if (responseMessagePayload == null || responseMessagePayload.isEmpty()) {
throw new IOException("Sas URI response message had no payload");
}
return new FileUploadSasUriResponse(responseMessagePayload);
}
use of com.microsoft.azure.sdk.iot.device.ResponseMessage in project azure-iot-sdk-java by Azure.
the class ResponseMessageTest method constructorNullBodyThrows.
/* Tests_SRS_RESPONSEMESSAGE_21_002: [If the message body is null, the constructor shall throw an IllegalArgumentException thrown by base constructor.] */
@Test(expected = IllegalArgumentException.class)
public void constructorNullBodyThrows() {
// arrange
final byte[] body = null;
final IotHubStatusCode status = IotHubStatusCode.OK;
// act
ResponseMessage msg = new ResponseMessage(body, status);
}
use of com.microsoft.azure.sdk.iot.device.ResponseMessage in project azure-iot-sdk-java by Azure.
the class ResponseMessageTest method constructorSetsRequiredPrivateMembers.
/* Tests_SRS_RESPONSEMESSAGE_21_001: [The constructor shall save the message body by calling super with the body as parameter.] */
/* Tests_SRS_RESPONSEMESSAGE_21_003: [The constructor shall save the status.] */
@Test
public void constructorSetsRequiredPrivateMembers() {
// arrange
final byte[] body = { 'A', 'B', 'C', '\0' };
final IotHubStatusCode status = IotHubStatusCode.OK;
// act
ResponseMessage msg = new ResponseMessage(body, status);
// assert
assertEquals(status, Deencapsulation.getField(msg, "status"));
assertEquals(body, Deencapsulation.getField(msg, "body"));
}
use of com.microsoft.azure.sdk.iot.device.ResponseMessage in project azure-iot-sdk-java by Azure.
the class ResponseMessageTest method constructorNullBodyThrows.
/* Tests_SRS_RESPONSEMESSAGE_21_002: [If the message body is null, the constructor shall throw an IllegalArgumentException thrown by base constructor.] */
@Test(expected = IllegalArgumentException.class)
public void constructorNullBodyThrows() {
// arrange
final byte[] body = null;
final IotHubStatusCode status = IotHubStatusCode.OK;
// act
ResponseMessage msg = new ResponseMessage(body, status);
}
use of com.microsoft.azure.sdk.iot.device.ResponseMessage in project azure-iot-sdk-java by Azure.
the class ResponseMessageTest method constructorSetsRequiredPrivateMembers.
/* Tests_SRS_RESPONSEMESSAGE_21_001: [The constructor shall save the message body by calling super with the body as parameter.] */
/* Tests_SRS_RESPONSEMESSAGE_21_003: [The constructor shall save the status.] */
@Test
public void constructorSetsRequiredPrivateMembers() {
// arrange
final byte[] body = { 'A', 'B', 'C', '\0' };
final IotHubStatusCode status = IotHubStatusCode.OK;
// act
ResponseMessage msg = new ResponseMessage(body, status);
// assert
assertEquals(status, Deencapsulation.getField(msg, "status"));
assertEquals(body, Deencapsulation.getField(msg, "body"));
}
Aggregations