### Question:
SearchResultEntryProtocolOp extends ProtocolOp { @Override public void toString(StringBuilder buffer) { buffer.append("SearchResultEntry(dn="); dn.toString(buffer); buffer.append(", attrs={"); LinkedList<LDAPAttribute> tmp = getAttributes(); if (! tmp.isEmpty()) { Iterator<LDAPAttribute> iterator = tmp.iterator(); iterator.next().toString(buffer); while (iterator.hasNext()) { buffer.append(", "); iterator.next().toString(buffer); } } buffer.append("})"); } SearchResultEntryProtocolOp(DN dn);  SearchResultEntryProtocolOp(DN dn,
                                     LinkedList<LDAPAttribute> attributes);  SearchResultEntryProtocolOp(SearchResultEntry searchEntry);  SearchResultEntryProtocolOp(SearchResultEntry searchEntry,
          int ldapVersion); private  SearchResultEntryProtocolOp(DN dn,
      LinkedList<LDAPAttribute> attributes, SearchResultEntry searchEntry,
      int ldapVersion); DN getDN(); LinkedList<LDAPAttribute> getAttributes(); @Override byte getType(); @Override String getProtocolOpName(); @Override void write(ASN1Writer stream); @Override void toString(StringBuilder buffer); @Override void toString(StringBuilder buffer, int indent); void toLDIF(StringBuilder buffer, int wrapColumn); SearchResultEntry toSearchResultEntry();  }### Answer:
@Test(dataProvider = "entries") public void testToString(Entry entry) throws Exception { SearchResultEntryProtocolOp protocolOp = new SearchResultEntryProtocolOp(new SearchResultEntry(entry)); StringBuilder sb = new StringBuilder(); protocolOp.toString(); protocolOp.toString(sb, 1); }
@Test (dataProvider = "entries", expectedExceptions = LDAPException.class) public void testInvalidElement1(Entry entry) throws Exception { ByteStringBuilder builder = new ByteStringBuilder(); ASN1Writer writer = ASN1.getWriter(builder); writer.writeStartSequence(OP_TYPE_SEARCH_RESULT_ENTRY); writer.writeOctetString(entry.getName().toString()); writer.writeOctetString("cn"); writer.writeEndSequence(); ASN1Reader reader = ASN1.getReader(builder.toByteString()); LDAPReader.readProtocolOp(reader); }