### Question:
DEREncoder implements ASN1Encoder { @Override public void writeEncoded(byte[] encoded) { EncoderState lastState = states.peekLast(); if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { updateCurrentBuffer(); lastState.addChildElement(encoded[0], currentBufferPos); } if (implicitTag != -1) { writeTag(encoded[0], currentBuffer); currentBuffer.append(encoded, 1, encoded.length - 1); } else { currentBuffer.append(encoded); } if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { lastState.addChildLength(currentBuffer.length()); } } DEREncoder();   DEREncoder(ByteStringBuilder target); @Override void startSequence(); @Override void startSet(); @Override void startSetOf(); @Override void startExplicit(int number); @Override void startExplicit(int clazz, int number); @Override void endSequence(); @Override void endExplicit(); @Override void endSet(); @Override void endSetOf(); @Override void encodeOctetString(String str); @Override void encodeOctetString(byte[] str); @Override void encodeIA5String(String str); @Override void encodeIA5String(byte[] str); @Override void encodePrintableString(final byte[] str); @Override void encodePrintableString(final String str); @Override void encodeUTF8String(final String str); @Override void encodeBMPString(final String str); @Override void encodeUniversalString(final String str); @Override void encodeBitString(byte[] str); @Override void encodeBitString(byte[] str, int numUnusedBits); @Override void encodeBitString(final EnumSet<?> enumSet); @Override void encodeBitString(final BitSet bitSet); @Override void encodeBitString(String binaryStr); @Override void encodeBitString(BigInteger integer); @Override void encodeGeneralizedTime(final ZonedDateTime time); @Override void encodeObjectIdentifier(String objectIdentifier); @Override void encodeNull(); @Override void encodeImplicit(int number); @Override void encodeImplicit(int clazz, int number); @Override void encodeBoolean(final boolean value); @Override void encodeInteger(BigInteger integer); @Override void writeEncoded(byte[] encoded); @Override void flush(); @Override byte[] getEncoded();  }### Answer:
@Test public void testWriteEncoded() throws Exception { DEREncoder encoder = new DEREncoder(); encoder.startSet(); encoder.encodeNull(); encoder.writeEncoded(new byte[] {4, 8, 1, 35, 69, 103, -119, -85, -51, -17}); encoder.encodeObjectIdentifier("1.2.45684.5447897894"); encoder.encodeOctetString(new byte[] {1, 35, 69}); encoder.endSet(); byte[] expected = new byte[] {49, 28, 4, 8, 1, 35, 69, 103, -119, -85, -51, -17, 4, 3, 1, 35, 69, 5, 0, 6, 9, 42, -126, -28, 116, -108, -91, -31, -90, 38}; assertArrayEquals(expected, encoder.getEncoded()); }