package com.fsck.k9.ical;


import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.internet.MimeBodyPart;
import com.fsck.k9.mail.internet.TextBody;
import org.junit.Test;

import static org.junit.Assert.assertEquals;


public class ICalParserTest {

    @Test
    public void parse_returnsCorrectDataForMinimalPublishEvent() throws MessagingException {
        String calendar =
"BEGIN:VCALENDAR\r\n" +
"METHOD:PUBLISH\r\n" +
"PRODID:-//ACME/DesktopCalendar//EN\r\n" +
"VERSION:2.0\r\n" +
"BEGIN:VEVENT\r\n" +
"ORGANIZER:mailto:a@example.com\r\n" +
"DTSTART:19970701T200000Z\r\n" +
"DTSTAMP:19970611T190000Z\r\n" +
"SUMMARY:ST. PAUL SAINTS -VS- DULUTH-SUPERIOR DUKES\r\n" +
"UID:0981234-1234234-23@example.com\r\n" +
"END:VEVENT\r\n" +
"END:VCALENDAR";
        Body body = new TextBody(calendar);
        MimeBodyPart dataPart = new MimeBodyPart(body);
        ICalPart part = new ICalPart(dataPart);
        ICalData data = ICalParser.parse(part);

        assertEquals(1, data.getCalendarData().size());
        assertEquals("PUBLISH", data.getCalendarData().get(0).getMethod().getValue());
        assertEquals("a@example.com", data.getCalendarData().get(0).getOrganizer().getEmail());
    }
}

@@ -287,16 +287,268 @@
 Test %7B%0A%0A
+    @Test%0A    public void parse_withNoText_returnsDataWithNoEvents() throws MessagingException %7B%0A        ICalPart part = new ICalPart(null);%0A        ICalData data = ICalParser.parse(part);%0A        assertEquals(0, data.getCalendarData().size());%0A    %7D%0A%0A
     @Tes

Check data is empty when part has no body