Search in sources :

Example 16 with VCardAsserter

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

the class HCardParserTest method convert_tel_urls_to_tel_types.

@Test
public void convert_tel_urls_to_tel_types() throws Exception {
    // @formatter:off
    VCardAsserter asserter = readHtml("<html>" + "<body>" + "<div class=\"vcard\">" + "<a class=\"url\" href=\"tel:+15555551234\">Call me</a>" + "</div>" + "</body>" + "</html>");
    asserter.next(V3_0);
    asserter.telephone().uri(new TelUri.Builder("+15555551234").build()).noMore();
    asserter.done();
// @formatter:on
}
Also used : TelUri(ezvcard.util.TelUri) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 17 with VCardAsserter

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

the class SampleVCardsTest method macAddressBookVCard.

@Test
public void macAddressBookVCard() throws Throwable {
    VCardAsserter asserter = read("John_Doe_MAC_ADDRESS_BOOK.vcf");
    asserter.next(V3_0);
    // @formatter:off
    asserter.structuredName().family("Doe").given("John").additional("Richter,James").prefixes("Mr.").suffixes("Sr.").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.email().types(EmailType.INTERNET, EmailType.WORK, EmailType.PREF).value("john.doe@ibm.com").noMore();
    asserter.telephone().types(TelephoneType.WORK, TelephoneType.PREF).text("905-777-1234").next().types(TelephoneType.HOME).text("905-666-1234").next().types(TelephoneType.CELL).text("905-555-1234").next().types(TelephoneType.HOME, TelephoneType.FAX).text("905-888-1234").next().types(TelephoneType.WORK, TelephoneType.FAX).text("905-999-1234").next().types(TelephoneType.PAGER).text("905-111-1234").next().group("item1").text("905-222-1234").noMore();
    asserter.address().group("item2").streetAddress("Silicon Alley 5,").locality("New York").region("New York").postalCode("12345").country("United States of America").types(AddressType.HOME, AddressType.PREF).next().group("item3").streetAddress("Street4" + NEWLINE + "Building 6" + NEWLINE + "Floor 8").locality("New York").postalCode("12345").country("USA").types(AddressType.WORK).noMore();
    asserter.simpleProperty(Note.class).value("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"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 THE COPYRIGHT HOLDER 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." + NEWLINE + "Favotire Color: Blue").noMore();
    asserter.simpleProperty(Url.class).group("item4").value("http://www.ibm.com").param("TYPE", "pref").noMore();
    asserter.dateProperty(Birthday.class).date("2012-06-06").noMore();
    asserter.binaryProperty(Photo.class).param("ENCODING", "BASE64").dataLength(18242).noMore();
    asserter.rawProperty("X-PHONETIC-FIRST-NAME").value("Jon").noMore();
    asserter.rawProperty("X-PHONETIC-LAST-NAME").value("Dow").noMore();
    asserter.rawProperty("X-ABLABEL").group("item1").value("AssistantPhone").next().group("item4").value("_$!<HomePage>!$_").next().group("item5").value("Spouse").noMore();
    asserter.rawProperty("X-ABADR").group("item2").value("Silicon Alley").next().group("item3").value("Street 4, Building 6,\\nFloor 8\\nNew York\\nUSA").noMore();
    asserter.rawProperty("X-ABRELATEDNAMES").group("item5").value("Jenny").param("TYPE", "pref").noMore();
    asserter.rawProperty("X-ABUID").value("6B29A774-D124-4822-B8D0-2780EC117F60\\:ABPerson").noMore();
    VCard vcard = asserter.getVCard();
    asserter.validate().prop(vcard.getEmails().get(0), // "TYPE=WORK" not valid in vCard 3.0
    9).prop(vcard.getPhotos().get(0), // "BASE64" not valid parameter
    4).run();
    // @formatter:on
    asserter.done();
}
Also used : Photo(ezvcard.property.Photo) VCardAsserter(ezvcard.property.asserter.VCardAsserter) VCard(ezvcard.VCard) Test(org.junit.Test)

Example 18 with VCardAsserter

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

the class SampleVCardsTest method gmailSingle.

@Test
public void gmailSingle() throws Throwable {
    VCardAsserter asserter = read("gmail-single.vcf");
    asserter.next(V3_0);
    // @formatter:off
    asserter.simpleProperty(FormattedName.class).value("Greg Dartmouth").noMore();
    asserter.structuredName().family("Dartmouth").given("Greg").noMore();
    asserter.listProperty(Nickname.class).values("Gman").noMore();
    asserter.email().types(EmailType.INTERNET).value("gdartmouth@hotmail.com").noMore();
    asserter.telephone().types(TelephoneType.CELL).text("555 555 1111").next().group("item1").text("555 555 2222").noMore();
    asserter.address().streetAddress("123 Home St" + NEWLINE + "Home City, HM 12345").types(AddressType.HOME).next().group("item2").streetAddress("321 Custom St").locality("Custom City").region("TX").postalCode("98765").country("USA").noMore();
    asserter.listProperty(Organization.class).values("TheCompany").noMore();
    asserter.simpleProperty(Title.class).value("TheJobTitle").noMore();
    asserter.dateProperty(Birthday.class).date("1960-09-10").noMore();
    asserter.simpleProperty(Url.class).group("item3").value("http://TheProfile.com").noMore();
    asserter.simpleProperty(Note.class).value("This is GMail's note field." + NEWLINE + "It should be added as a NOTE type." + NEWLINE + "ACustomField: CustomField").noMore();
    asserter.rawProperty("X-PHONETIC-FIRST-NAME").value("Grregg").noMore();
    asserter.rawProperty("X-PHONETIC-LAST-NAME").value("Dart-mowth").noMore();
    asserter.rawProperty("X-ICQ").value("123456789").noMore();
    asserter.rawProperty("X-ABLABEL").group("item1").value("GRAND_CENTRAL").next().group("item2").value("CustomAdrType").next().group("item3").value("PROFILE").next().group("item4").value("_$!<Anniversary>!$_").next().group("item5").value("_$!<Spouse>!$_").next().group("item6").value("CustomRelationship").noMore();
    asserter.rawProperty("X-ABDATE").group("item4").value("1970-06-02").noMore();
    asserter.rawProperty("X-ABRELATEDNAMES").group("item5").value("MySpouse").next().group("item6").value("MyCustom").noMore();
    // @formatter:on
    asserter.validate().run();
    asserter.done();
}
Also used : VCardAsserter(ezvcard.property.asserter.VCardAsserter) FreeBusyUrl(ezvcard.property.FreeBusyUrl) Url(ezvcard.property.Url) Test(org.junit.Test)

Example 19 with VCardAsserter

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

the class SampleVCardsTest method evolutionVCard.

@Test
public void evolutionVCard() throws Throwable {
    VCardAsserter asserter = read("John_Doe_EVOLUTION.vcf");
    asserter.next(V3_0);
    // @formatter:off
    asserter.simpleProperty(Url.class).value("http://www.ibm.com").param("X-COUCHDB-UUID", "0abc9b8d-0845-47d0-9a91-3db5bb74620d").noMore();
    asserter.telephone().types(TelephoneType.CELL).text("905-666-1234").param("X-COUCHDB-UUID", "c2fa1caa-2926-4087-8971-609cfc7354ce").next().types(TelephoneType.WORK, TelephoneType.VOICE).text("905-555-1234").param("X-COUCHDB-UUID", "fbfb2722-4fd8-4dbf-9abd-eeb24072fd8e").noMore();
    asserter.simpleProperty(Uid.class).value("477343c8e6bf375a9bac1f96a5000837").noMore();
    asserter.structuredName().family("Doe").given("John").additional("Richter, James").prefixes("Mr.").suffixes("Sr.").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", "Dungeon").noMore();
    asserter.simpleProperty(Title.class).value("Money Counter").noMore();
    asserter.listProperty(Categories.class).values("VIP").noMore();
    asserter.simpleProperty(Note.class).value("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"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 THE COPYRIGHT HOLDER 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.email().types(EmailType.WORK).value("john.doe@ibm.com").param("X-COUCHDB-UUID", "83a75a5d-2777-45aa-bab5-76a4bd972490").noMore();
    asserter.address().poBox("ASB-123").streetAddress("15 Crescent moon drive").locality("Albaney").region("New York").postalCode("12345").country("United States of America").types(AddressType.HOME).noMore();
    asserter.dateProperty(Birthday.class).date("1980-03-22").noMore();
    asserter.simpleProperty(Revision.class).value(utc("2012-03-05 13:32:54")).noMore();
    asserter.rawProperty("X-COUCHDB-APPLICATION-ANNOTATIONS").value("{\"Evolution\":{\"revision\":\"2012-03-05T13:32:54Z\"}}").noMore();
    asserter.rawProperty("X-AIM").value("johnny5@aol.com").param("TYPE", "HOME").param("X-COUCHDB-UUID", "cb9e11fc-bb97-4222-9cd8-99820c1de454").noMore();
    asserter.rawProperty("X-EVOLUTION-FILE-AS").value("Doe\\, John").noMore();
    asserter.rawProperty("X-EVOLUTION-SPOUSE").value("Maria").noMore();
    asserter.rawProperty("X-EVOLUTION-MANAGER").value("Big Blue").noMore();
    asserter.rawProperty("X-EVOLUTION-ASSISTANT").value("Little Red").noMore();
    asserter.rawProperty("X-EVOLUTION-ANNIVERSARY").value("1980-03-22").noMore();
    VCard vcard = asserter.getVCard();
    asserter.validate().prop(vcard.getEmails().get(0), // "TYPE=WORK" not valid in vCard 3.0
    9).run();
    // @formatter:on
    asserter.done();
}
Also used : VCardAsserter(ezvcard.property.asserter.VCardAsserter) VCard(ezvcard.VCard) FreeBusyUrl(ezvcard.property.FreeBusyUrl) Url(ezvcard.property.Url) Test(org.junit.Test)

Example 20 with VCardAsserter

use of ezvcard.property.asserter.VCardAsserter 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)

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