use of com.microsoft.azure.sdk.iot.device.IotHubStatusCode in project azure-iot-sdk-java by Azure.
the class ResponseMessageTest method constructorSetsRequiredPrivateMembers.
/* Tests_SRS_RESPONSEMESSAGE_21_001: [The constructor shall save the message body by calling super with the body as parameter.] */
/* Tests_SRS_RESPONSEMESSAGE_21_003: [The constructor shall save the status.] */
@Test
public void constructorSetsRequiredPrivateMembers() {
// arrange
final byte[] body = { 'A', 'B', 'C', '\0' };
final IotHubStatusCode status = IotHubStatusCode.OK;
// act
ResponseMessage msg = new ResponseMessage(body, status);
// assert
assertEquals(status, Deencapsulation.getField(msg, "status"));
assertEquals(body, Deencapsulation.getField(msg, "body"));
}
use of com.microsoft.azure.sdk.iot.device.IotHubStatusCode in project azure-iot-sdk-java by Azure.
the class IotHubStatusCodeTest method getIotHubStatusCodeMapsServerBusyCorrectly.
// Tests_SRS_IOTHUBSTATUSCODE_11_001: [The function shall convert the given HTTPS status code to the corresponding IoT Hub status code.]
@Test
public void getIotHubStatusCodeMapsServerBusyCorrectly() {
final int httpsStatus = 503;
IotHubStatusCode testStatus = IotHubStatusCode.getIotHubStatusCode(httpsStatus);
final IotHubStatusCode expectedStatus = IotHubStatusCode.SERVER_BUSY;
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 getIotHubStatusCodeMapsOtherStatusCodeToError.
// Tests_SRS_IOTHUBSTATUSCODE_11_002: [If the given HTTPS status code does not map to an IoT Hub status code, the function return status code ERROR.]
@Test
public void getIotHubStatusCodeMapsOtherStatusCodeToError() {
final int httpsStatus = -1;
IotHubStatusCode testStatus = IotHubStatusCode.getIotHubStatusCode(httpsStatus);
final IotHubStatusCode expectedStatus = IotHubStatusCode.ERROR;
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 getIotHubStatusCodeMapsBadFormatCorrectly.
// Tests_SRS_IOTHUBSTATUSCODE_11_001: [The function shall convert the given HTTPS status code to the corresponding IoT Hub status code.]
@Test
public void getIotHubStatusCodeMapsBadFormatCorrectly() {
final int httpsStatus = 400;
IotHubStatusCode testStatus = IotHubStatusCode.getIotHubStatusCode(httpsStatus);
final IotHubStatusCode expectedStatus = IotHubStatusCode.BAD_FORMAT;
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 getIotHubStatusCodeMapsInternalServerErrorCorrectly.
// Tests_SRS_IOTHUBSTATUSCODE_11_001: [The function shall convert the given HTTPS status code to the corresponding IoT Hub status code.]
@Test
public void getIotHubStatusCodeMapsInternalServerErrorCorrectly() {
final int httpsStatus = 500;
IotHubStatusCode testStatus = IotHubStatusCode.getIotHubStatusCode(httpsStatus);
final IotHubStatusCode expectedStatus = IotHubStatusCode.INTERNAL_SERVER_ERROR;
assertThat(testStatus, is(expectedStatus));
}
Aggregations