FragmentCollector { public DtlsHandshakeMessageFragment buildCombinedFragment() { if (!isMessageComplete()) { LOGGER.warn("Returning incompletely received message! Missing pieces are ignored in the content."); } DtlsHandshakeMessageFragment message = new DtlsHandshakeMessageFragment(); message.setType(type); message.setLength(messageLength); message.setMessageSeq(messageSeq); message.setFragmentOffset(0); message.setFragmentLength(messageLength); message.setContent(getCombinedContent()); DtlsHandshakeMessageFragmentSerializer serializer = new DtlsHandshakeMessageFragmentSerializer(message, null); message.setCompleteResultingMessage(serializer.serialize()); this.setInterpreted(interpreted); return message; } FragmentCollector(Config config, Byte type, int messageSeq, int messageLength); void addFragment(DtlsHandshakeMessageFragment fragment); boolean wouldAdd(DtlsHandshakeMessageFragment fragment); boolean isFitting(DtlsHandshakeMessageFragment fragment); boolean isFragmentOverwritingContent(DtlsHandshakeMessageFragment fragment); DtlsHandshakeMessageFragment buildCombinedFragment(); boolean isMessageComplete(); boolean isInterpreted(); void setInterpreted(boolean interpreted);  }
@Test public void testbuildCombinedFragment() { byte[] original = ArrayConverter.hexStringToByteArray("123456789A123456789A"); collector.addFragment(fragmentOfMsg(0, 0, 3, original, 0)); collector.addFragment(fragmentOfMsg(0, 3, 5, original, 0)); collector.addFragment(fragmentOfMsg(0, 8, 2, original, 0)); DtlsHandshakeMessageFragment fragment = collector.buildCombinedFragment(); checkFragment(fragment, 0, 10, original); }