Search in sources :

Example 51 with VCard

use of ezvcard.VCard in project ez-vcard by mangstadt.

the class SampleVCardsTest method lotusNotesVCard.

@Test
public void lotusNotesVCard() throws Throwable {
    VCardAsserter asserter = read("John_Doe_LOTUS_NOTES.vcf");
    asserter.next(V3_0);
    // @formatter:off
    asserter.simpleProperty(ProductId.class).value("-//Apple Inc.//Address Book 6.1//EN").noMore();
    asserter.structuredName().family("Doe").given("John").additional("Johny").prefixes("Mr.").suffixes("I").noMore();
    asserter.simpleProperty(FormattedName.class).value("Mr. Doe John I Johny").noMore();
    asserter.listProperty(Nickname.class).values("Johny,JayJay").noMore();
    asserter.listProperty(Organization.class).values("IBM", "SUN").noMore();
    asserter.simpleProperty(Title.class).value("Generic Accountant").noMore();
    asserter.email().types(EmailType.INTERNET, EmailType.WORK, EmailType.PREF).value("john.doe@ibm.com").next().types(EmailType.INTERNET, EmailType.WORK).value("billy_bob@gmail.com").noMore();
    asserter.telephone().types(TelephoneType.CELL, TelephoneType.VOICE, TelephoneType.PREF).text("+1 (212) 204-34456").next().types(TelephoneType.WORK, TelephoneType.FAX).text("00-1-212-555-7777").noMore();
    asserter.address().group("item1").streetAddress("25334" + NEWLINE + "South cresent drive, Building 5, 3rd floo r").locality("New York").region("New York").postalCode("NYC887").country("U.S.A.").types(AddressType.HOME, AddressType.PREF).noMore();
    asserter.simpleProperty(Note.class).value("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"" + NEWLINE + "AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO , THE" + NEWLINE + "IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR P URPOSE" + NEWLINE + "ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTOR S BE" + NEWLINE + "LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR" + NEWLINE + "CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF" + NEWLINE + " SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS " + NEWLINE + "INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN" + NEWLINE + " CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)" + NEWLINE + "A RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE" + NEWLINE + " POSSIBILITY OF SUCH DAMAGE.").noMore();
    asserter.simpleProperty(Url.class).group("item2").value("http://www.sun.com").param("TYPE", "pref").noMore();
    asserter.dateProperty(Birthday.class).date("1980-05-21").noMore();
    asserter.binaryProperty(Photo.class).param("ENCODING", "b").param("TYPE", "JPEG").contentType(ImageType.JPEG).dataLength(7957).noMore();
    asserter.simpleProperty(Uid.class).value("0e7602cc-443e-4b82-b4b1-90f62f99a199").noMore();
    asserter.geo().latitude(-2.6).longitude(3.4).noMore();
    asserter.simpleProperty(Classification.class).value("Public").noMore();
    asserter.simpleProperty(Profile.class).value("VCard").noMore();
    asserter.timezone().offset(new UtcOffset(true, 1, 0)).noMore();
    asserter.simpleProperty(Label.class).value("John Doe" + NEWLINE + "New York, NewYork," + NEWLINE + "South Crecent Dr ive," + NEWLINE + "Building 5, floor 3," + NEWLINE + "USA").param("TYPE", "HOME").param("TYPE", "PARCEL").param("TYPE", "PREF").noMore();
    asserter.simpleProperty(SortString.class).value("JOHN").noMore();
    asserter.simpleProperty(Role.class).value("Counting Money").noMore();
    asserter.simpleProperty(Source.class).value("Whatever").noMore();
    asserter.simpleProperty(Mailer.class).value("Mozilla Thunderbird").noMore();
    asserter.simpleProperty(SourceDisplayText.class).value("VCard for John Doe").noMore();
    asserter.rawProperty("X-ABLABEL").group("item2").value("_$!<HomePage>!$_").noMore();
    asserter.rawProperty("X-ABUID").value("0E7602CC-443E-4B82-B4B1-90F62F99A199:ABPerson").noMore();
    asserter.rawProperty("X-GENERATOR").value("Cardme Generator").noMore();
    asserter.rawProperty("X-LONG-STRING").value("12345678901234567890123456789012345678901234567890123456789012 34567890123456789012345678901234567890").noMore();
    VCard vcard = asserter.getVCard();
    asserter.validate().prop(vcard.getEmails().get(0), // "TYPE=WORK" not valid in vCard 3.0
    9).prop(vcard.getEmails().get(1), // "TYPE=WORK" not valid in vCard 3.0
    9).run();
    // @formatter:on
    asserter.done();
}
Also used : UtcOffset(ezvcard.util.UtcOffset) Label(ezvcard.property.Label) Photo(ezvcard.property.Photo) VCardAsserter(ezvcard.property.asserter.VCardAsserter) VCard(ezvcard.VCard) Test(org.junit.Test)

