use of com.microsoft.azure.sdk.iot.device.fileupload.FileUploadInProgress in project azure-iot-sdk-java by Azure.
the class FileUploadInProgressTest method isCancelledThrows.
@Test
public void isCancelledThrows() {
// arrange
final Map<String, Object> context = new HashMap<>();
FileUploadInProgress fileUploadInProgress = Deencapsulation.newInstance(FileUploadInProgress.class, new Class[] { IotHubEventCallback.class, Object.class }, mockIotHubEventCallback, context);
// act
assertFalse((boolean) Deencapsulation.invoke(fileUploadInProgress, "isCancelled"));
}
use of com.microsoft.azure.sdk.iot.device.fileupload.FileUploadInProgress in project azure-iot-sdk-java by Azure.
the class FileUploadInProgressTest method setTaskSuccess.
/* Codes_SRS_FILEUPLOADINPROGRESS_21_003: [The setTask shall sore the content of the `task`.] */
@Test
public void setTaskSuccess() {
// arrange
final Map<String, Object> context = new HashMap<>();
FileUploadInProgress fileUploadInProgress = Deencapsulation.newInstance(FileUploadInProgress.class, new Class[] { IotHubEventCallback.class, Object.class }, mockIotHubEventCallback, context);
// act
Deencapsulation.invoke(fileUploadInProgress, "setTask", new Class[] { Future.class }, mockFuture);
// assert
assertEquals(mockFuture, Deencapsulation.getField(fileUploadInProgress, "task"));
}
use of com.microsoft.azure.sdk.iot.device.fileupload.FileUploadInProgress in project azure-iot-sdk-java by Azure.
the class FileUploadTest method closeNowWithPendingUploadSuccess.
/* Tests_SRS_FILEUPLOAD_21_018: [If there is pending file uploads, the closeNow shall cancel the upload, and call the `statusCallback` reporting ERROR.] */
@Test
public void closeNowWithPendingUploadSuccess(@Mocked final Future mockFuture) throws IOException {
// arrange
final Map<String, Object> context = new HashMap<>();
final Queue<FileUploadInProgress> fileUploadInProgressSet = new LinkedBlockingDeque<FileUploadInProgress>() {
{
add(mockFileUploadInProgress);
}
};
new NonStrictExpectations() {
{
new HttpsTransportManager(mockConfig);
result = mockHttpsTransportManager;
Executors.newScheduledThreadPool(10);
result = mockScheduler;
Deencapsulation.invoke(mockFileUploadInProgress, "isCancelled");
result = true;
}
};
FileUpload fileUpload = new FileUpload(mockConfig);
Deencapsulation.setField(fileUpload, "fileUploadInProgressesSet", fileUploadInProgressSet);
// act
fileUpload.closeNow();
// assert
new Verifications() {
{
Deencapsulation.invoke(mockFileUploadInProgress, "triggerCallback", new Class[] { IotHubStatusCode.class }, IotHubStatusCode.ERROR);
times = 1;
}
};
}
Aggregations