### Question:
AutocryptHeader { String toRawHeaderString() { if (!parameters.isEmpty()) { throw new UnsupportedOperationException("arbitrary parameters not supported"); } StringBuilder builder = new StringBuilder(); builder.append(AutocryptHeader.AUTOCRYPT_HEADER).append(": "); builder.append(AutocryptHeader.AUTOCRYPT_PARAM_ADDR).append('=').append(addr).append("; "); if (isPreferEncryptMutual) { builder.append(AutocryptHeader.AUTOCRYPT_PARAM_PREFER_ENCRYPT) .append('=').append(AutocryptHeader.AUTOCRYPT_PREFER_ENCRYPT_MUTUAL).append("; "); } builder.append(AutocryptHeader.AUTOCRYPT_PARAM_KEY_DATA).append("="); appendBase64KeyData(builder); return builder.toString(); } AutocryptHeader(@NonNull Map<String, String> parameters, @NonNull String addr,
            @NonNull byte[] keyData, boolean isPreferEncryptMutual); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test public void toRawHeaderString_returnsExpected() throws Exception { AutocryptHeader autocryptHeader = new AutocryptHeader(PARAMETERS, ADDR, KEY_DATA, IS_PREFER_ENCRYPT_MUTUAL); String autocryptHeaderString = autocryptHeader.toRawHeaderString(); String expected = "Autocrypt: addr=addr; prefer-encrypt=mutual; keydata=dGhlc2VhcmUxMjBjaGFyYWN\r\n" + " 0ZXJzeHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh\r\n" + " 4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4"; assertEquals(expected, autocryptHeaderString); }
@Test public void toRawHeaderString_withLongAddress_returnsExpected() throws Exception { AutocryptHeader autocryptHeader = new AutocryptHeader(PARAMETERS, ADDR_LONG, KEY_DATA, IS_PREFER_ENCRYPT_MUTUAL); String autocryptHeaderString = autocryptHeader.toRawHeaderString(); String expected = "Autocrypt: addr=veryveryverylongaddressthatspansmorethanalinelengthintheheader; prefer-encrypt=mutual; keydata=\r\n" + " dGhlc2VhcmUxMjBjaGFyYWN0ZXJzeHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4\r\n" + " eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4\r\n" + " eHh4eHh4"; assertEquals(expected, autocryptHeaderString); }
@Test public void toRawHeaderString_withShortData_returnsExpected() throws Exception { AutocryptHeader autocryptHeader = new AutocryptHeader(PARAMETERS, ADDR, KEY_DATA_SHORT, IS_PREFER_ENCRYPT_MUTUAL); String autocryptHeaderString = autocryptHeader.toRawHeaderString(); String expected = "Autocrypt: addr=addr; prefer-encrypt=mutual; keydata=dGhlc2VhcmUxNWNoYXJz"; assertEquals(expected, autocryptHeaderString); }