Example 52 with VCard

use of ezvcard.VCard 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 53 with VCard

use of ezvcard.VCard 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 54 with VCard

use of ezvcard.VCard 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)

Example 55 with VCard

use of ezvcard.VCard in project ez-vcard by mangstadt.

the class VCardReaderTest method value_parameter.

@Test
public void value_parameter() throws Exception {
    for (VCardVersion version : VCardVersion.values()) {
        // @formatter:off
        String str = "BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "VAL;VALUE=text;LANGUAGE=en:value\r\n" + "VAL;LANGUAGE=en:value\r\n" + "VAL;VALUE=text:value\r\n" + "VAL:value\r\n" + "END:VCARD\r\n";
        // @formatter:on
        VCardReader reader = new VCardReader(str);
        reader.registerScribe(new ValueScribe());
        VCard vcard = reader.readNext();
        assertVersion(version, vcard);
        assertPropertyCount(4, vcard);
        Iterator<ValueProp> it = vcard.getProperties(ValueProp.class).iterator();
        ValueProp prop = it.next();
        assertEquals(TEXT, prop.dataType);
        assertEquals(1, prop.getParameters().size());
        assertNull(prop.getParameters().getValue());
        assertEquals("en", prop.getParameters().getLanguage());
        prop = it.next();
        assertEquals(INTEGER, prop.dataType);
        assertEquals(1, prop.getParameters().size());
        assertNull(prop.getParameters().getValue());
        assertEquals("en", prop.getParameters().getLanguage());
        prop = it.next();
        assertEquals(TEXT, prop.dataType);
        assertEquals(0, prop.getParameters().size());
        assertNull(prop.getParameters().getValue());
        assertNull(prop.getParameters().getLanguage());
        prop = it.next();
        assertEquals(INTEGER, prop.dataType);
        assertEquals(0, prop.getParameters().size());
        assertNull(prop.getParameters().getValue());
        assertNull(prop.getParameters().getLanguage());
        assertParseWarnings(reader);
        assertNoMoreVCards(reader);
    }
}
Also used : VCardVersion(ezvcard.VCardVersion) VCard(ezvcard.VCard) Test(org.junit.Test)

Aggregations

VCard (ezvcard.VCard)191 Test (org.junit.Test)134 StringWriter (java.io.StringWriter)29 StructuredName (ezvcard.property.StructuredName)23 Person (com.google.api.services.people.v1.model.Person)22 Telephone (ezvcard.property.Telephone)21 Photo (ezvcard.property.Photo)17 Email (ezvcard.property.Email)16 List (java.util.List)16 EmailAddress (com.google.api.services.people.v1.model.EmailAddress)15 Document (org.w3c.dom.Document)15 VCardVersion (ezvcard.VCardVersion)14 XCardDocumentStreamWriter (ezvcard.io.xml.XCardDocument.XCardDocumentStreamWriter)14 Address (ezvcard.property.Address)14 PhoneNumber (com.google.api.services.people.v1.model.PhoneNumber)13 Collectors (java.util.stream.Collectors)12 Name (com.google.api.services.people.v1.model.Name)11 File (java.io.File)11 Truth.assertThat (com.google.common.truth.Truth.assertThat)10 Pair (com.google.gdata.util.common.base.Pair)10