WorkflowTraceUtil { public static HandshakeMessage getLastReceivedMessage(HandshakeMessageType type, WorkflowTrace trace) { List<ProtocolMessage> messageList = getAllReceivedMessages(trace); List<HandshakeMessage> handshakeMessageList = filterHandshakeMessagesFromList(messageList); handshakeMessageList = filterMessageList(handshakeMessageList, type); if (handshakeMessageList.isEmpty()) { return null; } else { return handshakeMessageList.get(handshakeMessageList.size() - 1); } } private  WorkflowTraceUtil(); static ProtocolMessage getFirstReceivedMessage(ProtocolMessageType type, WorkflowTrace trace); static HandshakeMessage getFirstReceivedMessage(HandshakeMessageType type, WorkflowTrace trace); static HandshakeMessage getLastReceivedMessage(HandshakeMessageType type, WorkflowTrace trace); static ProtocolMessage getLastReceivedMessage(ProtocolMessageType type, WorkflowTrace trace); static AbstractRecord getLastReceivedRecord(WorkflowTrace trace); static ProtocolMessage getFirstSendMessage(ProtocolMessageType type, WorkflowTrace trace); static ExtensionMessage getFirstSendExtension(ExtensionType type, WorkflowTrace trace); static List<HandshakeMessage> getAllSendHandshakeMessages(WorkflowTrace trace); static List<HandshakeMessage> getAllReceivedHandshakeMessages(WorkflowTrace trace); static List<ExtensionMessage> getAllSendExtensions(WorkflowTrace trace); static List<ExtensionMessage> getAllReceivedExtensions(WorkflowTrace trace); static HandshakeMessage getFirstSendMessage(HandshakeMessageType type, WorkflowTrace trace); static HandshakeMessage getLastSendMessage(HandshakeMessageType type, WorkflowTrace trace); static ProtocolMessage getLastSendMessage(ProtocolMessageType type, WorkflowTrace trace); static boolean didReceiveMessage(ProtocolMessageType type, WorkflowTrace trace); static boolean didReceiveMessage(HandshakeMessageType type, WorkflowTrace trace); static boolean didSendMessage(ProtocolMessageType type, WorkflowTrace trace); static boolean didSendMessage(HandshakeMessageType type, WorkflowTrace trace); static ProtocolMessage getLastReceivedMessage(WorkflowTrace trace); static List<HandshakeMessage> filterHandshakeMessagesFromList(List<ProtocolMessage> messages); static List<ProtocolMessage> getAllReceivedMessages(WorkflowTrace trace); static List<ProtocolMessage> getAllReceivedMessages(WorkflowTrace trace, ProtocolMessageType type); static List<ProtocolMessage> getAllSendMessages(WorkflowTrace trace); static Boolean didReceiveTypeBeforeType(ProtocolMessageType protocolMessageType, HandshakeMessageType type,
            WorkflowTrace trace); static List<AbstractRecord> getAllReceivedRecords(WorkflowTrace trace); static List<AbstractRecord> getAllSendRecords(WorkflowTrace trace); static SendingAction getLastSendingAction(WorkflowTrace trace);  }
@Test public void testGetLastReceivedMessage() { assertNull(WorkflowTraceUtil.getLastReceivedMessage(ProtocolMessageType.HEARTBEAT, trace)); trace.addTlsAction(rcvMultipleProtocolMessages); assertNotSame(rcvMultipleProtocolMessages.getMessages().get(0), WorkflowTraceUtil.getLastReceivedMessage(ProtocolMessageType.HEARTBEAT, trace)); assertNotSame(rcvMultipleProtocolMessages.getMessages().get(1), WorkflowTraceUtil.getLastReceivedMessage(ProtocolMessageType.HEARTBEAT, trace)); assertSame(rcvMultipleProtocolMessages.getMessages().get(2), WorkflowTraceUtil.getLastReceivedMessage(ProtocolMessageType.HEARTBEAT, trace)); assertNull(WorkflowTraceUtil.getLastReceivedMessage(HandshakeMessageType.SERVER_HELLO, trace)); trace.addTlsAction(rcvMultipleHandshakeMessages); assertNotSame(rcvMultipleHandshakeMessages.getMessages().get(0), WorkflowTraceUtil.getLastReceivedMessage(HandshakeMessageType.SERVER_HELLO, trace)); assertNotSame(rcvMultipleHandshakeMessages.getMessages().get(1), WorkflowTraceUtil.getLastReceivedMessage(HandshakeMessageType.SERVER_HELLO, trace)); assertSame(rcvMultipleHandshakeMessages.getMessages().get(2), WorkflowTraceUtil.getLastReceivedMessage(HandshakeMessageType.SERVER_HELLO, trace)); }