### Question:
ModifyRequestProtocolOp extends ProtocolOp { @Override public void toString(StringBuilder buffer) { buffer.append("ModifyRequest(dn=").append(dn); buffer.append(", mods={"); if (! modifications.isEmpty()) { Iterator<RawModification> iterator = modifications.iterator(); iterator.next().toString(buffer); while (iterator.hasNext()) { buffer.append(", "); iterator.next().toString(buffer); } } buffer.append("})"); } ModifyRequestProtocolOp(ByteString dn);  ModifyRequestProtocolOp(ByteString dn,
      List<RawModification> modifications); ByteString getDN(); List<RawModification> getModifications(); @Override byte getType(); @Override String getProtocolOpName(); @Override void write(ASN1Writer stream); @Override void toString(StringBuilder buffer); @Override void toString(StringBuilder buffer, int indent);  }### Answer:
@Test public void TestToStringSingleLine() throws Exception { StringBuilder buffer = new StringBuilder(); StringBuilder key = new StringBuilder(); int numModifications = 10; List<RawModification> modifications = generateModifications(numModifications, "test"); ModifyRequestProtocolOp modifyRequest = new ModifyRequestProtocolOp(dn, modifications); modifyRequest.toString(buffer); key.append("ModifyRequest(dn=").append(dn).append(", mods={"); for (int i = 0; i < numModifications; i++) { modifications.get(i).toString(key); if(i < numModifications - 1) { key.append(", "); } } key.append("})"); assertEquals(buffer.toString(), key.toString()); }
@Test public void TestToStringMultiLine() throws Exception { StringBuilder buffer = new StringBuilder(); StringBuilder key = new StringBuilder(); int numModifications = 10; int indent = 5; List<RawModification> modifications = generateModifications(numModifications, "test"); ModifyRequestProtocolOp modifyRequest = new ModifyRequestProtocolOp(dn, modifications); modifyRequest.toString(buffer, indent); StringBuilder indentBuf = new StringBuilder(indent); for (int i = 0; i < indent; i++) { indentBuf.append(' '); } key.append(indentBuf); key.append("Modify Request"); key.append(EOL); key.append(indentBuf); key.append(" DN: "); key.append(dn); key.append(EOL); key.append(" Modifications:"); key.append(EOL); for (RawModification modify : modifications) { modify.toString(key, indent+4); } assertEquals(buffer.toString(), key.toString()); }