use of com.microsoft.azure.sdk.iot.device.exceptions.BadFormatException in project azure-iot-sdk-java by Azure.
the class FileUploadTaskTest method sendNotificationChecksHttpStatusCode.
@Test
public void sendNotificationChecksHttpStatusCode() throws IOException, IllegalArgumentException, URISyntaxException {
// arrange
FileUploadTask fileUploadTask = Deencapsulation.newInstance(FileUploadTask.class, new Class[] { String.class, InputStream.class, long.class, HttpsTransportManager.class, IotHubEventCallback.class, Object.class }, VALID_BLOB_NAME, mockInputStream, VALID_STREAM_LENGTH, mockHttpsTransportManager, mockIotHubEventCallback, VALID_CALLBACK_CONTEXT);
new Expectations() {
{
mockHttpsTransportManager.sendFileUploadNotification((IotHubTransportMessage) any);
result = mockResponseMessage;
mockResponseMessage.getStatus();
result = IotHubStatusCode.BAD_FORMAT;
}
};
// act
try {
fileUploadTask.sendNotification(mockFileUploadNotification);
fail("Test should have thrown an IOException with a nested BadFormatException");
} catch (IOException e) {
assertNotNull(e.getCause());
assertTrue(e.getCause() instanceof BadFormatException);
}
}
Aggregations