- 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>"
+ @Test
+ public void verifyThatAnEmptyProfileIsParsedWithoutError() {
+ Sone sone = soneParser.parseSone(database, originalSone, getXml("empty-profile"));
+ assertThat(sone.getProfile().getFirstName(), nullValue());
+ assertThat(sone.getProfile().getMiddleName(), nullValue());
+ assertThat(sone.getProfile().getLastName(), nullValue());
+ assertThat(sone.getProfile().getBirthYear(), nullValue());
+ assertThat(sone.getProfile().getBirthMonth(), nullValue());
+ assertThat(sone.getProfile().getBirthDay(), nullValue());
+ assertThat(sone.getProfile().getAvatar(), nullValue());
+ assertThat(sone.getProfile().getFields(), empty());
+ }
+
+ @Test
+ public void verifyThatTheCreatedSoneMeetsAllExpectations() {
+ Sone sone = soneParser.parseSone(database, originalSone, getXml("complete"));
+ assertThat(sone, notNullValue());
+ assertThat(sone.getTime(), is(1382419919000L));
+ assertThat(sone.getClient(), notNullValue());
+ assertThat(sone.getClient().getName(), is("Sone"));
+ assertThat(sone.getClient().getVersion(), is("0.8.7"));
+ assertThat(sone.getProfile(), notNullValue());
+ assertThat(sone.getProfile().getFirstName(), is("First"));
+ assertThat(sone.getProfile().getMiddleName(), is("M."));
+ assertThat(sone.getProfile().getLastName(), is("Last"));
+ assertThat(sone.getProfile().getBirthYear(), is(2013));
+ assertThat(sone.getProfile().getBirthMonth(), is(10));
+ assertThat(sone.getProfile().getBirthDay(), is(22));
+ assertThat(sone.getProfile().getAvatar(), is("96431abe-3add-11e3-8a46-67047503bf6d"));
+ assertThat(sone.getProfile().getFields(), contains(
+ fieldMatcher("Field1", "Value1"),
+ fieldMatcher("Field2", "Value2")
+ ));
+ assertThat(sone.getPosts(), contains(
+ postMatcher("d8c9586e-3adb-11e3-bb31-171fc040e645", "0rpD4gL8mszav2trndhIdKIxvKUCNAe2kjA3dLV8CVU", 1382420181000L, "Hello, User!"),
+ postMatcher("bbb7ebf0-3adb-11e3-8a0b-630cd8f21cf3", null, 1382420140000L, "Hello, World!")
+ ));
+ assertThat(sone.getReplies(), containsInAnyOrder(
+ postReplyMatcher("f09fa448-3adb-11e3-a783-ab54a11aacc4", "bbb7ebf0-3adb-11e3-8a0b-630cd8f21cf3", 1382420224000L, "Talking to myself."),
+ postReplyMatcher("0a376440-3adc-11e3-8f45-c7cc157436a5", "11ebe86e-3adc-11e3-b7b9-7f2c88018a33", 1382420271000L, "Talking to somebody I can't see.")
+ ));
+ assertThat(sone.getLikedPostIds(), containsInAnyOrder(
+ "bbb7ebf0-3adb-11e3-8a0b-630cd8f21cf3",
+ "305d85e6-3adc-11e3-be45-8b53dd91f0af"