Search in sources :

Example 21 with VCardAsserter

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

the class SampleVCardsTest method msOutlookVCard.

@Test
public void msOutlookVCard() throws Throwable {
    VCardAsserter asserter = read("John_Doe_MS_OUTLOOK.vcf");
    asserter.next(V2_1);
    // @formatter:off
    asserter.structuredName().family("Doe").given("John").additional("Richter,James").prefixes("Mr.").suffixes("Sr.").param(VCardParameters.LANGUAGE, "en-us").noMore();
    asserter.simpleProperty(FormattedName.class).value("Mr. John Richter James Doe Sr.").noMore();
    asserter.listProperty(Nickname.class).values("Johny").noMore();
    asserter.listProperty(Organization.class).values("IBM", "Accounting").noMore();
    asserter.simpleProperty(Title.class).value("Money Counter").noMore();
    asserter.simpleProperty(Note.class).value("THIS SOFTWARE IS PROVIDED BY GEORGE EL-HADDAD ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GEORGE EL-HADDAD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.").noMore();
    asserter.telephone().types(TelephoneType.WORK, TelephoneType.VOICE).text("(905) 555-1234").next().types(TelephoneType.HOME, TelephoneType.VOICE).text("(905) 666-1234").noMore();
    asserter.address().streetAddress("Cresent moon drive").locality("Albaney").region("New York").postalCode("12345").country("United States of America").label("Cresent moon drive\r\nAlbaney, New York  12345").types(AddressType.WORK, AddressType.PREF).next().streetAddress("Silicon Alley 5,").locality("New York").region("New York").postalCode("12345").country("United States of America").label("Silicon Alley 5,\r\nNew York, New York  12345").types(AddressType.HOME).noMore();
    asserter.simpleProperty(Url.class).value("http://www.ibm.com").param("TYPE", "WORK").noMore();
    asserter.simpleProperty(Role.class).value("Counting Money").noMore();
    asserter.dateProperty(Birthday.class).date("1980-03-22").noMore();
    asserter.email().types(EmailType.PREF, EmailType.INTERNET).value("john.doe@ibm.cm").noMore();
    asserter.binaryProperty(Photo.class).param("ENCODING", "BASE64").param("TYPE", "JPEG").contentType(ImageType.JPEG).dataLength(860).noMore();
    asserter.simpleProperty(Revision.class).value(utc("2012-03-05 13:19:33")).noMore();
    asserter.rawProperty("X-MS-OL-DEFAULT-POSTAL-ADDRESS").value("2").noMore();
    asserter.rawProperty("X-MS-ANNIVERSARY").value("20110113").noMore();
    asserter.rawProperty("X-MS-IMADDRESS").value("johny5@aol.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=\"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=\"addrhome\" 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("Big Blue").noMore();
    asserter.rawProperty("X-MS-ASSISTANT").value("Jenny").noMore();
    VCard vcard = asserter.getVCard();
    asserter.validate().prop(vcard.getNickname(), // 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) FreeBusyUrl(ezvcard.property.FreeBusyUrl) Url(ezvcard.property.Url) Test(org.junit.Test)

Example 22 with VCardAsserter

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

the class SampleVCardsTest method androidVCard.

@Test
public void androidVCard() throws Throwable {
    VCardAsserter asserter = read("John_Doe_ANDROID.vcf");
    {
        asserter.next(V2_1);
        // @formatter:off
        asserter.email().types(EmailType.PREF).value("john.doe@company.com").noMore();
        asserter.listProperty(Categories.class).values("My Contacts").noMore();
        VCard vcard = asserter.getVCard();
        asserter.validate().prop(null, // N property required
        0).prop(vcard.getCategories(), // not supported in 2.1
        2).run();
    // @formatter:on
    }
    {
        asserter.next(V2_1);
        // @formatter:off
        asserter.email().types(EmailType.PREF).value("jane.doe@company.com").noMore();
        asserter.listProperty(Categories.class).values("My Contacts").noMore();
        VCard vcard = asserter.getVCard();
        asserter.validate().prop(null, // N property required
        0).prop(vcard.getCategories(), // not supported in 2.1
        2).run();
    // @formatter:on
    }
    {
        asserter.next(V2_1);
        // @formatter:off
        asserter.structuredName().param("ENCODING", "QUOTED-PRINTABLE").param("CHARSET", "UTF-8").family("\u00d1 \u00d1 \u00d1 \u00d1 ").noMore();
        asserter.simpleProperty(FormattedName.class).param("ENCODING", "QUOTED-PRINTABLE").param("CHARSET", "UTF-8").value("\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 ").noMore();
        asserter.telephone().types(TelephoneType.CELL, TelephoneType.PREF).text("123456789").noMore();
        asserter.listProperty(Categories.class).values("My Contacts").noMore();
        VCard vcard = asserter.getVCard();
        asserter.validate().prop(vcard.getCategories(), // not supported in 2.1
        2).run();
    // @formatter:on
    }
    {
        asserter.next(V2_1);
        // @formatter:off
        asserter.structuredName().param("CHARSET", "UTF-8").param("ENCODING", "QUOTED-PRINTABLE").family("\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1").noMore();
        asserter.simpleProperty(FormattedName.class).param("CHARSET", "UTF-8").param("ENCODING", "QUOTED-PRINTABLE").value("\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1").noMore();
        asserter.telephone().types(TelephoneType.CELL, TelephoneType.PREF).text("123456").next().types(TelephoneType.HOME).text("234567").next().types(TelephoneType.CELL).text("3456789").next().types(TelephoneType.HOME).text("45678901").noMore();
        asserter.listProperty(Categories.class).values("My Contacts").noMore();
        asserter.simpleProperty(Note.class).param("CHARSET", "UTF-8").param("ENCODING", "QUOTED-PRINTABLE").value("\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 ").next().param("CHARSET", "UTF-8").param("ENCODING", "QUOTED-PRINTABLE").value("\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 ").noMore();
        VCard vcard = asserter.getVCard();
        asserter.validate().prop(vcard.getCategories(), // not supported in 2.1
        2).run();
    // @formatter:on
    }
    {
        asserter.next(V2_1);
        // @formatter:off
        asserter.structuredName().param("CHARSET", "UTF-8").param("ENCODING", "QUOTED-PRINTABLE").family("\u00d1 \u00d1 ").given("\u00d1 \u00d1 \u00d1 ").noMore();
        asserter.simpleProperty(FormattedName.class).param("CHARSET", "UTF-8").param("ENCODING", "QUOTED-PRINTABLE").value("\u00d1 \u00d1 \u00d1 \u00d1 ").noMore();
        asserter.telephone().types(TelephoneType.CELL, TelephoneType.PREF).text("123456").next().types(TelephoneType.WORK).text("123456").next().types(TelephoneType.WORK, TelephoneType.FAX).text("123456").noMore();
        asserter.email().types(EmailType.PREF, EmailType.WORK).value("bob@company.com").next().types(EmailType.PREF).param("CHARSET", "UTF-8").param("ENCODING", "QUOTED-PRINTABLE").value("\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1").noMore();
        asserter.listProperty(Organization.class).param("CHARSET", "UTF-8").param("ENCODING", "QUOTED-PRINTABLE").values("\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1").next().param("CHARSET", "UTF-8").param("ENCODING", "QUOTED-PRINTABLE").values("\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1").noMore();
        asserter.simpleProperty(Url.class).value("www.company.com").next().value("http://www.company.com").noMore();
        asserter.binaryProperty(Photo.class).param("ENCODING", "BASE64").param("TYPE", "JPEG").contentType(ImageType.JPEG).dataLength(876).noMore();
        VCard vcard = asserter.getVCard();
        asserter.validate().prop(vcard.getEmails().get(0), // "TYPE=WORK" not valid in vCard 2.1
        9).run();
    // @formatter:on
    }
    {
        asserter.next(V2_1);
        // @formatter:off
        asserter.structuredName().param("CHARSET", "UTF-8").param("ENCODING", "QUOTED-PRINTABLE").family("\u00d1\u00d1\u00d1\u00d1").noMore();
        asserter.simpleProperty(FormattedName.class).param("CHARSET", "UTF-8").param("ENCODING", "QUOTED-PRINTABLE").value("\u00d1\u00d1\u00d1\u00d1").noMore();
        asserter.telephone().types(TelephoneType.CELL, TelephoneType.PREF).text("55556666").noMore();
        asserter.email().types(EmailType.PREF).value("henry@company.com").noMore();
        asserter.listProperty(Organization.class).param("CHARSET", "UTF-8").param("ENCODING", "QUOTED-PRINTABLE").values("\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1").next().param("CHARSET", "UTF-8").param("ENCODING", "QUOTED-PRINTABLE").values("\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1" + (char) 65533).next().param("CHARSET", "UTF-8").param("ENCODING", "QUOTED-PRINTABLE").values("\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1").noMore();
        asserter.listProperty(Categories.class).values("My Contacts").noMore();
        VCard vcard = asserter.getVCard();
        asserter.validate().prop(vcard.getCategories(), // not supported in 2.1
        2).run();
    // @formatter:on
    }
    asserter.done();
}
Also used : Organization(ezvcard.property.Organization) Categories(ezvcard.property.Categories) FormattedName(ezvcard.property.FormattedName) Note(ezvcard.property.Note) VCardAsserter(ezvcard.property.asserter.VCardAsserter) VCard(ezvcard.VCard) FreeBusyUrl(ezvcard.property.FreeBusyUrl) Url(ezvcard.property.Url) Test(org.junit.Test)

Example 23 with VCardAsserter

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

the class SampleVCardsTest method fullcontact.

@Test
public void fullcontact() throws Throwable {
    VCardAsserter asserter = read("fullcontact.vcf");
    asserter.next(V4_0);
    // @formatter:off
    asserter.structuredName().family("LastName").given("FirstName").additional("MiddleName").prefixes("Prefix").suffixes("Suffix").noMore();
    asserter.simpleProperty(FormattedName.class).value("Prefix FirstName MiddleName LastName Suffix").noMore();
    asserter.telephone().types(TelephoneType.HOME, TelephoneType.VOICE).text("555-555-1111").next().types(TelephoneType.WORK, TelephoneType.VOICE).text("555-555-1112").next().types(TelephoneType.CELL, TelephoneType.VOICE).text("555-555-1113").next().types(TelephoneType.CELL, TelephoneType.VOICE).text("555-555-1114").next().types(TelephoneType.VOICE).text("555-555-1115").next().types(TelephoneType.HOME, TelephoneType.FAX).text("555-555-1116").next().types(TelephoneType.WORK, TelephoneType.FAX).text("555-555-1117").next().types(TelephoneType.VOICE).text("555-555-1118").next().types(TelephoneType.VOICE).text("555-555-1119").noMore();
    asserter.email().types(EmailType.HOME).value("home@example.com").next().types(EmailType.WORK).value("work@example.com").next().types(EmailType.get("SCHOOL")).value("school@example.com").next().types(EmailType.get("OTHER")).value("other@example.com").next().types(EmailType.get("CUSTOMTYPE")).value("custom@example.com").noMore();
    asserter.binaryProperty(Photo.class).url("https://d3m0kzytmr41b1.cloudfront.net/c335e945d1b60edd9d75eb4837c432f637e95c8a").next().url("https://d3m0kzytmr41b1.cloudfront.net/c335e945d1b60edd9d75eb4837c432f637e95c8a").next().url("https://d2ojpxxtu63wzl.cloudfront.net/static/aa915d1f29f19baf560e5491decdd30a_67c95da9133249fde8b0da7ceebc298bf680117e6f52054f7f5f7a95e8377238").noMore();
    asserter.listProperty(Organization.class).values("Organization1", "Department1").next().values("Organization2", "Department2").noMore();
    asserter.simpleProperty(Title.class).value("Title1").next().value("Title2").noMore();
    asserter.dateProperty(Birthday.class).param("ALTID", "1").date("2016-08-01").next().param("ALTID", "1").text("2016-08-01").noMore();
    asserter.property(Gender.class).expected(Gender.male()).noMore();
    asserter.rawProperty("X-GENDER").value("male").noMore();
    asserter.rawProperty("X-ID").value("14f9aba0c9422da9ae376fe28bd89c2a.0").noMore();
    asserter.rawProperty("X-ETAG").value("fffffea9056d8166e2b7a427977e570c87dd51279d11d9b137c593eb").noMore();
    asserter.rawProperty("X-FC-TAGS").value("579c773f-736d-11e6-8dff-0ac8448704fb").noMore();
    asserter.rawProperty("X-FC-LIST-ID").value("8ad23200aa3e1984736b11e688dc0add41994b95").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A4D6F74686572").value("Mother").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A466174686572").value("Father").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A506172656E74").value("Parent").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A42726F74686572").value("Brother").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A536973746572").value("Sister").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A4368696C64").value("Child").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A467269656E64").value("Friend").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A53706F757365").value("Spouse").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A4669616E63C3A9").value("Fiance").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A506172746E6572").value("Partner").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A417373697374616E74").value("Assistant").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A4D616E61676572").value("Manager").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A4F74686572").value("Other").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A437573746F6D54595045").value("Custom").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D4F7468657244617465733A416E6E6976657273617279").value("2016-08-02").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D4F7468657244617465733A4F74686572").value("2016-08-03").noMore();
    asserter.rawProperty("X-FCENCODED-582D46432D4F7468657244617465733A437573746F6D54595045").value("2016-08-04").noMore();
    asserter.simpleProperty(Note.class).value("Notes line 1" + NEWLINE + "Notes line 2").noMore();
    asserter.simpleProperty(Url.class).value("http://www.homepage.com").next().value("http://www.blog.com").next().value("http://www.other.com").next().value("http://www.custom.com").noMore();
    asserter.address().types(AddressType.HOME).extendedAddress("HomeExtended").streetAddress("HomeStreet").locality("HomeCity").region("HomeState").postalCode("HomePostal").country("HomeCountry").next().types(AddressType.WORK).extendedAddress("WorkExtended").streetAddress("WorkStreet").locality("WorkCity").region("WorkState").postalCode("WorkPostal").country("WorkCountry").next().types(AddressType.get("OTHER")).extendedAddress("OtherExtended").streetAddress("OtherStreet").locality("OtherCity").region("OtherState").postalCode("OtherPostal").country("OtherCountry").next().types(AddressType.get("CUSTOMTYPE")).extendedAddress("CustomExtended").streetAddress("CustomStreet").locality("CustomCity").region("CustomState").postalCode("CustomPostal").country("CustomCountry").noMore();
    asserter.listProperty(Nickname.class).values("NickName").noMore();
    asserter.impp().param("X-SERVICE-TYPE", "GTalk").uri("xmpp:gtalk").next().param("X-SERVICE-TYPE", "Skype").uri("skype:skype").next().param("X-SERVICE-TYPE", "Yahoo").uri("ymsgr:yahoo").next().param("X-SERVICE-TYPE", "AIM").uri("aim:aim").next().param("X-SERVICE-TYPE", "Jabber").uri("xmpp:jabber").next().param("X-SERVICE-TYPE", "Other").uri("other:other").next().param("X-SERVICE-TYPE", "CustomTYPE").uri("customtype:custom").noMore();
    asserter.listProperty(Categories.class).values("Tag").noMore();
    asserter.simpleProperty(ProductId.class).value("ez-vcard 0.9.14-fc").noMore();
    // @formatter:on
    asserter.validate().run();
    asserter.done();
}
Also used : VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 24 with VCardAsserter

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

