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);
}
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)));
}
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);
}
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);
}
Aggregations