use of com.microsoft.azure.sdk.iot.device.transport.IotHubTransportPacket in project azure-iot-sdk-java by Azure.
the class IotHubTransportPacketTest method getCallbackReturnsCallback.
// Tests_SRS_IOTHUBTRANSPORTPACKET_11_001: [The constructor shall save the message, callback, status, startTimeMillis, and callback context.]
// Tests_SRS_IOTHUBTRANSPORTPACKET_11_003: [The function shall return the event callback given in the constructor.]
@Test
public void getCallbackReturnsCallback() {
// arrange
final Map<String, Object> context = new HashMap<>();
IotHubStatusCode expectedStatus = IotHubStatusCode.MESSAGE_CANCELLED_ONCLOSE;
// act
IotHubTransportPacket packet = new IotHubTransportPacket(mockMsg, mockCallback, context, expectedStatus, 10, null);
IotHubEventCallback testCallback = packet.getCallback();
// assert
final IotHubEventCallback expectedCallback = mockCallback;
assertThat(testCallback, is(expectedCallback));
assertEquals(expectedStatus, packet.getStatus());
}
use of com.microsoft.azure.sdk.iot.device.transport.IotHubTransportPacket in project azure-iot-sdk-java by Azure.
the class IotHubTransportPacketTest method getMessageReturnsMessage.
// Tests_SRS_IOTHUBTRANSPORTPACKET_11_001: [The constructor shall save the message, callback, status, startTimeMillis, and callback context.]
// Tests_SRS_IOTHUBTRANSPORTPACKET_11_002: [The function shall return the message given in the constructor.]
@Test
public void getMessageReturnsMessage() {
// arrange
final Map<String, Object> context = new HashMap<>();
// act
IotHubTransportPacket packet = new IotHubTransportPacket(mockMsg, mockCallback, context, IotHubStatusCode.OK_EMPTY, 10, null);
Message testMsg = packet.getMessage();
// assert
final Message expectedMsg = mockMsg;
assertThat(testMsg, is(expectedMsg));
}
use of com.microsoft.azure.sdk.iot.device.transport.IotHubTransportPacket in project azure-iot-sdk-java by Azure.
the class IotHubTransportPacketTest method getStartTimeMillisReturnsStartTime.
// Tests_SRS_IOTHUBTRANSPORTPACKET_11_001: [The constructor shall save the message, callback, status, startTimeMillis, and callback context.]
// Tests_SRS_IOTHUBTRANSPORTPACKET_34_007: [This function shall return the saved startTimeMillis.]
@Test
public void getStartTimeMillisReturnsStartTime() {
// arrange
long expectedStartTime = 1230;
// act
IotHubTransportPacket packet = new IotHubTransportPacket(mockMsg, mockCallback, new Object(), IotHubStatusCode.OK_EMPTY, expectedStartTime, null);
long actualStartTime = packet.getStartTimeMillis();
// assert
assertEquals(expectedStartTime, actualStartTime);
}
Aggregations