use of com.microsoft.azure.sdk.iot.service.devicetwin.Job in project azure-iot-sdk-java by Azure.
the class JobTest method scheduleUpdateTwinThrowOnInvalidMaxExecutionTimeInSeconds.
/* Tests_SRS_JOB_21_008: [If the maxExecutionTimeInSeconds is negative, the scheduleUpdateTwin shall throws IllegalArgumentException.] */
@Test(expected = IllegalArgumentException.class)
public void scheduleUpdateTwinThrowOnInvalidMaxExecutionTimeInSeconds() throws IOException {
// arrange
final String queryCondition = "validQueryCondition";
final DeviceTwinDevice deviceTwin = mockedDeviceTwinDevice;
final Date now = new Date();
final long maxExecutionTimeInSeconds = -100;
final String connectionString = "validConnectionString";
Job job = Deencapsulation.newInstance(Job.class, new Class[] { String.class }, connectionString);
// act
Deencapsulation.invoke(job, "scheduleUpdateTwin", new Class[] { String.class, DeviceTwinDevice.class, Date.class, Long.class }, queryCondition, deviceTwin, now, maxExecutionTimeInSeconds);
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.Job in project azure-iot-sdk-java by Azure.
the class DeviceMethodTest method scheduleDeviceMethodScheduleDeviceMethodSucceed.
/* Tests_SRS_DEVICEMETHOD_21_021: [The scheduleDeviceMethod shall invoke the scheduleDeviceMethod in the Job class with the received parameters.] */
@Test
public void scheduleDeviceMethodScheduleDeviceMethodSucceed(@Mocked Job mockedJob) throws IOException, IotHubException {
// arrange
final String queryCondition = "validQueryCondition";
final Date now = new Date();
final long maxExecutionTimeInSeconds = 100;
constructorExpectations();
DeviceMethod testMethod = DeviceMethod.createFromConnectionString(STANDARD_CONNECTIONSTRING);
new NonStrictExpectations() {
{
mockedIotHubConnectionString.toString();
result = STANDARD_CONNECTIONSTRING;
Deencapsulation.newInstance(Job.class, new Class[] { String.class }, anyString);
result = mockedJob;
}
};
// act
Job job = testMethod.scheduleDeviceMethod(queryCondition, STANDARD_METHODNAME, STANDARD_TIMEOUT_SECONDS, STANDARD_TIMEOUT_SECONDS, STANDARD_PAYLOAD_MAP, now, maxExecutionTimeInSeconds);
// assert
new Verifications() {
{
Deencapsulation.invoke(mockedJob, "scheduleDeviceMethod", queryCondition, STANDARD_METHODNAME, STANDARD_TIMEOUT_SECONDS, STANDARD_TIMEOUT_SECONDS, STANDARD_PAYLOAD_MAP, now, maxExecutionTimeInSeconds);
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.Job in project azure-iot-sdk-java by Azure.
the class DeviceMethodTest method scheduleDeviceMethodCreateJobSucceed.
/* Tests_SRS_DEVICEMETHOD_21_019: [The scheduleDeviceMethod shall create a new instance of the Job class.] */
/* Tests_SRS_DEVICEMETHOD_21_023: [The scheduleDeviceMethod shall return the created instance of the Job class.] */
@Test
public void scheduleDeviceMethodCreateJobSucceed(@Mocked Job mockedJob) throws IOException, IotHubException {
// arrange
final String queryCondition = "validQueryCondition";
final Date now = new Date();
final long maxExecutionTimeInSeconds = 100;
constructorExpectations();
DeviceMethod testMethod = DeviceMethod.createFromConnectionString(STANDARD_CONNECTIONSTRING);
new NonStrictExpectations() {
{
mockedIotHubConnectionString.toString();
result = STANDARD_CONNECTIONSTRING;
Deencapsulation.newInstance(Job.class, new Class[] { String.class }, anyString);
result = mockedJob;
times = 1;
}
};
// act
Job job = testMethod.scheduleDeviceMethod(queryCondition, STANDARD_METHODNAME, STANDARD_TIMEOUT_SECONDS, STANDARD_TIMEOUT_SECONDS, STANDARD_PAYLOAD_MAP, now, maxExecutionTimeInSeconds);
// assert
assertNotNull(job);
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.Job in project azure-iot-sdk-java by Azure.
the class DeviceTwinTest method schedule.
// Tests_SRS_DEVICETWIN_21_066: [The scheduleUpdateTwin shall invoke the scheduleUpdateTwin in the Job class with the received parameters ]
@Test
public void schedule(@Mocked Job mockedJob, @Mocked DeviceTwinDevice mockedDevice) throws IOException, IotHubException {
// arrange
final String connectionString = "testString";
final String queryCondition = "validQueryCondition";
final Date now = new Date();
final long maxExecutionTimeInSeconds = 100;
constructorExpectations(connectionString);
DeviceTwin testTwin = DeviceTwin.createFromConnectionString(connectionString);
new NonStrictExpectations() {
{
mockedConnectionString.toString();
result = connectionString;
Deencapsulation.newInstance(Job.class, new Class[] { String.class }, anyString);
result = mockedJob;
}
};
// act
Job job = testTwin.scheduleUpdateTwin(queryCondition, mockedDevice, now, maxExecutionTimeInSeconds);
// assert
new Verifications() {
{
Deencapsulation.invoke(mockedJob, "scheduleUpdateTwin", queryCondition, mockedDevice, now, maxExecutionTimeInSeconds);
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.Job in project azure-iot-sdk-java by Azure.
the class JobTest method scheduleUpdateTwinThrowOnNullStartTimeUTC.
/* Tests_SRS_JOB_21_007: [If the startTimeUtc is null, the scheduleUpdateTwin shall throws IllegalArgumentException.] */
@Test(expected = IllegalArgumentException.class)
public void scheduleUpdateTwinThrowOnNullStartTimeUTC() throws IOException {
// arrange
final String queryCondition = "validQueryCondition";
final DeviceTwinDevice deviceTwin = mockedDeviceTwinDevice;
final Date now = null;
final long maxExecutionTimeInSeconds = 100;
final String connectionString = "validConnectionString";
Job job = Deencapsulation.newInstance(Job.class, new Class[] { String.class }, connectionString);
// act
Deencapsulation.invoke(job, "scheduleUpdateTwin", new Class[] { String.class, DeviceTwinDevice.class, Date.class, Long.class }, queryCondition, deviceTwin, now, maxExecutionTimeInSeconds);
}
Aggregations