- private static class SoneXmlBuilder {
-
- private Optional<Long> time = of(1000L);
- private Optional<String> protocolVersion = of("0");
- private Optional<String> clientInformation = of("<name>Test-Client</name><version>1.0</version>");
- private Optional<String> profile = of(Joiner.on("").join(
- "<first-name>First</first-name>",
- "<middle-name>M.</middle-name>",
- "<last-name>Last</last-name>",
- "<birth-year>2000</birth-year>",
- "<birth-month>9</birth-month>",
- "<birth-day>13</birth-day>",
- "<avatar>avatar-id</avatar>",
- "<fields>",
- "<field><field-name>Custom Field</field-name><field-value>Custom Value</field-value></field>",
- "</fields>"
- ));
- private Optional<String> posts = of("<post><id>post-id</id><time>1</time><recipient>recipient</recipient><text>Hello!</text></post>");
- private Optional<String> replies = of("<reply><id>reply-id</id><post-id>post-id</post-id><time>2</time><text>Reply!</text></reply>");
-
- public SoneXmlBuilder removeTime() {
- time = absent();
- return this;
- }
-
- public SoneXmlBuilder setProtocolVersion(String protocolVersion) {
- this.protocolVersion = fromNullable(protocolVersion);
- return this;
- }
-
- public SoneXmlBuilder removeProtocolVersion() {
- this.protocolVersion = absent();
- return this;
- }
-
- public SoneXmlBuilder setClientInformation(String name, String version) {
- clientInformation = of("<name>" + name + "</name><version>" + version + "</version>");
- return this;
- }
-
- public SoneXmlBuilder removeClientInformation() {
- clientInformation = absent();
- return this;
- }
-
- public SoneXmlBuilder removeProfile() {
- profile = absent();
- return this;
- }
-
- public SoneXmlBuilder removePost() {
- posts = absent();
- return this;
- }
-
- public SoneXmlBuilder removeReply() {
- replies = absent();
- return this;
- }
-
- public InputStream get() {
- StringBuilder content = new StringBuilder();
- content.append("<sone>");
- if (time.isPresent()) {
- content.append(createXmlElement("time", String.valueOf(time.get())));
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("PostReply(")
+ .appendValue(id).appendText(", ")
+ .appendValue(postId).appendText(", ")
+ .appendValue(time).appendText(", ")
+ .appendValue(text).appendText(")");