use of com.microsoft.azure.sdk.iot.device.fileupload.FileUploadStatusCallBack in project azure-iot-sdk-java by Azure.
the class FileUploadTest method callbackDeleteFileUploadInProgressThrows.
@Test
public void callbackDeleteFileUploadInProgressThrows(@Mocked final LinkedBlockingDeque<?> mockFileUploadInProgressQueue) throws IOException {
// arrange
final Map<String, Object> context = new HashMap<>();
constructorExpectations();
new NonStrictExpectations() {
{
new LinkedBlockingDeque<>();
result = mockFileUploadInProgressQueue;
mockFileUploadInProgressQueue.remove(mockFileUploadInProgress);
result = new UnsupportedOperationException();
}
};
FileUpload fileUpload = new FileUpload(mockConfig);
IotHubEventCallback testFileUploadStatusCallBack = new FileUploadStatusCallBack();
// act
testFileUploadStatusCallBack.execute(IotHubStatusCode.OK_EMPTY, mockFileUploadInProgress);
// assert
new Verifications() {
{
Deencapsulation.invoke(mockFileUploadInProgress, "triggerCallback", new Class[] { IotHubStatusCode.class }, IotHubStatusCode.OK_EMPTY);
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.device.fileupload.FileUploadStatusCallBack in project azure-iot-sdk-java by Azure.
the class FileUploadTest method callbackBypassStatus.
/* Tests_SRS_FILEUPLOAD_21_014: [The constructor shall create an Event callback `fileUploadStatusCallBack` to receive the upload status.] */
/* Tests_SRS_FILEUPLOAD_21_019: [The FileUploadStatusCallBack shall implements the `IotHubEventCallback` as result of the FileUploadTask.] */
/* Tests_SRS_FILEUPLOAD_21_020: [The FileUploadStatusCallBack shall call the `statusCallback` reporting the received status.] */
@Test
public void callbackBypassStatus() throws IOException {
// arrange
final Map<String, Object> context = new HashMap<>();
constructorExpectations();
FileUpload fileUpload = new FileUpload(mockConfig);
IotHubEventCallback testFileUploadStatusCallBack = new FileUploadStatusCallBack();
// act
testFileUploadStatusCallBack.execute(IotHubStatusCode.OK_EMPTY, mockFileUploadInProgress);
// assert
new Verifications() {
{
Deencapsulation.invoke(mockFileUploadInProgress, "triggerCallback", new Class[] { IotHubStatusCode.class }, IotHubStatusCode.OK_EMPTY);
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.device.fileupload.FileUploadStatusCallBack in project azure-iot-sdk-java by Azure.
the class FileUploadTest method callbackDeleteFileUploadInProgress.
/* Tests_SRS_FILEUPLOAD_21_021: [The FileUploadStatusCallBack shall delete the `FileUploadInProgress` that store this file upload context.] */
@Test
public void callbackDeleteFileUploadInProgress(@Mocked final LinkedBlockingDeque<?> mockFileUploadInProgressQueue) throws IOException {
// arrange
final Map<String, Object> context = new HashMap<>();
new NonStrictExpectations() {
{
new HttpsTransportManager(mockConfig);
result = mockHttpsTransportManager;
Executors.newScheduledThreadPool(10);
result = mockScheduler;
new LinkedBlockingDeque<>();
result = mockFileUploadInProgressQueue;
}
};
FileUpload fileUpload = new FileUpload(mockConfig);
IotHubEventCallback testFileUploadStatusCallBack = new FileUploadStatusCallBack();
// act
testFileUploadStatusCallBack.execute(IotHubStatusCode.OK_EMPTY, mockFileUploadInProgress);
// assert
new Verifications() {
{
mockFileUploadInProgressQueue.remove(mockFileUploadInProgress);
times = 1;
}
};
}
Aggregations