FragmentCollector { public void addFragment(DtlsHandshakeMessageFragment fragment) { if (wouldAdd(fragment)) { if (isFragmentOverwritingContent(fragment)) { LOGGER.warn("Found a fragment which tries to rewrite history. Setting interpreted to false and resetting Stream."); fragmentStream = new FragmentStream(messageLength); this.messageLength = fragment.getLength().getValue(); this.messageSeq = fragment.getMessageSeq().getValue(); this.type = fragment.getType().getValue(); interpreted = false; } fragmentStream.insertByteArray(fragment.getContent().getValue(), fragment.getFragmentOffset().getValue()); } else { throw new IllegalDtlsFragmentException("Tried to insert an illegal DTLS fragment."); } } 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 testAddTrue() { collector.addFragment(fragment(0, 0, 10, 0)); }