Search in sources :

Example 1 with IotHubResponseCallback

use of com.microsoft.azure.sdk.iot.device.IotHubResponseCallback 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);
}
Also used : IotHubStatusCode(com.microsoft.azure.sdk.iot.device.IotHubStatusCode) HashMap(java.util.HashMap) IotHubCallbackPacket(com.microsoft.azure.sdk.iot.device.transport.IotHubCallbackPacket) IotHubResponseCallback(com.microsoft.azure.sdk.iot.device.IotHubResponseCallback) ResponseMessage(com.microsoft.azure.sdk.iot.device.ResponseMessage) Test(org.junit.Test)

Example 2 with IotHubResponseCallback

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

the class IotHubCallbackPacketTest method getResponseCallbackReturnsCallback.

// Tests_SRS_IOTHUBCALLBACKPACKET_21_006: [The constructor shall save the responseMessage, responseCallback, and callback context.]
// Tests_SRS_IOTHUBCALLBACKPACKET_21_005: [The getResponseCallback shall return the responseCallback given in the constructor.]
@Test
public void getResponseCallbackReturnsCallback() {
    // arrange
    final Map<String, Object> context = new HashMap<>();
    // act
    IotHubCallbackPacket packet = new IotHubCallbackPacket(mockMessage, mockResponseCallback, context);
    // assert
    IotHubResponseCallback testCallback = packet.getResponseCallback();
    assertThat(testCallback, is(mockResponseCallback));
    ResponseMessage testMessage = packet.getResponseMessage();
    assertThat(testMessage, is(mockMessage));
    Map<String, Object> testContext = (Map<String, Object>) packet.getContext();
    Set<Map.Entry<String, Object>> testEntrySet = testContext.entrySet();
    final Set<Map.Entry<String, Object>> expectedEntrySet = context.entrySet();
    assertThat(testEntrySet, everyItem(isIn(expectedEntrySet)));
}
Also used : HashMap(java.util.HashMap) IotHubCallbackPacket(com.microsoft.azure.sdk.iot.device.transport.IotHubCallbackPacket) IotHubResponseCallback(com.microsoft.azure.sdk.iot.device.IotHubResponseCallback) ResponseMessage(com.microsoft.azure.sdk.iot.device.ResponseMessage) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 3 with IotHubResponseCallback

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

the class IotHubOutboundPacketTest method getCallbackWithMessageReturnsCallback.

// Tests_SRS_IOTHUBOUTBOUNDPACKET_21_005: [The constructor shall save the message, callback, and callback context.]
// Tests_SRS_IOTHUBOUTBOUNDPACKET_11_006: [The function shall return the response callback given in the constructor.]
// Tests_SRS_IOTHUBOUTBOUNDPACKET_21_008: [The constructor shall set the event callback as null.]
@Test
public void getCallbackWithMessageReturnsCallback() {
    final Map<String, Object> context = new HashMap<>();
    IotHubOutboundPacket packet = new IotHubOutboundPacket(mockMsg, mockResponseCallback, context);
    IotHubEventCallback testCallback = packet.getCallback();
    IotHubResponseCallback testResponseCallback = packet.getResponseCallback();
    final IotHubResponseCallback expectedCallback = mockResponseCallback;
    assertThat(testResponseCallback, is(expectedCallback));
    assertNull(testCallback);
}
Also used : IotHubEventCallback(com.microsoft.azure.sdk.iot.device.IotHubEventCallback) HashMap(java.util.HashMap) IotHubOutboundPacket(com.microsoft.azure.sdk.iot.device.transport.IotHubOutboundPacket) IotHubResponseCallback(com.microsoft.azure.sdk.iot.device.IotHubResponseCallback) Test(org.junit.Test)

Example 4 with IotHubResponseCallback

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

the class IotHubOutboundPacketTest method getCallbackReturnsCallback.

// Tests_SRS_IOTHUBOUTBOUNDPACKET_11_001: [The constructor shall save the message, callback, and callback context.]
// Tests_SRS_IOTHUBOUTBOUNDPACKET_11_003: [The function shall return the event callback given in the constructor.]
// Tests_SRS_IOTHUBOUTBOUNDPACKET_21_007: [The constructor shall set the response callback as null.]
@Test
public void getCallbackReturnsCallback() {
    final Map<String, Object> context = new HashMap<>();
    IotHubOutboundPacket packet = new IotHubOutboundPacket(mockMsg, mockCallback, context);
    IotHubEventCallback testCallback = packet.getCallback();
    IotHubResponseCallback testResponseCallback = packet.getResponseCallback();
    final IotHubEventCallback expectedCallback = mockCallback;
    assertThat(testCallback, is(expectedCallback));
    assertNull(testResponseCallback);
}
Also used : IotHubEventCallback(com.microsoft.azure.sdk.iot.device.IotHubEventCallback) HashMap(java.util.HashMap) IotHubOutboundPacket(com.microsoft.azure.sdk.iot.device.transport.IotHubOutboundPacket) IotHubResponseCallback(com.microsoft.azure.sdk.iot.device.IotHubResponseCallback) Test(org.junit.Test)

Aggregations

IotHubResponseCallback (com.microsoft.azure.sdk.iot.device.IotHubResponseCallback)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 IotHubEventCallback (com.microsoft.azure.sdk.iot.device.IotHubEventCallback)2 ResponseMessage (com.microsoft.azure.sdk.iot.device.ResponseMessage)2 IotHubCallbackPacket (com.microsoft.azure.sdk.iot.device.transport.IotHubCallbackPacket)2 IotHubOutboundPacket (com.microsoft.azure.sdk.iot.device.transport.IotHubOutboundPacket)2 IotHubStatusCode (com.microsoft.azure.sdk.iot.device.IotHubStatusCode)1 Map (java.util.Map)1