use of com.microsoft.azure.sdk.iot.device.fileupload.FileUploadInProgress in project azure-iot-sdk-java by Azure.
the class FileUploadInProgressTest method isCancelledFalseSuccess.
/* Codes_SRS_FILEUPLOADINPROGRESS_21_006: [The isCancelled shall return the value of isCancelled on the `task`.] */
@Test
public void isCancelledFalseSuccess() {
// arrange
final Map<String, Object> context = new HashMap<>();
FileUploadInProgress fileUploadInProgress = Deencapsulation.newInstance(FileUploadInProgress.class, new Class[] { IotHubEventCallback.class, Object.class }, mockIotHubEventCallback, context);
Deencapsulation.invoke(fileUploadInProgress, "setTask", new Class[] { Future.class }, mockFuture);
new NonStrictExpectations() {
{
mockFuture.isCancelled();
result = false;
times = 1;
}
};
// act
boolean result = (boolean) Deencapsulation.invoke(fileUploadInProgress, "isCancelled");
// assert
assertFalse(result);
}
use of com.microsoft.azure.sdk.iot.device.fileupload.FileUploadInProgress in project azure-iot-sdk-java by Azure.
the class FileUploadInProgressTest method isCancelledTrueSuccess.
/* Codes_SRS_FILEUPLOADINPROGRESS_21_006: [The isCancelled shall return the value of isCancelled on the `task`.] */
@Test
public void isCancelledTrueSuccess() {
// arrange
final Map<String, Object> context = new HashMap<>();
FileUploadInProgress fileUploadInProgress = Deencapsulation.newInstance(FileUploadInProgress.class, new Class[] { IotHubEventCallback.class, Object.class }, mockIotHubEventCallback, context);
Deencapsulation.invoke(fileUploadInProgress, "setTask", new Class[] { Future.class }, mockFuture);
new NonStrictExpectations() {
{
mockFuture.isCancelled();
result = true;
times = 1;
}
};
// act
boolean result = (boolean) Deencapsulation.invoke(fileUploadInProgress, "isCancelled");
// assert
assertTrue(result);
}
use of com.microsoft.azure.sdk.iot.device.fileupload.FileUploadInProgress in project azure-iot-sdk-java by Azure.
the class FileUploadInProgressTest method triggerCallbackSuccess.
/* Codes_SRS_FILEUPLOADINPROGRESS_21_005: [The triggerCallback shall call the execute in `statusCallback` with the provided `iotHubStatusCode` and `statusCallbackContext`.] */
@Test
public void triggerCallbackSuccess() {
// 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, "triggerCallback", new Class[] { IotHubStatusCode.class }, IotHubStatusCode.OK);
// assert
new Verifications() {
{
Deencapsulation.invoke(mockIotHubEventCallback, "execute", new Class[] { IotHubStatusCode.class, Object.class }, IotHubStatusCode.OK, context);
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.device.fileupload.FileUploadInProgress in project azure-iot-sdk-java by Azure.
the class FileUploadInProgressTest method constructorSuccess.
/* Codes_SRS_FILEUPLOADINPROGRESS_21_001: [The constructor shall sore the content of the `statusCallback`, and `statusCallbackContext`.] */
@Test
public void constructorSuccess() {
// arrange
final Map<String, Object> context = new HashMap<>();
// act
FileUploadInProgress fileUploadInProgress = Deencapsulation.newInstance(FileUploadInProgress.class, new Class[] { IotHubEventCallback.class, Object.class }, mockIotHubEventCallback, context);
// assert
assertEquals(mockIotHubEventCallback, Deencapsulation.getField(fileUploadInProgress, "statusCallback"));
assertEquals(context, Deencapsulation.getField(fileUploadInProgress, "statusCallbackContext"));
}
use of com.microsoft.azure.sdk.iot.device.fileupload.FileUploadInProgress in project azure-iot-sdk-java by Azure.
the class FileUploadInProgressTest method setTaskThrows.
/* Codes_SRS_FILEUPLOADINPROGRESS_21_004: [If the `task` is null, the setTask shall throws IllegalArgumentException.] */
@Test(expected = IllegalArgumentException.class)
public void setTaskThrows() {
// 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 }, (Future) null);
}
Aggregations