Search in sources :

Example 26 with VCardAsserter

use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.

the class SampleVCardsTest method gmailList.

@Test
public void gmailList() throws Throwable {
    VCardAsserter asserter = read("gmail-list.vcf");
    {
        asserter.next(V3_0);
        // @formatter:off
        asserter.simpleProperty(FormattedName.class).value("Arnold Smith").noMore();
        asserter.structuredName().family("Smith").given("Arnold").noMore();
        asserter.email().types(EmailType.INTERNET).value("asmithk@gmail.com").noMore();
        // @formatter:on
        asserter.validate().run();
    }
    {
        asserter.next(V3_0);
        // @formatter:off
        asserter.simpleProperty(FormattedName.class).value("Chris Beatle").noMore();
        asserter.structuredName().family("Beatle").given("Chris").noMore();
        asserter.email().types(EmailType.INTERNET).value("chrisy55d@yahoo.com").noMore();
        // @formatter:on
        asserter.validate().run();
    }
    {
        asserter.next(V3_0);
        // @formatter:off
        asserter.simpleProperty(FormattedName.class).value("Doug White").noMore();
        asserter.structuredName().family("White").given("Doug").noMore();
        asserter.email().types(EmailType.INTERNET).value("dwhite@gmail.com").noMore();
        // @formatter:on
        asserter.validate().run();
    }
    asserter.done();
}
Also used : FormattedName(ezvcard.property.FormattedName) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 27 with VCardAsserter

use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.

the class SampleVCardsTest method rfc6350_example.

@Test
public void rfc6350_example() throws Throwable {
    VCardAsserter asserter = read("rfc6350-example.vcf");
    asserter.next(V4_0);
    // @formatter:off
    asserter.simpleProperty(FormattedName.class).value("Simon Perreault").noMore();
    asserter.structuredName().family("Perreault").given("Simon").suffixes("ing. jr", "M.Sc.").noMore();
    asserter.dateProperty(Birthday.class).partialDate(PartialDate.builder().month(2).date(3).build()).noMore();
    asserter.dateProperty(Anniversary.class).partialDate(PartialDate.builder().year(2009).month(8).date(8).hour(14).minute(30).offset(new UtcOffset(false, -5, 0)).build()).noMore();
    asserter.property(Gender.class).expected(Gender.male()).noMore();
    asserter.simpleProperty(Language.class).value("fr").param("PREF", "1").next().value("en").param("PREF", "2").noMore();
    asserter.listProperty(Organization.class).param("TYPE", "work").values("Viagenie").noMore();
    asserter.address().extendedAddress("Suite D2-630").streetAddress("2875 Laurier").locality("Quebec").region("QC").postalCode("G1V 2M2").country("Canada").types(AddressType.WORK).noMore();
    asserter.telephone().types(TelephoneType.WORK, TelephoneType.VOICE).uri(new TelUri.Builder("+1-418-656-9254").extension("102").build()).param("PREF", "1").next().types(TelephoneType.WORK, TelephoneType.CELL, TelephoneType.VOICE, TelephoneType.VIDEO, TelephoneType.TEXT).uri(new TelUri.Builder("+1-418-262-6501").build()).noMore();
    asserter.email().types(EmailType.WORK).value("simon.perreault@viagenie.ca").noMore();
    asserter.geo().latitude(46.772673).longitude(-71.282945).param("TYPE", "work").noMore();
    asserter.binaryProperty(Key.class).url("http://www.viagenie.ca/simon.perreault/simon.asc").param("TYPE", "work").noMore();
    asserter.timezone().offset(new UtcOffset(false, -5, 0)).noMore();
    asserter.simpleProperty(Url.class).value("http://nomis80.org").param("TYPE", "home").noMore();
    // @formatter:on
    asserter.validate().run();
    asserter.done();
}
Also used : UtcOffset(ezvcard.util.UtcOffset) Organization(ezvcard.property.Organization) TelUri(ezvcard.util.TelUri) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Key(ezvcard.property.Key) FreeBusyUrl(ezvcard.property.FreeBusyUrl) Url(ezvcard.property.Url) Test(org.junit.Test)

Example 28 with VCardAsserter

use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.

the class VCardReaderTest method invalid_line.

@Test
public void invalid_line() throws Exception {
    for (VCardVersion version : VCardVersion.values()) {
        // @formatter:off
        VCardAsserter asserter = read("BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "bad-line\r\n" + "END:VCARD\r\n");
        // @formatter:on
        asserter.next(version);
        asserter.warnings(27);
        asserter.done();
    }
}
Also used : VCardVersion(ezvcard.VCardVersion) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 29 with VCardAsserter

use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.

the class VCardReaderTest method warnings_list_cleared.

@Test
public void warnings_list_cleared() throws Exception {
    for (VCardVersion version : VCardVersion.values()) {
        // @formatter:off
        VCardAsserter asserter = read("BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "bad-line\r\n" + "END:VCARD\r\n" + "BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "END:VCARD\r\n");
        // @formatter:on
        asserter.next(version);
        asserter.warnings(27);
        asserter.next(version);
        asserter.done();
    }
}
Also used : VCardVersion(ezvcard.VCardVersion) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 30 with VCardAsserter

use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.

the class VCardReaderTest method skip_non_vcard_components.

@Test
public void skip_non_vcard_components() throws Exception {
    for (VCardVersion version : VCardVersion.values()) {
        // @formatter:off
        VCardAsserter asserter = read("BEGIN:VCALENDAR\r\n" + "VERSION:2.0\r\n" + "invalid line--warning should not be logged\r\n" + "PRODID:-//Company//Application//EN\r\n" + "END:VCALENDAR\r\n" + "invalid line--warning should not be logged\r\n" + "BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "FN:John Doe\r\n" + "END:VCARD\r\n");
        asserter.next(version);
        asserter.simpleProperty(FormattedName.class).value("John Doe").noMore();
        asserter.done();
    // @formatter:on
    }
}
Also used : VCardVersion(ezvcard.VCardVersion) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Aggregations

VCardAsserter (ezvcard.property.asserter.VCardAsserter)86 Test (org.junit.Test)84 Url (ezvcard.property.Url)12 VCard (ezvcard.VCard)10 VCardVersion (ezvcard.VCardVersion)10 FreeBusyUrl (ezvcard.property.FreeBusyUrl)9 Note (ezvcard.property.Note)7 Organization (ezvcard.property.Organization)7 Photo (ezvcard.property.Photo)7 FormattedName (ezvcard.property.FormattedName)6 Key (ezvcard.property.Key)6 UtcOffset (ezvcard.util.UtcOffset)5 CannotParseScribe (ezvcard.io.scribe.CannotParseScribe)4 SkipMeScribe (ezvcard.io.scribe.SkipMeScribe)4 TelUri (ezvcard.util.TelUri)4 Label (ezvcard.property.Label)3 StreamReader (ezvcard.io.StreamReader)2 Categories (ezvcard.property.Categories)2 Utf8Writer (ezvcard.util.Utf8Writer)2 File (java.io.File)2