the class SampleVCardsTest method blackBerryVCard.

@Test
public void blackBerryVCard() throws Throwable {
    VCardAsserter asserter = read("John_Doe_BLACK_BERRY.vcf");
    asserter.next(V2_1);
    // @formatter:off
    asserter.simpleProperty(FormattedName.class).value("John Doe").noMore();
    asserter.structuredName().family("Doe").given("john").noMore();
    asserter.telephone().types(TelephoneType.CELL).text("+96123456789").noMore();
    asserter.listProperty(Organization.class).values("Acme Solutions").noMore();
    asserter.simpleProperty(Note.class).value("").noMore();
    asserter.binaryProperty(Photo.class).param("ENCODING", "BASE64").dataLength(1674).noMore();
    // @formatter:on
    asserter.validate().run();
    asserter.done();
}
Also used : Photo(ezvcard.property.Photo) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 25 with VCardAsserter

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

the class SampleVCardsTest method outlook2003VCard.

@Test
public void outlook2003VCard() throws Throwable {
    VCardAsserter asserter = read("outlook-2003.vcf");
    asserter.next(V2_1);
    // @formatter:off
    asserter.structuredName().family("Doe").given("John").prefixes("Mr.").suffixes("III").noMore();
    asserter.simpleProperty(FormattedName.class).value("John Doe III").noMore();
    asserter.listProperty(Nickname.class).values("Joey").noMore();
    asserter.listProperty(Organization.class).values("Company, The", "TheDepartment").noMore();
    asserter.simpleProperty(Title.class).value("The Job Title").noMore();
    asserter.simpleProperty(Note.class).value("This is the note field!!\r\nSecond line\r\n\r\nThird line is empty\r\n").param("ENCODING", "QUOTED-PRINTABLE").noMore();
    asserter.telephone().types(TelephoneType.WORK, TelephoneType.VOICE).text("BusinessPhone").next().types(TelephoneType.HOME, TelephoneType.VOICE).text("HomePhone").next().types(TelephoneType.CELL, TelephoneType.VOICE).text("MobilePhone").next().types(TelephoneType.WORK, TelephoneType.FAX).text("BusinessFaxPhone").noMore();
    asserter.address().extendedAddress("TheOffice").streetAddress("123 Main St").locality("Austin").region("TX").postalCode("12345").country("United States of America").label("TheOffice\r\n123 Main St\r\nAustin, TX 12345\r\nUnited States of America").types(AddressType.WORK).noMore();
    asserter.simpleProperty(Url.class).value("http://web-page-address.com").param("TYPE", "WORK").noMore();
    asserter.simpleProperty(Role.class).value("TheProfession").noMore();
    asserter.dateProperty(Birthday.class).date("1980-03-21").noMore();
    asserter.binaryProperty(Key.class).param("ENCODING", "BASE64").param("TYPE", "X509").contentType(KeyType.X509).dataLength(805).noMore();
    asserter.email().types(EmailType.PREF, EmailType.INTERNET).value("jdoe@hotmail.com").noMore();
    /*
		 * Outlook 2003 apparently doesn't output FBURL correctly:
		 * http://help.lockergnome.com/office/BUG-Outlook-2003-exports-FBURL-vCard-incorrectly--ftopict423660.html
		 */
    asserter.simpleProperty(FreeBusyUrl.class).value("????????????????s????????????" + (char) 12).param("ENCODING", "QUOTED-PRINTABLE").noMore();
    asserter.simpleProperty(Revision.class).value(utc("2012-10-12 21:05:25")).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 : Note(ezvcard.property.Note) FreeBusyUrl(ezvcard.property.FreeBusyUrl) VCardAsserter(ezvcard.property.asserter.VCardAsserter) VCard(ezvcard.VCard) FreeBusyUrl(ezvcard.property.FreeBusyUrl) Url(ezvcard.property.Url) Key(ezvcard.property.Key) 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