+ assertThat(sone.getClient(), notNullValue());
+ assertThat(sone.getClient(), is(originalSone.getClient()));
+ }
+
+ @Test(expected = MalformedXml.class)
+ public void verifyThatAMissingProfileCausesAnError() {
+ soneParser.parseSone(database, originalSone, getXml("missing-profile"));
+ }
+
+ @Test(expected = MalformedXml.class)
+ public void verifyThatInvalidFieldsCauseAnError() {
+ soneParser.parseSone(database, originalSone, getXml("invalid-field"));
+ }
+
+ @Test(expected = DuplicateField.class)
+ public void verifyThatDuplicateFieldsCauseAnError() {
+ soneParser.parseSone(database, originalSone, getXml("duplicate-field"));
+ }
+
+ @Test(expected = InvalidAvatarId.class)
+ public void verifyThatAnInvalidAvatarIdCausesAnError() {
+ soneParser.parseSone(database, originalSone, getXml("invalid-avatar"));
+ }
+
+ @Test
+ public void verifyThatMissingPostsDoNotCauseAnError() {
+ soneParser.parseSone(database, originalSone, getXml("missing-posts"));
+ }
+
+ @Test(expected = MalformedXml.class)
+ public void verifyThatInvalidPostsCauseAnError() {
+ soneParser.parseSone(database, originalSone, getXml("invalid-posts"));
+ }
+
+ @Test(expected = MalformedTime.class)
+ public void verifyThatAMalformedTimeCausesAnError() {
+ soneParser.parseSone(database, originalSone, getXml("invalid-post-time"));
+ }
+
+ @Test
+ public void verifyThatMissingRepliesDoNotCauseAnError() {
+ soneParser.parseSone(database, originalSone, getXml("missing-replies"));
+ }
+
+ @Test(expected = MalformedXml.class)
+ public void verifyThatInvalidRepliesCauseAnError() {
+ soneParser.parseSone(database, originalSone, getXml("invalid-replies"));
+ }
+
+ @Test(expected = MalformedTime.class)
+ public void verifyThatAMalformedReplyTimeCausesAnError() {
+ soneParser.parseSone(database, originalSone, getXml("invalid-reply-time"));
+ }
+
+ @Test
+ public void verifyThatAMissingPostLikesSectionDoesNotCauseAnError() {
+ soneParser.parseSone(database, originalSone, getXml("missing-post-likes"));
+ }
+
+ @Test
+ public void verifyThatAMissingReplyLikesSectionDoesNotCauseAnError() {
+ soneParser.parseSone(database, originalSone, getXml("missing-reply-likes"));
+ }
+
+ @Test
+ public void verifyThatMissingAlbumsSectionDoNotCauseAnError() {
+ soneParser.parseSone(database, originalSone, getXml("missing-albums"));
+ }
+
+ @Test(expected = MalformedXml.class)
+ public void verifyThatAnInvalidAlbumCausesAnError() {
+ soneParser.parseSone(database, originalSone, getXml("invalid-album"));
+ }
+
+ @Test(expected = InvalidParentAlbum.class)
+ public void verifyThatAnInvalidParentAlbumCausesAnError() {
+ soneParser.parseSone(database, originalSone, getXml("invalid-parent-album"));
+ }
+
+ @Test(expected = MalformedXml.class)
+ public void verifyThatAnInvalidImageCausesAnError() {
+ soneParser.parseSone(database, originalSone, getXml("invalid-image"));
+ }
+
+ @Test(expected = MalformedDimension.class)
+ public void verifyThatInvalidImageDimensionsCauseAnError() {
+ soneParser.parseSone(database, originalSone, getXml("invalid-image-dimensions"));
+ }
+
+ @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());