Search in sources :

Example 51 with VCardAsserter

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

the class SampleVCardsTest method outlook2007VCard.

@Test
public void outlook2007VCard() throws Throwable {
    VCardAsserter asserter = read("outlook-2007.vcf");
    asserter.next(V2_1);
    // @formatter:off
    asserter.structuredName().family("Angstadt").given("Michael").prefixes("Mr.").suffixes("Jr.").param(VCardParameters.LANGUAGE, "en-us").noMore();
    asserter.simpleProperty(FormattedName.class).value("Mr. Michael Angstadt Jr.").noMore();
    asserter.listProperty(Nickname.class).values("Mike").noMore();
    asserter.listProperty(Organization.class).values("TheCompany", "TheDepartment").noMore();
    asserter.simpleProperty(Title.class).value("TheJobTitle").noMore();
    asserter.simpleProperty(Note.class).value("This is the NOTE field	\r\nI assume it encodes this text inside a NOTE vCard type.\r\nBut I'm not sure because there's text formatting going on here.\r\nIt does not preserve the formatting").param("ENCODING", "QUOTED-PRINTABLE").param("CHARSET", "us-ascii").noMore();
    asserter.telephone().types(TelephoneType.WORK, TelephoneType.VOICE).text("(111) 555-1111").next().types(TelephoneType.HOME, TelephoneType.VOICE).text("(111) 555-2222").next().types(TelephoneType.CELL, TelephoneType.VOICE).text("(111) 555-4444").next().types(TelephoneType.WORK, TelephoneType.FAX).text("(111) 555-3333").noMore();
    asserter.address().extendedAddress("TheOffice").streetAddress("222 Broadway").locality("New York").region("NY").postalCode("99999").country("USA").label("222 Broadway\r\nNew York, NY 99999\r\nUSA").types(AddressType.WORK, AddressType.PREF).noMore();
    asserter.simpleProperty(Url.class).value("http://mikeangstadt.name").param("TYPE", "HOME").next().value("http://mikeangstadt.name").param("TYPE", "WORK").noMore();
    asserter.simpleProperty(Role.class).value("TheProfession").noMore();
    asserter.dateProperty(Birthday.class).date("1922-03-10").noMore();
    asserter.binaryProperty(Key.class).param("ENCODING", "BASE64").param("TYPE", "X509").contentType(KeyType.X509).dataLength(514).noMore();
    asserter.email().types(EmailType.PREF, EmailType.INTERNET).value("mike.angstadt@gmail.com").noMore();
    asserter.binaryProperty(Photo.class).param("ENCODING", "BASE64").param("TYPE", "JPEG").contentType(ImageType.JPEG).dataLength(2324).noMore();
    asserter.simpleProperty(FreeBusyUrl.class).value("http://website.com/mycal").noMore();
    asserter.simpleProperty(Revision.class).value(utc("2012-08-01 18:46:31")).noMore();
    asserter.rawProperty("X-MS-TEL").value("(111) 555-4444").param("TYPE", "VOICE").param("TYPE", "CALLBACK").noMore();
    asserter.rawProperty("X-MS-OL-DEFAULT-POSTAL-ADDRESS").value("2").noMore();
    asserter.rawProperty("X-MS-ANNIVERSARY").value("20120801").noMore();
    asserter.rawProperty("X-MS-IMADDRESS").value("im@aim.com").noMore();
    asserter.rawProperty("X-MS-OL-DESIGN").value("<card xmlns=\"http://schemas.microsoft.com/office/outlook/12/electronicbusinesscards\" ver=\"1.0\" layout=\"left\" bgcolor=\"ffffff\"><img xmlns=\"\" align=\"tleft\" area=\"32\" use=\"photo\"/><fld xmlns=\"\" prop=\"name\" align=\"left\" dir=\"ltr\" style=\"b\" color=\"000000\" size=\"10\"/><fld xmlns=\"\" prop=\"org\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"/><fld xmlns=\"\" prop=\"title\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"/><fld xmlns=\"\" prop=\"dept\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"/><fld xmlns=\"\" prop=\"telwork\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"><label align=\"right\" color=\"626262\">Work</label></fld><fld xmlns=\"\" prop=\"telcell\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"><label align=\"right\" color=\"626262\">Mobile</label></fld><fld xmlns=\"\" prop=\"telhome\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"><label align=\"right\" color=\"626262\">Home</label></fld><fld xmlns=\"\" prop=\"email\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"/><fld xmlns=\"\" prop=\"addrwork\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"/><fld xmlns=\"\" prop=\"webwork\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"/><fld xmlns=\"\" prop=\"blank\" size=\"8\"/><fld xmlns=\"\" prop=\"blank\" size=\"8\"/><fld xmlns=\"\" prop=\"blank\" size=\"8\"/><fld xmlns=\"\" prop=\"blank\" size=\"8\"/><fld xmlns=\"\" prop=\"blank\" size=\"8\"/><fld xmlns=\"\" prop=\"blank\" size=\"8\"/></card>").param("CHARSET", "utf-8").noMore();
    asserter.rawProperty("X-MS-MANAGER").value("TheManagerName").noMore();
    asserter.rawProperty("X-MS-ASSISTANT").value("TheAssistantName").noMore();
    asserter.rawProperty("X-MS-SPOUSE").value("TheSpouse").noMore();
    VCard vcard = asserter.getVCard();
    asserter.validate().prop(vcard.getNickname(), // not supported in 2.1
    2).prop(vcard.getFbUrls().get(0), // not supported in 2.1
    2).run();
    // @formatter:on
    asserter.done();
}
Also used : Photo(ezvcard.property.Photo) VCardAsserter(ezvcard.property.asserter.VCardAsserter) VCard(ezvcard.VCard) Key(ezvcard.property.Key) Test(org.junit.Test)

