TrustedAuthoritySerializer extends Serializer<TrustedAuthority> { @Override protected byte[] serializeBytes() { if (trustedAuthority.getIdentifierType() != null && trustedAuthority.getIdentifierType().getValue() != null) { appendByte(trustedAuthority.getIdentifierType().getValue()); } if (trustedAuthority.getSha1Hash() != null && trustedAuthority.getSha1Hash().getValue() != null) { appendBytes(trustedAuthority.getSha1Hash().getValue()); } if (trustedAuthority.getDistinguishedNameLength() != null && trustedAuthority.getDistinguishedNameLength().getValue() != null) { appendInt(trustedAuthority.getDistinguishedNameLength().getValue(), ExtensionByteLength.TRUSTED_AUTHORITY_DISTINGUISHED_NAME_LENGTH); } if (trustedAuthority.getDistinguishedName() != null && trustedAuthority.getDistinguishedName().getValue() != null) { appendBytes(trustedAuthority.getDistinguishedName().getValue()); } return getAlreadySerialized(); } TrustedAuthoritySerializer(TrustedAuthority trustedAuthority);   }
@Test public void testSerializeBytes() { authority = new TrustedAuthority(identifier.getValue(), hash, distNameLength, distName); TrustedAuthorityPreparator preparator = new TrustedAuthorityPreparator(new TlsContext().getChooser(), authority); preparator.prepare(); serializer = new TrustedAuthoritySerializer(authority); assertArrayEquals(parserBytes, serializer.serialize()); }