### Question:
Rule implements Serializable { @Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append('{'); if(tag != null) { sb.append("\"tag\": \""); sb.append(escape(tag)); sb.append('"'); } if(value != null) { if(sb.length() != 0) { if(sb.length() > 1) { sb.append(", "); } } sb.append("\"value\": \""); sb.append(escape(value)); sb.append('"'); } if(id != null) { if(sb.length() != 0) { if(sb.length() > 1) { sb.append(", "); } } sb.append("\"id\": "); sb.append(id); } sb.append('}'); return sb.toString(); } Rule();  Rule(final String value, final String tag);  Rule(final String value, final String tag, final Long id); String getValue(); void setValue(final String value); String getTag(); void setTag(final String value); Long getId(); void setId(final Long id); @Override boolean equals(final java.lang.Object obj); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testFull() { final Rule r = new Rule("foo", "bar", 42L); assertEquals("{\"tag\": \"bar\", \"value\": \"foo\", \"id\": 42}", r.toString()); }
@Test public void testEmptyRule() { final Rule r = new Rule(); assertEquals("{}", r.toString()); }