Verify that an invalid album causes an error.
[Sone.git] / src / test / java / net / pterodactylus / sone / core / SoneParserTest.java
index 27b61b0..87f6600 100644 (file)
@@ -20,6 +20,7 @@ import java.util.logging.Logger;
 import net.pterodactylus.sone.core.SoneParser.DuplicateField;
 import net.pterodactylus.sone.core.SoneParser.InvalidProtocolVersion;
 import net.pterodactylus.sone.core.SoneParser.InvalidXml;
+import net.pterodactylus.sone.core.SoneParser.MalformedTime;
 import net.pterodactylus.sone.core.SoneParser.MalformedXml;
 import net.pterodactylus.sone.data.Client;
 import net.pterodactylus.sone.data.Image;
@@ -110,6 +111,56 @@ public class SoneParserTest {
        }
 
        @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
        public void verifyThatAnEmptyProfileIsParsedWithoutError() {
                Sone sone = soneParser.parseSone(database, originalSone, getXml("empty-profile"));
                assertThat(sone.getProfile().getFirstName(), nullValue());