### Question:
SearchResultEntryProtocolOp extends ProtocolOp { public void toLDIF(StringBuilder buffer, int wrapColumn) { String dnString = dn.toString(); int colsRemaining; if (needsBase64Encoding(dnString)) { dnString = Base64.encode(getBytes(dnString)); buffer.append("dn:: "); colsRemaining = wrapColumn - 5; } else { buffer.append("dn: "); colsRemaining = wrapColumn - 4; } int dnLength = dnString.length(); if (dnLength <= colsRemaining || colsRemaining <= 0) { buffer.append(dnString); buffer.append(EOL); } else { buffer.append(dnString, 0, colsRemaining); buffer.append(EOL); int startPos = colsRemaining; while (dnLength - startPos > wrapColumn - 1) { buffer.append(" "); buffer.append(dnString, startPos, startPos+wrapColumn-1); buffer.append(EOL); startPos += wrapColumn-1; } if (startPos < dnLength) { buffer.append(" "); buffer.append(dnString.substring(startPos)); buffer.append(EOL); } } for (LDAPAttribute a : getAttributes()) { String name = a.getAttributeType(); int nameLength = name.length(); for (ByteString v : a.getValues()) { String valueString; if (needsBase64Encoding(v)) { valueString = Base64.encode(v); buffer.append(name); buffer.append(":: "); colsRemaining = wrapColumn - nameLength - 3; } else { valueString = v.toString(); buffer.append(name); buffer.append(": "); colsRemaining = wrapColumn - nameLength - 2; } int valueLength = valueString.length(); if (valueLength <= colsRemaining || colsRemaining <= 0) { buffer.append(valueString); buffer.append(EOL); } else { buffer.append(valueString, 0, colsRemaining); buffer.append(EOL); int startPos = colsRemaining; while (valueLength - startPos > wrapColumn - 1) { buffer.append(" "); buffer.append(valueString, startPos, startPos+wrapColumn-1); buffer.append(EOL); startPos += wrapColumn-1; } if (startPos < valueLength) { buffer.append(" "); buffer.append(valueString.substring(startPos)); buffer.append(EOL); } } } } buffer.append(EOL); } 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 testToLdif(Entry from) throws Exception { int wrapColumn = 80; SearchResultEntryProtocolOp protocolOp = new SearchResultEntryProtocolOp(new SearchResultEntry(from)); StringBuilder builder = new StringBuilder(); protocolOp.toLDIF(builder, wrapColumn); Entry to = TestCaseUtils.entryFromLdifString(builder.toString()); }