Search in sources :

Example 11 with IotHubStatusCode

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"));
}
Also used : IotHubStatusCode(com.microsoft.azure.sdk.iot.device.IotHubStatusCode) ResponseMessage(com.microsoft.azure.sdk.iot.device.ResponseMessage) Test(org.junit.Test)

Example 12 with IotHubStatusCode

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));
}
Also used : IotHubStatusCode(com.microsoft.azure.sdk.iot.device.IotHubStatusCode) Test(org.junit.Test)

Example 13 with IotHubStatusCode

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));
}
Also used : IotHubStatusCode(com.microsoft.azure.sdk.iot.device.IotHubStatusCode) Test(org.junit.Test)

Example 14 with IotHubStatusCode

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));
}
Also used : IotHubStatusCode(com.microsoft.azure.sdk.iot.device.IotHubStatusCode) Test(org.junit.Test)

Example 15 with IotHubStatusCode

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));
}
Also used : IotHubStatusCode(com.microsoft.azure.sdk.iot.device.IotHubStatusCode) Test(org.junit.Test)

Aggregations

IotHubStatusCode (com.microsoft.azure.sdk.iot.device.IotHubStatusCode)20 Test (org.junit.Test)19 ResponseMessage (com.microsoft.azure.sdk.iot.device.ResponseMessage)5 IotHubCallbackPacket (com.microsoft.azure.sdk.iot.device.transport.IotHubCallbackPacket)4 HashMap (java.util.HashMap)4 DeviceTwinMessage (com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceTwinMessage)1 IotHubEventCallback (com.microsoft.azure.sdk.iot.device.IotHubEventCallback)1 IotHubResponseCallback (com.microsoft.azure.sdk.iot.device.IotHubResponseCallback)1 IOException (java.io.IOException)1 Map (java.util.Map)1