Search in sources :

Example 6 with IotHubStatusCode

use of com.microsoft.azure.sdk.iot.device.IotHubStatusCode in project azure-iot-sdk-java by Azure.

the class ResponseMessageTest method getStatusReturnStatus.

/* Tests_SRS_RESPONSEMESSAGE_21_005: [The getStatus shall return the stored status.] */
@Test
public void getStatusReturnStatus() {
    // arrange
    final byte[] body = { 'A', 'B', 'C', '\0' };
    final IotHubStatusCode status = IotHubStatusCode.OK;
    // act
    ResponseMessage msg = new ResponseMessage(body, status);
    // assert
    assertEquals(status, Deencapsulation.invoke(msg, "getStatus"));
}
Also used : IotHubStatusCode(com.microsoft.azure.sdk.iot.device.IotHubStatusCode) ResponseMessage(com.microsoft.azure.sdk.iot.device.ResponseMessage) Test(org.junit.Test)

Example 7 with IotHubStatusCode

use of com.microsoft.azure.sdk.iot.device.IotHubStatusCode in project azure-iot-sdk-java by Azure.

the class ResponseMessageTest method constructorNullStatusThrows.

/* Tests_SRS_RESPONSEMESSAGE_21_004: [If the message status is null, the constructor shall throw an IllegalArgumentException.] */
@Test(expected = IllegalArgumentException.class)
public void constructorNullStatusThrows() {
    // arrange
    final byte[] body = { 'A', 'B', 'C', '\0' };
    final IotHubStatusCode status = null;
    // act
    ResponseMessage msg = new ResponseMessage(body, status);
}
Also used : IotHubStatusCode(com.microsoft.azure.sdk.iot.device.IotHubStatusCode) ResponseMessage(com.microsoft.azure.sdk.iot.device.ResponseMessage) Test(org.junit.Test)

Example 8 with IotHubStatusCode

use of com.microsoft.azure.sdk.iot.device.IotHubStatusCode in project azure-iot-sdk-java by Azure.

the class IotHubStatusCodeTest method getIotHubStatusCodeMapsThrottledCorrectly.

// Tests_SRS_IOTHUBSTATUSCODE_11_001: [The function shall convert the given HTTPS status code to the corresponding IoT Hub status code.]
@Test
public void getIotHubStatusCodeMapsThrottledCorrectly() {
    final int httpsStatus = 429;
    IotHubStatusCode testStatus = IotHubStatusCode.getIotHubStatusCode(httpsStatus);
    final IotHubStatusCode expectedStatus = IotHubStatusCode.THROTTLED;
    assertThat(testStatus, is(expectedStatus));
}
Also used : IotHubStatusCode(com.microsoft.azure.sdk.iot.device.IotHubStatusCode) Test(org.junit.Test)

Example 9 with IotHubStatusCode

use of com.microsoft.azure.sdk.iot.device.IotHubStatusCode in project azure-iot-sdk-java by Azure.

the class ResponseMessageTest method constructorNullBodyThrows.

/* Tests_SRS_RESPONSEMESSAGE_21_002: [If the message body is null, the constructor shall throw an IllegalArgumentException thrown by base constructor.] */
@Test(expected = IllegalArgumentException.class)
public void constructorNullBodyThrows() {
    // arrange
    final byte[] body = null;
    final IotHubStatusCode status = IotHubStatusCode.OK;
    // act
    ResponseMessage msg = new ResponseMessage(body, status);
}
Also used : IotHubStatusCode(com.microsoft.azure.sdk.iot.device.IotHubStatusCode) ResponseMessage(com.microsoft.azure.sdk.iot.device.ResponseMessage) Test(org.junit.Test)

Example 10 with IotHubStatusCode

use of com.microsoft.azure.sdk.iot.device.IotHubStatusCode in project azure-iot-sdk-java by Azure.

the class IotHubStatusCodeTest method getIotHubStatusCodeMapsHubOrDeviceNotFoundCorrectly.

// Tests_SRS_IOTHUBSTATUSCODE_11_001: [The function shall convert the given HTTPS status code to the corresponding IoT Hub status code.]
@Test
public void getIotHubStatusCodeMapsHubOrDeviceNotFoundCorrectly() {
    final int httpsStatus = 404;
    IotHubStatusCode testStatus = IotHubStatusCode.getIotHubStatusCode(httpsStatus);
    final IotHubStatusCode expectedStatus = IotHubStatusCode.HUB_OR_DEVICE_ID_NOT_FOUND;
    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