Example 52 with VCardAsserter

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

the class SampleVCardsTest method rfc2426_example.

@Test
public void rfc2426_example() throws Throwable {
    VCardAsserter asserter = read("rfc2426-example.vcf");
    {
        asserter.next(V3_0);
        // @formatter:off
        asserter.simpleProperty(FormattedName.class).value("Frank Dawson").noMore();
        asserter.listProperty(Organization.class).values("Lotus Development Corporation").noMore();
        asserter.address().streetAddress("6544 Battleford Drive").locality("Raleigh").region("NC").postalCode("27613-3502").country("U.S.A.").types(AddressType.WORK, AddressType.POSTAL, AddressType.PARCEL).noMore();
        asserter.telephone().types(TelephoneType.VOICE, TelephoneType.MSG, TelephoneType.WORK).text("+1-919-676-9515").next().types(TelephoneType.FAX, TelephoneType.WORK).text("+1-919-676-9564").noMore();
        asserter.email().types(EmailType.INTERNET, EmailType.PREF).value("Frank_Dawson@Lotus.com").next().types(EmailType.INTERNET).value("fdawson@earthlink.net").noMore();
        asserter.simpleProperty(Url.class).value("http://home.earthlink.net/~fdawson").noMore();
        asserter.validate().prop(null, // N property required
        0).run();
    // @formatter:on
    }
    {
        asserter.next(V3_0);
        // @formatter:off
        asserter.simpleProperty(FormattedName.class).value("Tim Howes").noMore();
        asserter.listProperty(Organization.class).values("Netscape Communications Corp.").noMore();
        asserter.address().streetAddress("501 E. Middlefield Rd.").locality("Mountain View").region("CA").postalCode(" 94043").country("U.S.A.").types(AddressType.WORK).noMore();
        asserter.telephone().types(TelephoneType.VOICE, TelephoneType.MSG, TelephoneType.WORK).text("+1-415-937-3419").next().types(TelephoneType.FAX, TelephoneType.WORK).text("+1-415-528-4164").noMore();
        asserter.email().types(EmailType.INTERNET).value("howes@netscape.com").noMore();
        asserter.validate().prop(null, // N property required
        0).run();
    // @formatter:on
    }
    asserter.done();
}
Also used : Organization(ezvcard.property.Organization) FormattedName(ezvcard.property.FormattedName) VCardAsserter(ezvcard.property.asserter.VCardAsserter) FreeBusyUrl(ezvcard.property.FreeBusyUrl) Url(ezvcard.property.Url) Test(org.junit.Test)

Example 53 with VCardAsserter

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

the class VCardReaderTest method quoted_printable_encoding_invalid_value.

@Test
public void quoted_printable_encoding_invalid_value() throws Exception {
    for (VCardVersion version : VCardVersion.values()) {
        // @formatter:off
        VCardAsserter asserter = read("BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "PROP;ENCODING=QUOTED-PRINTABLE:=nnnn\r\n" + "END:VCARD\r\n");
        asserter.next(version);
        asserter.rawProperty("PROP").param("ENCODING", "QUOTED-PRINTABLE").value("=nnnn").noMore();
        asserter.warnings(27);
        asserter.done();
    // @formatter:on
    }
}
Also used : VCardVersion(ezvcard.VCardVersion) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 54 with VCardAsserter

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

the class VCardReaderTest method label_parameters.

/**
 * Escaped newlines should ONLY be unescaped in LABEL parameters of ADR
 * properties.
 */
@Test
public void label_parameters() throws Exception {
    for (VCardVersion version : VCardVersion.values()) {
        // @formatter:off
        VCardAsserter asserter = read("BEGIN:VCARD\r\n" + "VERSION:" + version.getVersion() + "\r\n" + "ADR;LABEL=one\\ntwo;PARAM=one\\ntwo:\r\n" + "PROP;LABEL=one\\ntwo;PARAM=one\\ntwo:\r\n" + "END:VCARD\r\n");
        asserter.next(version);
        asserter.address().label("one" + NEWLINE + "two").param("PARAM", "one\\ntwo").noMore();
        asserter.rawProperty("PROP").param("LABEL", "one\\ntwo").param("PARAM", "one\\ntwo").value("").noMore();
        asserter.done();
    // @formatter:on
    }
}
Also used : VCardVersion(ezvcard.VCardVersion) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 55 with VCardAsserter

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

the class VCardReaderTest method invalid_version.

@Test
public void invalid_version() throws Exception {
    // @formatter:off
    VCardAsserter asserter = read("BEGIN:VCARD\r\n" + "VERSION:invalid\r\n" + "END:VCARD\r\n");
    // default to 2.1
    asserter.next(V2_1);
    asserter.rawProperty("VERSION").value("invalid").noMore();
    asserter.warnings(27);
    asserter.done();
// @formatter:on
}
Also used : 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