use of com.microsoft.azure.sdk.iot.device.IotHubStatusCode in project azure-iot-sdk-java by Azure.
the class IotHubCallbackPacketTest method getResponseCallbackReturnsNull.
// Tests_SRS_IOTHUBCALLBACKPACKET_11_001: [The constructor shall save the status, eventCallback, and callback context.]
// Tests_SRS_IOTHUBCALLBACKPACKET_21_007: [The constructor shall set message and responseCallback as null.]
@Test
public void getResponseCallbackReturnsNull() {
final IotHubStatusCode status = IotHubStatusCode.HUB_OR_DEVICE_ID_NOT_FOUND;
final Map<String, Object> context = new HashMap<>();
IotHubCallbackPacket packet = new IotHubCallbackPacket(status, mockEventCallback, context);
IotHubResponseCallback testCallback = packet.getResponseCallback();
ResponseMessage testMessage = packet.getResponseMessage();
assertNull(testCallback);
assertNull(testMessage);
}
use of com.microsoft.azure.sdk.iot.device.IotHubStatusCode in project azure-iot-sdk-java by Azure.
the class IotHubCallbackPacketTest method getStatusReturnsStatus.
// Tests_SRS_IOTHUBCALLBACKPACKET_11_001: [The constructor shall save the status, eventCallback, and callback context.]
// Tests_SRS_IOTHUBCALLBACKPACKET_11_002: [The function shall return the status given in the constructor.]
@Test
public void getStatusReturnsStatus() {
final IotHubStatusCode status = IotHubStatusCode.BAD_FORMAT;
final Map<String, Object> context = new HashMap<>();
IotHubCallbackPacket packet = new IotHubCallbackPacket(status, mockEventCallback, context);
IotHubStatusCode testStatus = packet.getStatus();
final IotHubStatusCode expectedStatus = status;
assertThat(testStatus, is(expectedStatus));
}
use of com.microsoft.azure.sdk.iot.device.IotHubStatusCode in project azure-iot-sdk-java by Azure.
the class IotHubCallbackPacketTest method getEventCallbackReturnsCallback.
// Tests_SRS_IOTHUBCALLBACKPACKET_11_001: [The constructor shall save the status, eventCallback, and callback context.]
// Tests_SRS_IOTHUBCALLBACKPACKET_11_003: [The function shall return the eventCallback given in the constructor.]
@Test
public void getEventCallbackReturnsCallback() {
final IotHubStatusCode status = IotHubStatusCode.HUB_OR_DEVICE_ID_NOT_FOUND;
final Map<String, Object> context = new HashMap<>();
IotHubCallbackPacket packet = new IotHubCallbackPacket(status, mockEventCallback, context);
IotHubEventCallback testCallback = packet.getCallback();
assertThat(testCallback, is(mockEventCallback));
}
use of com.microsoft.azure.sdk.iot.device.IotHubStatusCode in project azure-iot-sdk-java by Azure.
the class IotHubStatusCodeTest method getIotHubStatusCodeMapsOkCorrectly.
// Tests_SRS_IOTHUBSTATUSCODE_11_001: [The function shall convert the given HTTPS status code to the corresponding IoT Hub status code.]
@Test
public void getIotHubStatusCodeMapsOkCorrectly() {
final int httpsStatus = 200;
IotHubStatusCode testStatus = IotHubStatusCode.getIotHubStatusCode(httpsStatus);
final IotHubStatusCode expectedStatus = IotHubStatusCode.OK;
assertThat(testStatus, is(expectedStatus));
}
use of com.microsoft.azure.sdk.iot.device.IotHubStatusCode in project azure-iot-sdk-java by Azure.
the class IotHubStatusCodeTest method getIotHubStatusCodeMapsPreconditionFailedCorrectly.
// Tests_SRS_IOTHUBSTATUSCODE_11_001: [The function shall convert the given HTTPS status code to the corresponding IoT Hub status code.]
@Test
public void getIotHubStatusCodeMapsPreconditionFailedCorrectly() {
final int httpsStatus = 412;
IotHubStatusCode testStatus = IotHubStatusCode.getIotHubStatusCode(httpsStatus);
final IotHubStatusCode expectedStatus = IotHubStatusCode.PRECONDITION_FAILED;
assertThat(testStatus, is(expectedStatus));
}
Aggregations