use of com.microsoft.azure.sdk.iot.service.devicetwin.MethodResult in project azure-iot-sdk-java by Azure.
the class DeviceMethodIT method invokeMethod_defaultResponseTimeout_succeed.
@Test
public void invokeMethod_defaultResponseTimeout_succeed() throws Exception {
// Arrange
TestDevice testDevice = devices.get(0);
// Act
MethodResult result = methodServiceClient.invoke(testDevice.getDeviceId(), METHOD_DELAY_IN_MILLISECONDS, null, CONNECTION_TIMEOUT, "100");
testDevice.waitIotHub(1, 10);
// Assert
assertNotNull(result);
assertEquals((long) METHOD_SUCCESS, (long) result.getStatus());
assertEquals(METHOD_DELAY_IN_MILLISECONDS + ":succeed", result.getPayload());
assertEquals(0, testDevice.getStatusError());
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.MethodResult in project azure-iot-sdk-java by Azure.
the class DeviceMethodIT method invokeMethod_throws_NumberFormatException_failed.
@Test
public void invokeMethod_throws_NumberFormatException_failed() throws Exception {
// Arrange
TestDevice testDevice = devices.get(0);
// Act
MethodResult result = methodServiceClient.invoke(testDevice.getDeviceId(), METHOD_DELAY_IN_MILLISECONDS, RESPONSE_TIMEOUT, CONNECTION_TIMEOUT, PAYLOAD_STRING);
testDevice.waitIotHub(1, 10);
// Assert
assertNotNull(result);
assertEquals((long) METHOD_THROWS, (long) result.getStatus());
assertEquals("java.lang.NumberFormatException: For input string: \"" + PAYLOAD_STRING + "\"", result.getPayload());
assertEquals(0, testDevice.getStatusError());
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.MethodResult in project azure-iot-sdk-java by Azure.
the class DeviceMethodIT method invokeMethod_unknown_failed.
@Test
public void invokeMethod_unknown_failed() throws Exception {
// Arrange
TestDevice testDevice = devices.get(0);
// Act
MethodResult result = methodServiceClient.invoke(testDevice.getDeviceId(), METHOD_UNKNOWN, RESPONSE_TIMEOUT, CONNECTION_TIMEOUT, PAYLOAD_STRING);
testDevice.waitIotHub(1, 10);
// Assert
assertNotNull(result);
assertEquals((long) METHOD_NOT_DEFINED, (long) result.getStatus());
assertEquals("unknown:" + METHOD_UNKNOWN, result.getPayload());
assertEquals(0, testDevice.getStatusError());
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.MethodResult in project azure-iot-sdk-java by Azure.
the class DeviceMethodIT method invokeMethod_recoverFromTimeout_succeed.
@Test
public void invokeMethod_recoverFromTimeout_succeed() throws Exception {
// Arrange
TestDevice testDevice = devices.get(0);
try {
methodServiceClient.invoke(testDevice.getDeviceId(), METHOD_DELAY_IN_MILLISECONDS, (long) 5, CONNECTION_TIMEOUT, "7000");
assert true;
} catch (IotHubGatewayTimeoutException expected) {
//Don't do anything. Expected throw.
}
// Act
MethodResult result = methodServiceClient.invoke(testDevice.getDeviceId(), METHOD_DELAY_IN_MILLISECONDS, RESPONSE_TIMEOUT, CONNECTION_TIMEOUT, "100");
testDevice.waitIotHub(1, 10);
// Assert
assertNotNull(result);
assertEquals((long) METHOD_SUCCESS, (long) result.getStatus());
assertEquals(METHOD_DELAY_IN_MILLISECONDS + ":succeed", result.getPayload());
assertEquals(0, testDevice.getStatusError());
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.MethodResult in project azure-iot-sdk-java by Azure.
the class DeviceMethodIT method invokeMethod_succeed.
@Test
public void invokeMethod_succeed() throws Exception {
// Arrange
TestDevice testDevice = devices.get(0);
// Act
MethodResult result = methodServiceClient.invoke(testDevice.getDeviceId(), METHOD_LOOPBACK, RESPONSE_TIMEOUT, CONNECTION_TIMEOUT, PAYLOAD_STRING);
testDevice.waitIotHub(1, 10);
// Assert
assertNotNull(result);
assertEquals((long) METHOD_SUCCESS, (long) result.getStatus());
assertEquals(METHOD_LOOPBACK + ":" + PAYLOAD_STRING, result.getPayload());
assertEquals(0, testDevice.getStatusError());
}
Aggregations