Debian Codegraph @

src/test/java/ezvcard/io/text/SampleVCardsTest.java

raw symbols SCIP
1 package ezvcard.io.text;
2
3 import static ezvcard.VCardVersion.V2_1;
4 import static ezvcard.VCardVersion.V3_0;
5 import static ezvcard.VCardVersion.V4_0;
6 import static ezvcard.util.StringUtils.NEWLINE;
7
8 import java.time.LocalDate;
9 import java.time.LocalDateTime;
10 import java.time.ZoneOffset;
11
12 import org.junit.Test;
13
14 import ezvcard.VCard;
15 import ezvcard.parameter.AddressType;
16 import ezvcard.parameter.EmailType;
17 import ezvcard.parameter.ImageType;
18 import ezvcard.parameter.KeyType;
19 import ezvcard.parameter.TelephoneType;
20 import ezvcard.parameter.VCardParameters;
21 import ezvcard.property.Anniversary;
22 import ezvcard.property.Birthday;
23 import ezvcard.property.Categories;
24 import ezvcard.property.Classification;
25 import ezvcard.property.FormattedName;
26 import ezvcard.property.FreeBusyUrl;
27 import ezvcard.property.Gender;
28 import ezvcard.property.Key;
29 import ezvcard.property.Label;
30 import ezvcard.property.Language;
31 import ezvcard.property.Mailer;
32 import ezvcard.property.Nickname;
33 import ezvcard.property.Note;
34 import ezvcard.property.Organization;
35 import ezvcard.property.Photo;
36 import ezvcard.property.ProductId;
37 import ezvcard.property.Profile;
38 import ezvcard.property.Revision;
39 import ezvcard.property.Role;
40 import ezvcard.property.SortString;
41 import ezvcard.property.Source;
42 import ezvcard.property.SourceDisplayText;
43 import ezvcard.property.Title;
44 import ezvcard.property.Uid;
45 import ezvcard.property.Url;
46 import ezvcard.property.asserter.VCardAsserter;
47 import ezvcard.util.PartialDate;
48 import ezvcard.util.TelUri;
49
50 /*
51 Copyright (c) 2012-2023, Michael Angstadt
52 All rights reserved.
53
54 Redistribution and use in source and binary forms, with or without
55 modification, are permitted provided that the following conditions are met:
56
57 1. Redistributions of source code must retain the above copyright notice, this
58 list of conditions and the following disclaimer.
59 2. Redistributions in binary form must reproduce the above copyright notice,
60 this list of conditions and the following disclaimer in the documentation
61 and/or other materials provided with the distribution.
62
63 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
64 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
65 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
66 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
67 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
68 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
69 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
70 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
71 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
72 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
73
74 The views and conclusions contained in the software and documentation are those
75 of the authors and should not be interpreted as representing official policies,
76 either expressed or implied, of the FreeBSD Project.
77 */
78
79 /**
80 * @author Michael Angstadt
81 */
82 public class SampleVCardsTest {
83 @Test
84 public void androidVCard() throws Throwable {
85 VCardAsserter asserter = read("John_Doe_ANDROID.vcf");
86
87 {
88 asserter.next(V2_1);
89
90 //@formatter:off
91 asserter.email()
92 .types(EmailType.PREF)
93 .value("[email protected]")
94 .noMore();
95
96 asserter.listProperty(Categories.class)
97 .values("My Contacts")
98 .noMore();
99
100 VCard vcard = asserter.getVCard();
101 asserter.validate()
102 .prop(null, 0) //N property required
103 .prop(vcard.getCategories(), 2) //not supported in 2.1
104 .run();
105 //@formatter:on
106 }
107
108 {
109 asserter.next(V2_1);
110
111 //@formatter:off
112 asserter.email()
113 .types(EmailType.PREF)
114 .value("[email protected]")
115 .noMore();
116
117 asserter.listProperty(Categories.class)
118 .values("My Contacts")
119 .noMore();
120
121 VCard vcard = asserter.getVCard();
122 asserter.validate()
123 .prop(null, 0) //N property required
124 .prop(vcard.getCategories(), 2) //not supported in 2.1
125 .run();
126 //@formatter:on
127 }
128
129 {
130 asserter.next(V2_1);
131
132 //@formatter:off
133 asserter.structuredName()
134 .param("ENCODING", "QUOTED-PRINTABLE")
135 .param("CHARSET", "UTF-8")
136 .family("\u00d1 \u00d1 \u00d1 \u00d1 ")
137 .noMore();
138
139 asserter.simpleProperty(FormattedName.class)
140 .param("ENCODING", "QUOTED-PRINTABLE")
141 .param("CHARSET", "UTF-8")
142 .value("\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 ")
143 .noMore();
144
145 asserter.telephone()
146 .types(TelephoneType.CELL, TelephoneType.PREF)
147 .text("123456789")
148 .noMore();
149
150 asserter.listProperty(Categories.class)
151 .values("My Contacts")
152 .noMore();
153
154 VCard vcard = asserter.getVCard();
155 asserter.validate()
156 .prop(vcard.getCategories(), 2) //not supported in 2.1
157 .run();
158 //@formatter:on
159 }
160
161 {
162 asserter.next(V2_1);
163
164 //@formatter:off
165 asserter.structuredName()
166 .param("CHARSET", "UTF-8")
167 .param("ENCODING", "QUOTED-PRINTABLE")
168 .family("\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1")
169 .noMore();
170
171 asserter.simpleProperty(FormattedName.class)
172 .param("CHARSET", "UTF-8")
173 .param("ENCODING", "QUOTED-PRINTABLE")
174 .value("\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1")
175 .noMore();
176
177 asserter.telephone()
178 .types(TelephoneType.CELL, TelephoneType.PREF)
179 .text("123456")
180 .next()
181 .types(TelephoneType.HOME)
182 .text("234567")
183 .next()
184 .types(TelephoneType.CELL)
185 .text("3456789")
186 .next()
187 .types(TelephoneType.HOME)
188 .text("45678901")
189 .noMore();
190
191 asserter.listProperty(Categories.class)
192 .values("My Contacts")
193 .noMore();
194
195 asserter.simpleProperty(Note.class)
196 .param("CHARSET", "UTF-8")
197 .param("ENCODING", "QUOTED-PRINTABLE")
198 .value("\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 ")
199 .next()
200 .param("CHARSET", "UTF-8")
201 .param("ENCODING", "QUOTED-PRINTABLE")
202 .value("\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1 \u00d1\u00d1 \u00d1 \u00d1 \u00d1 \u00d1 ")
203 .noMore();
204
205 VCard vcard = asserter.getVCard();
206 asserter.validate()
207 .prop(vcard.getCategories(), 2) //not supported in 2.1
208 .run();
209 //@formatter:on
210 }
211
212 {
213 asserter.next(V2_1);
214
215 //@formatter:off
216 asserter.structuredName()
217 .param("CHARSET", "UTF-8")
218 .param("ENCODING", "QUOTED-PRINTABLE")
219 .family("\u00d1 \u00d1 ")
220 .given("\u00d1 \u00d1 \u00d1 ")
221 .noMore();
222
223 asserter.simpleProperty(FormattedName.class)
224 .param("CHARSET", "UTF-8")
225 .param("ENCODING", "QUOTED-PRINTABLE")
226 .value("\u00d1 \u00d1 \u00d1 \u00d1 ")
227 .noMore();
228
229 asserter.telephone()
230 .types(TelephoneType.CELL, TelephoneType.PREF)
231 .text("123456")
232 .next()
233 .types(TelephoneType.WORK)
234 .text("123456")
235 .next()
236 .types(TelephoneType.WORK, TelephoneType.FAX)
237 .text("123456")
238 .noMore();
239
240 asserter.email()
241 .types(EmailType.PREF, EmailType.WORK)
242 .value("[email protected]")
243 .next()
244 .types(EmailType.PREF)
245 .param("CHARSET", "UTF-8")
246 .param("ENCODING", "QUOTED-PRINTABLE")
247 .value("\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1")
248 .noMore();
249
250 asserter.listProperty(Organization.class)
251 .param("CHARSET", "UTF-8")
252 .param("ENCODING", "QUOTED-PRINTABLE")
253 .values("\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1")
254 .next()
255 .param("CHARSET", "UTF-8")
256 .param("ENCODING", "QUOTED-PRINTABLE")
257 .values("\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1\u00d1")
258 .noMore();
259
260 asserter.simpleProperty(Url.class)
261 .value("www.company.com")
262 .next()
263 .value("http://www.company.com")
264 .noMore();
265
266 asserter.binaryProperty(Photo.class)
267 .param("ENCODING", "BASE64")
268 .param("TYPE", "JPEG")
269 .contentType(ImageType.JPEG)
270 .dataLength(876)
271 .noMore();
272
273 VCard vcard = asserter.getVCard();
274 asserter.validate()
275 .prop(vcard.getEmails().get(0), 9) //"TYPE=WORK" not valid in vCard 2.1
276 .run();
277 //@formatter:on
278 }
279
280 {
281 asserter.next(V2_1);
282
283 //@formatter:off
284 asserter.structuredName()
285 .param("CHARSET", "UTF-8")
286 .param("ENCODING", "QUOTED-PRINTABLE")
287 .family("\u00d1\u00d1\u00d1\u00d1")
288 .noMore();
289
290 asserter.simpleProperty(FormattedName.class)
291 .param("CHARSET", "UTF-8")
292 .param("ENCODING", "QUOTED-PRINTABLE")
293 .value("\u00d1\u00d1\u00d1\u00d1")
294 .noMore();
295
296 asserter.telephone()
297 .types(TelephoneType.CELL, TelephoneType.PREF)
298 .text("55556666")
299 .noMore();
300
301 asserter.email()
302 .types(EmailType.PREF)
303 .value("[email protected]")
304 .noMore();
305
306 asserter.listProperty(Organization.class)
307 .param("CHARSET", "UTF-8")
308 .param("ENCODING", "QUOTED-PRINTABLE")
309 .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")
310 .next()
311 .param("CHARSET", "UTF-8")
312 .param("ENCODING", "QUOTED-PRINTABLE")
313 .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)
314 .next()
315 .param("CHARSET", "UTF-8")
316 .param("ENCODING", "QUOTED-PRINTABLE")
317 .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")
318 .noMore();
319
320 asserter.listProperty(Categories.class)
321 .values("My Contacts")
322 .noMore();
323
324 VCard vcard = asserter.getVCard();
325 asserter.validate()
326 .prop(vcard.getCategories(), 2) //not supported in 2.1
327 .run();
328 //@formatter:on
329 }
330
331 asserter.done();
332 }
333
334 @Test
335 public void blackBerryVCard() throws Throwable {
336 VCardAsserter asserter = read("John_Doe_BLACK_BERRY.vcf");
337 asserter.next(V2_1);
338
339 //@formatter:off
340 asserter.simpleProperty(FormattedName.class)
341 .value("John Doe")
342 .noMore();
343
344 asserter.structuredName()
345 .family("Doe")
346 .given("john")
347 .noMore();
348
349 asserter.telephone()
350 .types(TelephoneType.CELL)
351 .text("+96123456789")
352 .noMore();
353
354 asserter.listProperty(Organization.class)
355 .values("Acme Solutions")
356 .noMore();
357
358 asserter.simpleProperty(Note.class)
359 .value("")
360 .noMore();
361
362 asserter.binaryProperty(Photo.class)
363 .param("ENCODING", "BASE64")
364 .dataLength(1674)
365 .noMore();
366 //@formatter:on
367
368 asserter.validate().run();
369 asserter.done();
370 }
371
372 @Test
373 public void evolutionVCard() throws Throwable {
374 VCardAsserter asserter = read("John_Doe_EVOLUTION.vcf");
375 asserter.next(V3_0);
376
377 //@formatter:off
378 asserter.simpleProperty(Url.class)
379 .value("http://www.ibm.com")
380 .param("X-COUCHDB-UUID", "0abc9b8d-0845-47d0-9a91-3db5bb74620d")
381 .noMore();
382
383 asserter.telephone()
384 .types(TelephoneType.CELL)
385 .text("905-666-1234")
386 .param("X-COUCHDB-UUID", "c2fa1caa-2926-4087-8971-609cfc7354ce")
387 .next()
388 .types(TelephoneType.WORK, TelephoneType.VOICE)
389 .text("905-555-1234")
390 .param("X-COUCHDB-UUID", "fbfb2722-4fd8-4dbf-9abd-eeb24072fd8e")
391 .noMore();
392
393 asserter.simpleProperty(Uid.class)
394 .value("477343c8e6bf375a9bac1f96a5000837")
395 .noMore();
396
397 asserter.structuredName()
398 .family("Doe")
399 .given("John")
400 .additional("Richter, James")
401 .prefixes("Mr.")
402 .suffixes("Sr.")
403 .noMore();
404
405 asserter.simpleProperty(FormattedName.class)
406 .value("Mr. John Richter, James Doe Sr.")
407 .noMore();
408
409 asserter.listProperty(Nickname.class)
410 .values("Johny")
411 .noMore();
412
413 asserter.listProperty(Organization.class)
414 .values("IBM", "Accounting", "Dungeon")
415 .noMore();
416
417 asserter.simpleProperty(Title.class)
418 .value("Money Counter")
419 .noMore();
420
421 asserter.listProperty(Categories.class)
422 .values("VIP")
423 .noMore();
424
425 asserter.simpleProperty(Note.class)
426 .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.")
427 .noMore();
428
429 asserter.email()
430 .types(EmailType.WORK)
431 .value("[email protected]")
432 .param("X-COUCHDB-UUID", "83a75a5d-2777-45aa-bab5-76a4bd972490")
433 .noMore();
434
435 asserter.address()
436 .poBox("ASB-123")
437 .streetAddress("15 Crescent moon drive")
438 .locality("Albaney")
439 .region("New York")
440 .postalCode("12345")
441 .country("United States of America")
442 .types(AddressType.HOME)
443 .noMore();
444
445 asserter.dateProperty(Birthday.class)
446 .date(LocalDate.of(1980, 3, 22))
447 .noMore();
448
449 asserter.simpleProperty(Revision.class)
450 .value(LocalDateTime.of(2012, 3, 5, 13, 32, 54).toInstant(ZoneOffset.UTC))
451 .noMore();
452
453 asserter.rawProperty("X-COUCHDB-APPLICATION-ANNOTATIONS")
454 .value("{\"Evolution\":{\"revision\":\"2012-03-05T13:32:54Z\"}}")
455 .noMore();
456
457 asserter.rawProperty("X-AIM")
458 .value("[email protected]")
459 .param("TYPE", "HOME")
460 .param("X-COUCHDB-UUID", "cb9e11fc-bb97-4222-9cd8-99820c1de454")
461 .noMore();
462
463 asserter.rawProperty("X-EVOLUTION-FILE-AS")
464 .value("Doe\\, John")
465 .noMore();
466
467 asserter.rawProperty("X-EVOLUTION-SPOUSE")
468 .value("Maria")
469 .noMore();
470
471 asserter.rawProperty("X-EVOLUTION-MANAGER")
472 .value("Big Blue")
473 .noMore();
474
475 asserter.rawProperty("X-EVOLUTION-ASSISTANT")
476 .value("Little Red")
477 .noMore();
478
479 asserter.rawProperty("X-EVOLUTION-ANNIVERSARY")
480 .value("1980-03-22")
481 .noMore();
482
483 VCard vcard = asserter.getVCard();
484 asserter.validate()
485 .prop(vcard.getEmails().get(0), 9) //"TYPE=WORK" not valid in vCard 3.0
486 .run();
487 //@formatter:on
488
489 asserter.done();
490 }
491
492 @Test
493 public void fullcontact() throws Throwable {
494 VCardAsserter asserter = read("fullcontact.vcf");
495 asserter.next(V4_0);
496
497 //@formatter:off
498 asserter.structuredName()
499 .family("LastName")
500 .given("FirstName")
501 .additional("MiddleName")
502 .prefixes("Prefix")
503 .suffixes("Suffix")
504 .noMore();
505
506 asserter.simpleProperty(FormattedName.class)
507 .value("Prefix FirstName MiddleName LastName Suffix")
508 .noMore();
509
510 asserter.telephone()
511 .types(TelephoneType.HOME, TelephoneType.VOICE)
512 .text("555-555-1111")
513 .next()
514 .types(TelephoneType.WORK, TelephoneType.VOICE)
515 .text("555-555-1112")
516 .next()
517 .types(TelephoneType.CELL, TelephoneType.VOICE)
518 .text("555-555-1113")
519 .next()
520 .types(TelephoneType.CELL, TelephoneType.VOICE)
521 .text("555-555-1114")
522 .next()
523 .types(TelephoneType.VOICE)
524 .text("555-555-1115")
525 .next()
526 .types(TelephoneType.HOME, TelephoneType.FAX)
527 .text("555-555-1116")
528 .next()
529 .types(TelephoneType.WORK, TelephoneType.FAX)
530 .text("555-555-1117")
531 .next()
532 .types(TelephoneType.VOICE)
533 .text("555-555-1118")
534 .next()
535 .types(TelephoneType.VOICE)
536 .text("555-555-1119")
537 .noMore();
538
539 asserter.email()
540 .types(EmailType.HOME)
541 .value("[email protected]")
542 .next()
543 .types(EmailType.WORK)
544 .value("[email protected]")
545 .next()
546 .types(EmailType.get("SCHOOL"))
547 .value("[email protected]")
548 .next()
549 .types(EmailType.get("OTHER"))
550 .value("[email protected]")
551 .next()
552 .types(EmailType.get("CUSTOMTYPE"))
553 .value("[email protected]")
554 .noMore();
555
556 asserter.binaryProperty(Photo.class)
557 .url("https://d3m0kzytmr41b1.cloudfront.net/c335e945d1b60edd9d75eb4837c432f637e95c8a")
558 .next()
559 .url("https://d3m0kzytmr41b1.cloudfront.net/c335e945d1b60edd9d75eb4837c432f637e95c8a")
560 .next()
561 .url("https://d2ojpxxtu63wzl.cloudfront.net/static/aa915d1f29f19baf560e5491decdd30a_67c95da9133249fde8b0da7ceebc298bf680117e6f52054f7f5f7a95e8377238")
562 .noMore();
563
564 asserter.listProperty(Organization.class)
565 .values("Organization1", "Department1")
566 .next()
567 .values("Organization2", "Department2")
568 .noMore();
569
570 asserter.simpleProperty(Title.class)
571 .value("Title1")
572 .next()
573 .value("Title2")
574 .noMore();
575
576 asserter.dateProperty(Birthday.class)
577 .param("ALTID", "1")
578 .date(LocalDate.of(2016, 8, 1))
579 .next()
580 .param("ALTID", "1")
581 .text("2016-08-01")
582 .noMore();
583
584 asserter.property(Gender.class)
585 .expected(Gender.male())
586 .noMore();
587
588 asserter.rawProperty("X-GENDER")
589 .value("male")
590 .noMore();
591
592 asserter.rawProperty("X-ID")
593 .value("14f9aba0c9422da9ae376fe28bd89c2a.0")
594 .noMore();
595
596 asserter.rawProperty("X-ETAG")
597 .value("fffffea9056d8166e2b7a427977e570c87dd51279d11d9b137c593eb")
598 .noMore();
599
600 asserter.rawProperty("X-FC-TAGS")
601 .value("579c773f-736d-11e6-8dff-0ac8448704fb")
602 .noMore();
603
604 asserter.rawProperty("X-FC-LIST-ID")
605 .value("8ad23200aa3e1984736b11e688dc0add41994b95")
606 .noMore();
607
608 asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A4D6F74686572")
609 .value("Mother")
610 .noMore();
611
612 asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A466174686572")
613 .value("Father")
614 .noMore();
615
616 asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A506172656E74")
617 .value("Parent")
618 .noMore();
619
620 asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A42726F74686572")
621 .value("Brother")
622 .noMore();
623
624 asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A536973746572")
625 .value("Sister")
626 .noMore();
627
628 asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A4368696C64")
629 .value("Child")
630 .noMore();
631
632 asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A467269656E64")
633 .value("Friend")
634 .noMore();
635
636 asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A53706F757365")
637 .value("Spouse")
638 .noMore();
639
640 asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A4669616E63C3A9")
641 .value("Fiance")
642 .noMore();
643
644 asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A506172746E6572")
645 .value("Partner")
646 .noMore();
647
648 asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A417373697374616E74")
649 .value("Assistant")
650 .noMore();
651
652 asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A4D616E61676572")
653 .value("Manager")
654 .noMore();
655
656 asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A4F74686572")
657 .value("Other")
658 .noMore();
659
660 asserter.rawProperty("X-FCENCODED-582D46432D52656C617465644E616D65733A437573746F6D54595045")
661 .value("Custom")
662 .noMore();
663
664 asserter.rawProperty("X-FCENCODED-582D46432D4F7468657244617465733A416E6E6976657273617279")
665 .value("2016-08-02")
666 .noMore();
667
668 asserter.rawProperty("X-FCENCODED-582D46432D4F7468657244617465733A4F74686572")
669 .value("2016-08-03")
670 .noMore();
671
672 asserter.rawProperty("X-FCENCODED-582D46432D4F7468657244617465733A437573746F6D54595045")
673 .value("2016-08-04")
674 .noMore();
675
676 asserter.simpleProperty(Note.class)
677 .value("Notes line 1" + NEWLINE + "Notes line 2")
678 .noMore();
679
680 asserter.simpleProperty(Url.class)
681 .value("http://www.homepage.com")
682 .next()
683 .value("http://www.blog.com")
684 .next()
685 .value("http://www.other.com")
686 .next()
687 .value("http://www.custom.com")
688 .noMore();
689
690 asserter.address()
691 .types(AddressType.HOME)
692 .extendedAddress("HomeExtended")
693 .streetAddress("HomeStreet")
694 .locality("HomeCity")
695 .region("HomeState")
696 .postalCode("HomePostal")
697 .country("HomeCountry")
698 .next()
699 .types(AddressType.WORK)
700 .extendedAddress("WorkExtended")
701 .streetAddress("WorkStreet")
702 .locality("WorkCity")
703 .region("WorkState")
704 .postalCode("WorkPostal")
705 .country("WorkCountry")
706 .next()
707 .types(AddressType.get("OTHER"))
708 .extendedAddress("OtherExtended")
709 .streetAddress("OtherStreet")
710 .locality("OtherCity")
711 .region("OtherState")
712 .postalCode("OtherPostal")
713 .country("OtherCountry")
714 .next()
715 .types(AddressType.get("CUSTOMTYPE"))
716 .extendedAddress("CustomExtended")
717 .streetAddress("CustomStreet")
718 .locality("CustomCity")
719 .region("CustomState")
720 .postalCode("CustomPostal")
721 .country("CustomCountry")
722 .noMore();
723
724 asserter.listProperty(Nickname.class)
725 .values("NickName")
726 .noMore();
727
728 asserter.impp()
729 .param("X-SERVICE-TYPE", "GTalk")
730 .uri("xmpp:gtalk")
731 .next()
732 .param("X-SERVICE-TYPE", "Skype")
733 .uri("skype:skype")
734 .next()
735 .param("X-SERVICE-TYPE", "Yahoo")
736 .uri("ymsgr:yahoo")
737 .next()
738 .param("X-SERVICE-TYPE", "AIM")
739 .uri("aim:aim")
740 .next()
741 .param("X-SERVICE-TYPE", "Jabber")
742 .uri("xmpp:jabber")
743 .next()
744 .param("X-SERVICE-TYPE", "Other")
745 .uri("other:other")
746 .next()
747 .param("X-SERVICE-TYPE", "CustomTYPE")
748 .uri("customtype:custom")
749 .noMore();
750
751 asserter.listProperty(Categories.class)
752 .values("Tag")
753 .noMore();
754
755 asserter.simpleProperty(ProductId.class)
756 .value("ez-vcard 0.9.14-fc")
757 .noMore();
758 //@formatter:on
759
760 asserter.validate().run();
761 asserter.done();
762 }
763
764 @Test
765 public void gmailVCard() throws Throwable {
766 VCardAsserter asserter = read("John_Doe_GMAIL.vcf");
767 asserter.next(V3_0);
768
769 //@formatter:off
770 asserter.simpleProperty(FormattedName.class)
771 .value("Mr. John Richter, James Doe Sr.")
772 .noMore();
773
774 asserter.structuredName()
775 .family("Doe")
776 .given("John")
777 .additional("Richter, James")
778 .prefixes("Mr.")
779 .suffixes("Sr.")
780 .noMore();
781
782 asserter.email()
783 .types(EmailType.INTERNET, EmailType.HOME)
784 .value("[email protected]")
785 .noMore();
786
787 asserter.telephone()
788 .types(TelephoneType.CELL)
789 .text("905-555-1234")
790 .next()
791 .types(TelephoneType.HOME)
792 .text("905-666-1234")
793 .noMore();
794
795 asserter.address()
796 .extendedAddress("Crescent moon drive" + NEWLINE + "555-asd" + NEWLINE + "Nice Area, Albaney, New York 12345" + NEWLINE + "United States of America")
797 .types(AddressType.HOME)
798 .noMore();
799
800 asserter.listProperty(Organization.class)
801 .values("IBM")
802 .noMore();
803
804 asserter.simpleProperty(Title.class)
805 .value("Money Counter")
806 .noMore();
807
808 asserter.dateProperty(Birthday.class)
809 .date(LocalDate.of(1980, 3, 22))
810 .noMore();
811
812 asserter.simpleProperty(Url.class)
813 .value("http://www.ibm.com")
814 .param("TYPE", "WORK")
815 .noMore();
816
817 asserter.simpleProperty(Note.class)
818 .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")
819 .noMore();
820
821 asserter.rawProperty("X-PHONETIC-FIRST-NAME")
822 .value("Jon")
823 .noMore();
824
825 asserter.rawProperty("X-PHONETIC-LAST-NAME")
826 .value("Dow")
827 .noMore();
828
829 asserter.rawProperty("X-ABDATE")
830 .group("item1")
831 .value("1975-03-01")
832 .noMore();
833
834 asserter.rawProperty("X-ABLABEL")
835 .group("item1")
836 .value("_$!<Anniversary>!$_")
837 .next()
838 .group("item2")
839 .value("_$!<Spouse>!$_")
840 .noMore();
841
842 asserter.rawProperty("X-ABRELATEDNAMES")
843 .group("item2")
844 .value("Jenny")
845 .noMore();
846
847 VCard vcard = asserter.getVCard();
848 asserter.validate()
849 .prop(vcard.getEmails().get(0), 9) //"TYPE=WORK" not valid in vCard 3.0
850 .run();
851 //@formatter:on
852
853 asserter.done();
854 }
855
856 @Test
857 public void gmailList() throws Throwable {
858 VCardAsserter asserter = read("gmail-list.vcf");
859
860 {
861 asserter.next(V3_0);
862
863 //@formatter:off
864 asserter.simpleProperty(FormattedName.class)
865 .value("Arnold Smith")
866 .noMore();
867
868 asserter.structuredName()
869 .family("Smith")
870 .given("Arnold")
871 .noMore();
872
873 asserter.email()
874 .types(EmailType.INTERNET)
875 .value("[email protected]")
876 .noMore();
877 //@formatter:on
878
879 asserter.validate().run();
880 }
881
882 {
883 asserter.next(V3_0);
884
885 //@formatter:off
886 asserter.simpleProperty(FormattedName.class)
887 .value("Chris Beatle")
888 .noMore();
889
890 asserter.structuredName()
891 .family("Beatle")
892 .given("Chris")
893 .noMore();
894
895 asserter.email()
896 .types(EmailType.INTERNET)
897 .value("[email protected]")
898 .noMore();
899 //@formatter:on
900
901 asserter.validate().run();
902 }
903
904 {
905 asserter.next(V3_0);
906
907 //@formatter:off
908 asserter.simpleProperty(FormattedName.class)
909 .value("Doug White")
910 .noMore();
911
912 asserter.structuredName()
913 .family("White")
914 .given("Doug")
915 .noMore();
916
917 asserter.email()
918 .types(EmailType.INTERNET)
919 .value("[email protected]")
920 .noMore();
921 //@formatter:on
922
923 asserter.validate().run();
924 }
925
926 asserter.done();
927 }
928
929 @Test
930 public void gmailSingle() throws Throwable {
931 VCardAsserter asserter = read("gmail-single.vcf");
932 asserter.next(V3_0);
933
934 //@formatter:off
935 asserter.simpleProperty(FormattedName.class)
936 .value("Greg Dartmouth")
937 .noMore();
938
939 asserter.structuredName()
940 .family("Dartmouth")
941 .given("Greg")
942 .noMore();
943
944 asserter.listProperty(Nickname.class)
945 .values("Gman")
946 .noMore();
947
948 asserter.email()
949 .types(EmailType.INTERNET)
950 .value("[email protected]")
951 .noMore();
952
953 asserter.telephone()
954 .types(TelephoneType.CELL)
955 .text("555 555 1111")
956 .next()
957 .group("item1")
958 .text("555 555 2222")
959 .noMore();
960
961 asserter.address()
962 .streetAddress("123 Home St" + NEWLINE + "Home City, HM 12345")
963 .types(AddressType.HOME)
964 .next()
965 .group("item2")
966 .streetAddress("321 Custom St")
967 .locality("Custom City")
968 .region("TX")
969 .postalCode("98765")
970 .country("USA")
971 .noMore();
972
973 asserter.listProperty(Organization.class)
974 .values("TheCompany")
975 .noMore();
976
977 asserter.simpleProperty(Title.class)
978 .value("TheJobTitle")
979 .noMore();
980
981 asserter.dateProperty(Birthday.class)
982 .date(LocalDate.of(1960, 9, 10))
983 .noMore();
984
985 asserter.simpleProperty(Url.class)
986 .group("item3")
987 .value("http://TheProfile.com")
988 .noMore();
989
990 asserter.simpleProperty(Note.class)
991 .value("This is GMail's note field." + NEWLINE + "It should be added as a NOTE type." + NEWLINE + "ACustomField: CustomField")
992 .noMore();
993
994 asserter.rawProperty("X-PHONETIC-FIRST-NAME")
995 .value("Grregg")
996 .noMore();
997
998 asserter.rawProperty("X-PHONETIC-LAST-NAME")
999 .value("Dart-mowth")
1000 .noMore();
1001
1002 asserter.rawProperty("X-ICQ")
1003 .value("123456789")
1004 .noMore();
1005
1006 asserter.rawProperty("X-ABLABEL")
1007 .group("item1")
1008 .value("GRAND_CENTRAL")
1009 .next()
1010 .group("item2")
1011 .value("CustomAdrType")
1012 .next()
1013 .group("item3")
1014 .value("PROFILE")
1015 .next()
1016 .group("item4")
1017 .value("_$!<Anniversary>!$_")
1018 .next()
1019 .group("item5")
1020 .value("_$!<Spouse>!$_")
1021 .next()
1022 .group("item6")
1023 .value("CustomRelationship")
1024 .noMore();
1025
1026 asserter.rawProperty("X-ABDATE")
1027 .group("item4")
1028 .value("1970-06-02")
1029 .noMore();
1030
1031 asserter.rawProperty("X-ABRELATEDNAMES")
1032 .group("item5")
1033 .value("MySpouse")
1034 .next()
1035 .group("item6")
1036 .value("MyCustom")
1037 .noMore();
1038 //@formatter:on
1039
1040 asserter.validate().run();
1041 asserter.done();
1042 }
1043
1044 /**
1045 * File generated on 5/7/2016.
1046 */
1047 @Test
1048 public void gmailSingle2() throws Throwable {
1049 VCardAsserter asserter = read("gmail-single2.vcf");
1050 asserter.next(V3_0);
1051
1052 //@formatter:off
1053 asserter.simpleProperty(FormattedName.class)
1054 .value("VCard Test")
1055 .noMore();
1056
1057 asserter.structuredName()
1058 .family("Test")
1059 .given("VCard")
1060 .noMore();
1061
1062 asserter.listProperty(Nickname.class)
1063 .values("TheNickname")
1064 .noMore();
1065
1066 asserter.email()
1067 .types(EmailType.INTERNET)
1068 .value("[email protected]")
1069 .next()
1070 .types(EmailType.INTERNET, EmailType.HOME)
1071 .value("[email protected]")
1072 .next()
1073 .types(EmailType.INTERNET, EmailType.WORK)
1074 .value("[email protected]")
1075 .next()
1076 .types(EmailType.INTERNET)
1077 .value("[email protected]")
1078 .next()
1079 .types(EmailType.INTERNET)
1080 .group("item1")
1081 .value("[email protected]")
1082 .noMore();
1083
1084 asserter.telephone()
1085 .text("5555551111")
1086 .next()
1087 .types(TelephoneType.HOME)
1088 .text("5555551112")
1089 .next()
1090 .types(TelephoneType.WORK)
1091 .text("5555551113")
1092 .next()
1093 .text("5555551114")
1094 .next()
1095 .types(TelephoneType.CELL)
1096 .text("5555551115")
1097 .next()
1098 .types(TelephoneType.get("MAIN"))
1099 .text("5555551116")
1100 .next()
1101 .types(TelephoneType.HOME, TelephoneType.FAX)
1102 .text("5555551117")
1103 .next()
1104 .types(TelephoneType.WORK, TelephoneType.FAX)
1105 .text("5555551118")
1106 .next()
1107 .group("item2")
1108 .text("5555551119")
1109 .next()
1110 .types(TelephoneType.PAGER)
1111 .text("5555551120")
1112 .next()
1113 .group("item3")
1114 .text("5555551121")
1115 .noMore();
1116
1117 asserter.address()
1118 .streetAddress("111 Main St")
1119 .locality("NY")
1120 .region("New York")
1121 .postalCode("10011")
1122 .next()
1123 .types(AddressType.HOME)
1124 .streetAddress("112 Main St")
1125 .locality("NY")
1126 .region("New York")
1127 .postalCode("10011")
1128 .next()
1129 .types(AddressType.WORK)
1130 .streetAddress("113 Main St")
1131 .locality("NY")
1132 .region("New York")
1133 .postalCode("10011")
1134 .next()
1135 .streetAddress("114 Main St")
1136 .locality("NY")
1137 .region("New York")
1138 .postalCode("10011")
1139 .next()
1140 .group("item4")
1141 .streetAddress("115 Main St")
1142 .locality("NY")
1143 .region("New York")
1144 .postalCode("10011")
1145 .noMore();
1146
1147 asserter.listProperty(Organization.class)
1148 .values("TheCompany")
1149 .noMore();
1150
1151 asserter.simpleProperty(Title.class)
1152 .value("TheJobTitle")
1153 .noMore();
1154
1155 asserter.dateProperty(Birthday.class)
1156 .date(LocalDate.of(1912, 6, 23))
1157 .noMore();
1158
1159 asserter.simpleProperty(Url.class)
1160 .value("http://www.example1.com")
1161 .next()
1162 .group("item5")
1163 .value("http://www.example2.com")
1164 .next()
1165 .group("item6")
1166 .value("http://www.example3.com")
1167 .next()
1168 .group("item7")
1169 .value("http://www.example4.com")
1170 .next()
1171 .param("TYPE", "WORK")
1172 .value("http://www.example5.com")
1173 .next()
1174 .group("item8")
1175 .value("http://www.example6.com")
1176 .noMore();
1177
1178 asserter.simpleProperty(Note.class)
1179 .value("note line 1" + NEWLINE + "note line 2" + NEWLINE + "CustomField: field value")
1180 .noMore();
1181
1182 asserter.rawProperty("X-PHONETIC-FIRST-NAME")
1183 .value("ThePhoneticFirstName")
1184 .noMore();
1185 asserter.rawProperty("X-PHONETIC-LAST-NAME")
1186 .value("ThePhoneticLastName")
1187 .noMore();
1188
1189 asserter.rawProperty("X-ABLabel")
1190 .group("item1")
1191 .value("CustomEmailCategory")
1192 .next()
1193 .group("item2")
1194 .value("GRAND_CENTRAL")
1195 .next()
1196 .group("item3")
1197 .value("CustomePhoneCategory")
1198 .next()
1199 .group("item4")
1200 .value("CustomAddressCategory")
1201 .next()
1202 .group("item5")
1203 .value("PROFILE")
1204 .next()
1205 .group("item6")
1206 .value("BLOG")
1207 .next()
1208 .group("item7")
1209 .value("_$!<HomePage>!$_")
1210 .next()
1211 .group("item8")
1212 .value("CustomWebsiteCategory")
1213 .next()
1214 .group("item9")
1215 .value("_$!<Anniversary>!$_")
1216 .next()
1217 .group("item10")
1218 .value("CustomDateCategory")
1219 .next()
1220 .group("item11")
1221 .value("_$!<Spouse>!$_")
1222 .next()
1223 .group("item12")
1224 .value("_$!<Child>!$_")
1225 .next()
1226 .group("item13")
1227 .value("_$!<Mother>!$_")
1228 .next()
1229 .group("item14")
1230 .value("_$!<Father>!$_")
1231 .next()
1232 .group("item15")
1233 .value("_$!<Parent>!$_")
1234 .next()
1235 .group("item16")
1236 .value("_$!<Brother>!$_")
1237 .next()
1238 .group("item17")
1239 .value("_$!<Sister>!$_")
1240 .next()
1241 .group("item18")
1242 .value("_$!<Friend>!$_")
1243 .next()
1244 .group("item19")
1245 .value("RELATIVE")
1246 .next()
1247 .group("item20")
1248 .value("_$!<Manager>!$_")
1249 .next()
1250 .group("item21")
1251 .value("_$!<Assistant>!$_")
1252 .next()
1253 .group("item22")
1254 .value("REFERRED_BY")
1255 .next()
1256 .group("item23")
1257 .value("_$!<Partner>!$_")
1258 .next()
1259 .group("item24")
1260 .value("DOMESTIC_PARTNER")
1261 .next()
1262 .group("item25")
1263 .value("CustomRelationCategory")
1264 .noMore();
1265
1266 asserter.rawProperty("X-GTALK")
1267 .value("IM2")
1268 .noMore();
1269 asserter.rawProperty("X-AIM")
1270 .value("IM3")
1271 .noMore();
1272 asserter.rawProperty("X-YAHOO")
1273 .value("IM4")
1274 .noMore();
1275 asserter.rawProperty("X-SKYPE")
1276 .value("IM5")
1277 .noMore();
1278 asserter.rawProperty("X-QQ")
1279 .value("IM6")
1280 .noMore();
1281 asserter.rawProperty("X-MSN")
1282 .value("IM7")
1283 .noMore();
1284 asserter.rawProperty("X-ICQ")
1285 .value("IM8")
1286 .noMore();
1287 asserter.rawProperty("X-JABBER")
1288 .value("IM9")
1289 .noMore();
1290
1291 asserter.rawProperty("X-ABDATE")
1292 .group("item9")
1293 .value("1930-03-20")
1294 .next()
1295 .value("1776-07-04")
1296 .next()
1297 .group("item10")
1298 .value("2000-09-12")
1299 .noMore();
1300
1301 asserter.rawProperty("X-ABRELATEDNAMES")
1302 .value("Name1")
1303 .next()
1304 .group("item11")
1305 .value("Name2")
1306 .next()
1307 .group("item12")
1308 .value("Name3")
1309 .next()
1310 .group("item13")
1311 .value("Name4")
1312 .next()
1313 .group("item14")
1314 .value("Name5")
1315 .next()
1316 .group("item15")
1317 .value("Name6")
1318 .next()
1319 .group("item16")
1320 .value("Name7")
1321 .next()
1322 .group("item17")
1323 .value("Name8")
1324 .next()
1325 .group("item18")
1326 .value("Name9")
1327 .next()
1328 .group("item19")
1329 .value("Name10")
1330 .next()
1331 .group("item20")
1332 .value("Name11")
1333 .next()
1334 .group("item21")
1335 .value("Name12")
1336 .next()
1337 .group("item22")
1338 .value("Name13")
1339 .next()
1340 .group("item23")
1341 .value("Name14")
1342 .next()
1343 .group("item24")
1344 .value("Name15")
1345 .next()
1346 .group("item25")
1347 .value("Name16")
1348 .noMore();
1349
1350 VCard vcard = asserter.getVCard();
1351 asserter.validate()
1352 .prop(vcard.getEmails().get(1), 9) //"TYPE=HOME" not valid in vCard 3.0
1353 .prop(vcard.getEmails().get(2), 9) //"TYPE=WORK" not valid in vCard 3.0
1354 .run();
1355 //@formatter:on
1356
1357 asserter.done();
1358 }
1359
1360 @Test
1361 public void iPhoneVCard() throws Throwable {
1362 VCardAsserter asserter = read("John_Doe_IPHONE.vcf");
1363 asserter.next(V3_0);
1364
1365 //@formatter:off
1366 asserter.simpleProperty(ProductId.class)
1367 .value("-//Apple Inc.//iOS 5.0.1//EN")
1368 .noMore();
1369
1370 asserter.structuredName()
1371 .family("Doe")
1372 .given("John")
1373 .additional("Richter", "James")
1374 .prefixes("Mr.")
1375 .suffixes("Sr.")
1376 .noMore();
1377
1378 asserter.simpleProperty(FormattedName.class)
1379 .value("Mr. John Richter James Doe Sr.")
1380 .noMore();
1381
1382 asserter.listProperty(Nickname.class)
1383 .values("Johny")
1384 .noMore();
1385
1386 asserter.listProperty(Organization.class)
1387 .values("IBM", "Accounting")
1388 .noMore();
1389
1390 asserter.simpleProperty(Title.class)
1391 .value("Money Counter")
1392 .noMore();
1393
1394 asserter.email()
1395 .group("item1")
1396 .types(EmailType.INTERNET, EmailType.PREF)
1397 .value("[email protected]")
1398 .noMore();
1399
1400 asserter.telephone()
1401 .types(TelephoneType.CELL, TelephoneType.VOICE, TelephoneType.PREF)
1402 .text("905-555-1234")
1403 .next()
1404 .types(TelephoneType.HOME, TelephoneType.VOICE)
1405 .text("905-666-1234")
1406 .next()
1407 .types(TelephoneType.WORK, TelephoneType.VOICE)
1408 .text("905-777-1234")
1409 .next()
1410 .types(TelephoneType.HOME, TelephoneType.FAX)
1411 .text("905-888-1234")
1412 .next()
1413 .types(TelephoneType.WORK, TelephoneType.FAX)
1414 .text("905-999-1234")
1415 .next()
1416 .types(TelephoneType.PAGER)
1417 .text("905-111-1234")
1418 .next()
1419 .group("item2")
1420 .text("905-222-1234")
1421 .noMore();
1422
1423 asserter.address()
1424 .group("item3")
1425 .streetAddress("Silicon Alley 5", "")
1426 .locality("New York")
1427 .region("New York")
1428 .postalCode("12345")
1429 .country("United States of America")
1430 .types(AddressType.HOME, AddressType.PREF)
1431 .next()
1432 .group("item4")
1433 .streetAddress("Street4" + NEWLINE + "Building 6" + NEWLINE + "Floor 8")
1434 .locality("New York")
1435 .postalCode("12345")
1436 .country("USA")
1437 .types(AddressType.WORK)
1438 .noMore();
1439
1440 asserter.simpleProperty(Url.class)
1441 .group("item5")
1442 .value("http://www.ibm.com")
1443 .param("TYPE", "pref")
1444 .noMore();
1445
1446 asserter.dateProperty(Birthday.class)
1447 .date(LocalDate.of(2012, 6, 6))
1448 .noMore();
1449
1450 asserter.binaryProperty(Photo.class)
1451 .param("ENCODING", "b")
1452 .param("TYPE", "JPEG")
1453 .contentType(ImageType.JPEG)
1454 .dataLength(32531)
1455 .noMore();
1456
1457 asserter.rawProperty("X-ABLABEL")
1458 .group("item2")
1459 .value("_$!<AssistantPhone>!$_")
1460 .next()
1461 .group("item5")
1462 .value("_$!<HomePage>!$_")
1463 .noMore();
1464
1465 asserter.rawProperty("X-ABADR")
1466 .group("item3")
1467 .value("Silicon Alley")
1468 .next()
1469 .group("item4")
1470 .value("Street 4, Building 6,\\n Floor 8\\nNew York\\nUSA")
1471 .noMore();
1472 //@formatter:on
1473
1474 asserter.validate().run();
1475 asserter.done();
1476 }
1477
1478 @Test
1479 public void lotusNotesVCard() throws Throwable {
1480 VCardAsserter asserter = read("John_Doe_LOTUS_NOTES.vcf");
1481 asserter.next(V3_0);
1482
1483 //@formatter:off
1484 asserter.simpleProperty(ProductId.class)
1485 .value("-//Apple Inc.//Address Book 6.1//EN")
1486 .noMore();
1487
1488 asserter.structuredName()
1489 .family("Doe")
1490 .given("John")
1491 .additional("Johny")
1492 .prefixes("Mr.")
1493 .suffixes("I")
1494 .noMore();
1495
1496 asserter.simpleProperty(FormattedName.class)
1497 .value("Mr. Doe John I Johny")
1498 .noMore();
1499
1500 asserter.listProperty(Nickname.class)
1501 .values("Johny,JayJay")
1502 .noMore();
1503
1504 asserter.listProperty(Organization.class)
1505 .values("IBM", "SUN")
1506 .noMore();
1507
1508 asserter.simpleProperty(Title.class)
1509 .value("Generic Accountant")
1510 .noMore();
1511
1512 asserter.email()
1513 .types(EmailType.INTERNET, EmailType.WORK, EmailType.PREF)
1514 .value("[email protected]")
1515 .next()
1516 .types(EmailType.INTERNET, EmailType.WORK)
1517 .value("[email protected]")
1518 .noMore();
1519
1520 asserter.telephone()
1521 .types(TelephoneType.CELL, TelephoneType.VOICE, TelephoneType.PREF)
1522 .text("+1 (212) 204-34456")
1523 .next()
1524 .types(TelephoneType.WORK, TelephoneType.FAX)
1525 .text("00-1-212-555-7777")
1526 .noMore();
1527
1528 asserter.address()
1529 .group("item1")
1530 .streetAddress("25334" + NEWLINE + "South cresent drive, Building 5, 3rd floo r")
1531 .locality("New York")
1532 .region("New York")
1533 .postalCode("NYC887")
1534 .country("U.S.A.")
1535 .types(AddressType.HOME, AddressType.PREF)
1536 .noMore();
1537
1538 asserter.simpleProperty(Note.class)
1539 .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.")
1540 .noMore();
1541
1542 asserter.simpleProperty(Url.class)
1543 .group("item2")
1544 .value("http://www.sun.com")
1545 .param("TYPE", "pref")
1546 .noMore();
1547
1548 asserter.dateProperty(Birthday.class)
1549 .date(LocalDate.of(1980, 5, 21))
1550 .noMore();
1551
1552 asserter.binaryProperty(Photo.class)
1553 .param("ENCODING", "b")
1554 .param("TYPE", "JPEG")
1555 .contentType(ImageType.JPEG)
1556 .dataLength(7957)
1557 .noMore();
1558
1559 asserter.simpleProperty(Uid.class)
1560 .value("0e7602cc-443e-4b82-b4b1-90f62f99a199")
1561 .noMore();
1562
1563 asserter.geo()
1564 .latitude(-2.6)
1565 .longitude(3.4)
1566 .noMore();
1567
1568 asserter.simpleProperty(Classification.class)
1569 .value("Public")
1570 .noMore();
1571
1572 asserter.simpleProperty(Profile.class)
1573 .value("VCard")
1574 .noMore();
1575
1576 asserter.timezone()
1577 .offset(ZoneOffset.ofHours(1))
1578 .noMore();
1579
1580 asserter.simpleProperty(Label.class)
1581 .value("John Doe" + NEWLINE + "New York, NewYork," + NEWLINE + "South Crecent Dr ive," + NEWLINE + "Building 5, floor 3," + NEWLINE + "USA")
1582 .param("TYPE", "HOME")
1583 .param("TYPE", "PARCEL")
1584 .param("TYPE", "PREF")
1585 .noMore();
1586
1587 asserter.simpleProperty(SortString.class)
1588 .value("JOHN")
1589 .noMore();
1590
1591 asserter.simpleProperty(Role.class)
1592 .value("Counting Money")
1593 .noMore();
1594
1595 asserter.simpleProperty(Source.class)
1596 .value("Whatever")
1597 .noMore();
1598
1599 asserter.simpleProperty(Mailer.class)
1600 .value("Mozilla Thunderbird")
1601 .noMore();
1602
1603 asserter.simpleProperty(SourceDisplayText.class)
1604 .value("VCard for John Doe")
1605 .noMore();
1606
1607 asserter.rawProperty("X-ABLABEL")
1608 .group("item2")
1609 .value("_$!<HomePage>!$_")
1610 .noMore();
1611
1612 asserter.rawProperty("X-ABUID")
1613 .value("0E7602CC-443E-4B82-B4B1-90F62F99A199:ABPerson")
1614 .noMore();
1615
1616 asserter.rawProperty("X-GENERATOR")
1617 .value("Cardme Generator")
1618 .noMore();
1619
1620 asserter.rawProperty("X-LONG-STRING")
1621 .value("12345678901234567890123456789012345678901234567890123456789012 34567890123456789012345678901234567890")
1622 .noMore();
1623
1624 VCard vcard = asserter.getVCard();
1625 asserter.validate()
1626 .prop(vcard.getEmails().get(0), 9) //"TYPE=WORK" not valid in vCard 3.0
1627 .prop(vcard.getEmails().get(1), 9) //"TYPE=WORK" not valid in vCard 3.0
1628 .run();
1629 //@formatter:on
1630
1631 asserter.done();
1632 }
1633
1634 @Test
1635 public void msOutlookVCard() throws Throwable {
1636 VCardAsserter asserter = read("John_Doe_MS_OUTLOOK.vcf");
1637 asserter.next(V2_1);
1638
1639 //@formatter:off
1640 asserter.structuredName()
1641 .family("Doe")
1642 .given("John")
1643 .additional("Richter,James")
1644 .prefixes("Mr.")
1645 .suffixes("Sr.")
1646 .param(VCardParameters.LANGUAGE, "en-us")
1647 .noMore();
1648
1649 asserter.simpleProperty(FormattedName.class)
1650 .value("Mr. John Richter James Doe Sr.")
1651 .noMore();
1652
1653 asserter.listProperty(Nickname.class)
1654 .values("Johny")
1655 .noMore();
1656
1657 asserter.listProperty(Organization.class)
1658 .values("IBM", "Accounting")
1659 .noMore();
1660
1661 asserter.simpleProperty(Title.class)
1662 .value("Money Counter")
1663 .noMore();
1664
1665 asserter.simpleProperty(Note.class)
1666 .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.")
1667 .noMore();
1668
1669 asserter.telephone()
1670 .types(TelephoneType.WORK, TelephoneType.VOICE)
1671 .text("(905) 555-1234")
1672 .next()
1673 .types(TelephoneType.HOME, TelephoneType.VOICE)
1674 .text("(905) 666-1234")
1675 .noMore();
1676
1677 asserter.address()
1678 .streetAddress("Cresent moon drive")
1679 .locality("Albaney")
1680 .region("New York")
1681 .postalCode("12345")
1682 .country("United States of America")
1683 .label("Cresent moon drive\r\nAlbaney, New York 12345")
1684 .types(AddressType.WORK, AddressType.PREF)
1685 .next()
1686 .streetAddress("Silicon Alley 5,")
1687 .locality("New York")
1688 .region("New York")
1689 .postalCode("12345")
1690 .country("United States of America")
1691 .label("Silicon Alley 5,\r\nNew York, New York 12345")
1692 .types(AddressType.HOME)
1693 .noMore();
1694
1695 asserter.simpleProperty(Url.class)
1696 .value("http://www.ibm.com")
1697 .param("TYPE", "WORK")
1698 .noMore();
1699
1700 asserter.simpleProperty(Role.class)
1701 .value("Counting Money")
1702 .noMore();
1703
1704 asserter.dateProperty(Birthday.class)
1705 .date(LocalDate.of(1980, 3, 22))
1706 .noMore();
1707
1708 asserter.email()
1709 .types(EmailType.PREF, EmailType.INTERNET)
1710 .value("[email protected]")
1711 .noMore();
1712
1713 asserter.binaryProperty(Photo.class)
1714 .param("ENCODING", "BASE64")
1715 .param("TYPE", "JPEG")
1716 .contentType(ImageType.JPEG)
1717 .dataLength(860)
1718 .noMore();
1719
1720 asserter.simpleProperty(Revision.class)
1721 .value(LocalDateTime.of(2012, 3, 5, 13, 19, 33).toInstant(ZoneOffset.UTC))
1722 .noMore();
1723
1724 asserter.rawProperty("X-MS-OL-DEFAULT-POSTAL-ADDRESS")
1725 .value("2")
1726 .noMore();
1727
1728 asserter.rawProperty("X-MS-ANNIVERSARY")
1729 .value("20110113")
1730 .noMore();
1731
1732 asserter.rawProperty("X-MS-IMADDRESS")
1733 .value("[email protected]")
1734 .noMore();
1735
1736 asserter.rawProperty("X-MS-OL-DESIGN")
1737 .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>")
1738 .param("CHARSET", "utf-8")
1739 .noMore();
1740
1741 asserter.rawProperty("X-MS-MANAGER")
1742 .value("Big Blue")
1743 .noMore();
1744
1745 asserter.rawProperty("X-MS-ASSISTANT")
1746 .value("Jenny")
1747 .noMore();
1748
1749 VCard vcard = asserter.getVCard();
1750 asserter.validate()
1751 .prop(vcard.getNickname(), 2) //not supported in 2.1
1752 .run();
1753 //@formatter:on
1754
1755 asserter.done();
1756 }
1757
1758 @Test
1759 public void outlook2007VCard() throws Throwable {
1760 VCardAsserter asserter = read("outlook-2007.vcf");
1761 asserter.next(V2_1);
1762
1763 //@formatter:off
1764 asserter.structuredName()
1765 .family("Angstadt")
1766 .given("Michael")
1767 .prefixes("Mr.")
1768 .suffixes("Jr.")
1769 .param(VCardParameters.LANGUAGE, "en-us")
1770 .noMore();
1771
1772 asserter.simpleProperty(FormattedName.class)
1773 .value("Mr. Michael Angstadt Jr.")
1774 .noMore();
1775
1776 asserter.listProperty(Nickname.class)
1777 .values("Mike")
1778 .noMore();
1779
1780 asserter.listProperty(Organization.class)
1781 .values("TheCompany", "TheDepartment")
1782 .noMore();
1783
1784 asserter.simpleProperty(Title.class)
1785 .value("TheJobTitle")
1786 .noMore();
1787
1788 asserter.simpleProperty(Note.class)
1789 .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")
1790 .param("ENCODING", "QUOTED-PRINTABLE")
1791 .param("CHARSET", "us-ascii")
1792 .noMore();
1793
1794 asserter.telephone()
1795 .types(TelephoneType.WORK, TelephoneType.VOICE)
1796 .text("(111) 555-1111")
1797 .next()
1798 .types(TelephoneType.HOME, TelephoneType.VOICE)
1799 .text("(111) 555-2222")
1800 .next()
1801 .types(TelephoneType.CELL, TelephoneType.VOICE)
1802 .text("(111) 555-4444")
1803 .next()
1804 .types(TelephoneType.WORK, TelephoneType.FAX)
1805 .text("(111) 555-3333")
1806 .noMore();
1807
1808 asserter.address()
1809 .extendedAddress("TheOffice")
1810 .streetAddress("222 Broadway")
1811 .locality("New York")
1812 .region("NY")
1813 .postalCode("99999")
1814 .country("USA")
1815 .label("222 Broadway\r\nNew York, NY 99999\r\nUSA")
1816 .types(AddressType.WORK, AddressType.PREF)
1817 .noMore();
1818
1819 asserter.simpleProperty(Url.class)
1820 .value("http://mikeangstadt.name")
1821 .param("TYPE", "HOME")
1822 .next()
1823 .value("http://mikeangstadt.name")
1824 .param("TYPE", "WORK")
1825 .noMore();
1826
1827 asserter.simpleProperty(Role.class)
1828 .value("TheProfession")
1829 .noMore();
1830
1831 asserter.dateProperty(Birthday.class)
1832 .date(LocalDate.of(1922, 3, 10))
1833 .noMore();
1834
1835 asserter.binaryProperty(Key.class)
1836 .param("ENCODING", "BASE64")
1837 .param("TYPE", "X509")
1838 .contentType(KeyType.X509)
1839 .dataLength(514)
1840 .noMore();
1841
1842 asserter.email()
1843 .types(EmailType.PREF, EmailType.INTERNET)
1844 .value("[email protected]")
1845 .noMore();
1846
1847 asserter.binaryProperty(Photo.class)
1848 .param("ENCODING", "BASE64")
1849 .param("TYPE", "JPEG")
1850 .contentType(ImageType.JPEG)
1851 .dataLength(2324)
1852 .noMore();
1853
1854 asserter.simpleProperty(FreeBusyUrl.class)
1855 .value("http://website.com/mycal")
1856 .noMore();
1857
1858 asserter.simpleProperty(Revision.class)
1859 .value(LocalDateTime.of(2012, 8, 1, 18, 46, 31).toInstant(ZoneOffset.UTC))
1860 .noMore();
1861
1862 asserter.rawProperty("X-MS-TEL")
1863 .value("(111) 555-4444")
1864 .param("TYPE", "VOICE")
1865 .param("TYPE", "CALLBACK")
1866 .noMore();
1867
1868 asserter.rawProperty("X-MS-OL-DEFAULT-POSTAL-ADDRESS")
1869 .value("2")
1870 .noMore();
1871
1872 asserter.rawProperty("X-MS-ANNIVERSARY")
1873 .value("20120801")
1874 .noMore();
1875
1876 asserter.rawProperty("X-MS-IMADDRESS")
1877 .value("[email protected]")
1878 .noMore();
1879
1880 asserter.rawProperty("X-MS-OL-DESIGN")
1881 .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>")
1882 .param("CHARSET", "utf-8")
1883 .noMore();
1884
1885 asserter.rawProperty("X-MS-MANAGER")
1886 .value("TheManagerName")
1887 .noMore();
1888
1889 asserter.rawProperty("X-MS-ASSISTANT")
1890 .value("TheAssistantName")
1891 .noMore();
1892
1893 asserter.rawProperty("X-MS-SPOUSE")
1894 .value("TheSpouse")
1895 .noMore();
1896
1897 VCard vcard = asserter.getVCard();
1898 asserter.validate()
1899 .prop(vcard.getNickname(), 2) //not supported in 2.1
1900 .prop(vcard.getFbUrls().get(0), 2) //not supported in 2.1
1901 .run();
1902 //@formatter:on
1903
1904 asserter.done();
1905 }
1906
1907 @Test
1908 public void macAddressBookVCard() throws Throwable {
1909 VCardAsserter asserter = read("John_Doe_MAC_ADDRESS_BOOK.vcf");
1910 asserter.next(V3_0);
1911
1912 //@formatter:off
1913 asserter.structuredName()
1914 .family("Doe")
1915 .given("John")
1916 .additional("Richter,James")
1917 .prefixes("Mr.")
1918 .suffixes("Sr.")
1919 .noMore();
1920
1921 asserter.simpleProperty(FormattedName.class)
1922 .value("Mr. John Richter,James Doe Sr.")
1923 .noMore();
1924
1925 asserter.listProperty(Nickname.class)
1926 .values("Johny")
1927 .noMore();
1928
1929 asserter.listProperty(Organization.class)
1930 .values("IBM", "Accounting")
1931 .noMore();
1932
1933 asserter.simpleProperty(Title.class)
1934 .value("Money Counter")
1935 .noMore();
1936
1937 asserter.email()
1938 .types(EmailType.INTERNET, EmailType.WORK, EmailType.PREF)
1939 .value("[email protected]")
1940 .noMore();
1941
1942 asserter.telephone()
1943 .types(TelephoneType.WORK, TelephoneType.PREF)
1944 .text("905-777-1234")
1945 .next()
1946 .types(TelephoneType.HOME)
1947 .text("905-666-1234")
1948 .next()
1949 .types(TelephoneType.CELL)
1950 .text("905-555-1234")
1951 .next()
1952 .types(TelephoneType.HOME, TelephoneType.FAX)
1953 .text("905-888-1234")
1954 .next()
1955 .types(TelephoneType.WORK,TelephoneType.FAX)
1956 .text("905-999-1234")
1957 .next()
1958 .types(TelephoneType.PAGER)
1959 .text("905-111-1234")
1960 .next()
1961 .group("item1")
1962 .text("905-222-1234")
1963 .noMore();
1964
1965 asserter.address()
1966 .group("item2")
1967 .streetAddress("Silicon Alley 5,")
1968 .locality("New York")
1969 .region("New York")
1970 .postalCode("12345")
1971 .country("United States of America")
1972 .types(AddressType.HOME, AddressType.PREF)
1973 .next()
1974 .group("item3")
1975 .streetAddress("Street4" + NEWLINE + "Building 6" + NEWLINE + "Floor 8")
1976 .locality("New York")
1977 .postalCode("12345")
1978 .country("USA")
1979 .types(AddressType.WORK)
1980 .noMore();
1981
1982 asserter.simpleProperty(Note.class)
1983 .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")
1984 .noMore();
1985
1986 asserter.simpleProperty(Url.class)
1987 .group("item4")
1988 .value("http://www.ibm.com")
1989 .param("TYPE", "pref")
1990 .noMore();
1991
1992 asserter.dateProperty(Birthday.class)
1993 .date(LocalDate.of(2012, 6, 6))
1994 .noMore();
1995
1996 asserter.binaryProperty(Photo.class)
1997 .param("ENCODING", "BASE64")
1998 .dataLength(18242)
1999 .noMore();
2000
2001 asserter.rawProperty("X-PHONETIC-FIRST-NAME")
2002 .value("Jon")
2003 .noMore();
2004
2005 asserter.rawProperty("X-PHONETIC-LAST-NAME")
2006 .value("Dow")
2007 .noMore();
2008
2009 asserter.rawProperty("X-ABLABEL")
2010 .group("item1")
2011 .value("AssistantPhone")
2012 .next()
2013 .group("item4")
2014 .value("_$!<HomePage>!$_")
2015 .next()
2016 .group("item5")
2017 .value("Spouse")
2018 .noMore();
2019
2020 asserter.rawProperty("X-ABADR")
2021 .group("item2")
2022 .value("Silicon Alley")
2023 .next()
2024 .group("item3")
2025 .value("Street 4, Building 6,\\nFloor 8\\nNew York\\nUSA")
2026 .noMore();
2027
2028 asserter.rawProperty("X-ABRELATEDNAMES")
2029 .group("item5")
2030 .value("Jenny")
2031 .param("TYPE", "pref")
2032 .noMore();
2033
2034 asserter.rawProperty("X-ABUID")
2035 .value("6B29A774-D124-4822-B8D0-2780EC117F60\\:ABPerson")
2036 .noMore();
2037
2038 VCard vcard = asserter.getVCard();
2039 asserter.validate()
2040 .prop(vcard.getEmails().get(0), 9) //"TYPE=WORK" not valid in vCard 3.0
2041 .prop(vcard.getPhotos().get(0), 4) //"BASE64" not valid parameter
2042 .run();
2043 //@formatter:on
2044
2045 asserter.done();
2046 }
2047
2048 @Test
2049 public void outlook2003VCard() throws Throwable {
2050 VCardAsserter asserter = read("outlook-2003.vcf");
2051 asserter.next(V2_1);
2052
2053 //@formatter:off
2054 asserter.structuredName()
2055 .family("Doe")
2056 .given("John")
2057 .prefixes("Mr.")
2058 .suffixes("III")
2059 .noMore();
2060
2061 asserter.simpleProperty(FormattedName.class)
2062 .value("John Doe III")
2063 .noMore();
2064
2065 asserter.listProperty(Nickname.class)
2066 .values("Joey")
2067 .noMore();
2068
2069 asserter.listProperty(Organization.class)
2070 .values("Company, The", "TheDepartment")
2071 .noMore();
2072
2073 asserter.simpleProperty(Title.class)
2074 .value("The Job Title")
2075 .noMore();
2076
2077 asserter.simpleProperty(Note.class)
2078 .value("This is the note field!!\r\nSecond line\r\n\r\nThird line is empty\r\n")
2079 .param("ENCODING", "QUOTED-PRINTABLE")
2080 .noMore();
2081
2082 asserter.telephone()
2083 .types(TelephoneType.WORK, TelephoneType.VOICE)
2084 .text("BusinessPhone")
2085 .next()
2086 .types(TelephoneType.HOME, TelephoneType.VOICE)
2087 .text("HomePhone")
2088 .next()
2089 .types(TelephoneType.CELL, TelephoneType.VOICE)
2090 .text("MobilePhone")
2091 .next()
2092 .types(TelephoneType.WORK, TelephoneType.FAX)
2093 .text("BusinessFaxPhone")
2094 .noMore();
2095
2096 asserter.address()
2097 .extendedAddress("TheOffice")
2098 .streetAddress("123 Main St")
2099 .locality("Austin")
2100 .region("TX")
2101 .postalCode("12345")
2102 .country("United States of America")
2103 .label("TheOffice\r\n123 Main St\r\nAustin, TX 12345\r\nUnited States of America")
2104 .types(AddressType.WORK)
2105 .noMore();
2106
2107 asserter.simpleProperty(Url.class)
2108 .value("http://web-page-address.com")
2109 .param("TYPE", "WORK")
2110 .noMore();
2111
2112 asserter.simpleProperty(Role.class)
2113 .value("TheProfession")
2114 .noMore();
2115
2116 asserter.dateProperty(Birthday.class)
2117 .date(LocalDate.of(1980, 3, 21))
2118 .noMore();
2119
2120 asserter.binaryProperty(Key.class)
2121 .param("ENCODING", "BASE64")
2122 .param("TYPE", "X509")
2123 .contentType(KeyType.X509)
2124 .dataLength(805)
2125 .noMore();
2126
2127 asserter.email()
2128 .types(EmailType.PREF, EmailType.INTERNET)
2129 .value("[email protected]")
2130 .noMore();
2131
2132 /*
2133 * Outlook 2003 apparently doesn't output FBURL correctly:
2134 * http://help.lockergnome.com/office/BUG-Outlook-2003-exports-FBURL-vCard-incorrectly--ftopict423660.html
2135 */
2136 asserter.simpleProperty(FreeBusyUrl.class)
2137 .value("????????????????s????????????" + (char) 12)
2138 .param("ENCODING", "QUOTED-PRINTABLE")
2139 .noMore();
2140
2141 asserter.simpleProperty(Revision.class)
2142 .value(LocalDateTime.of(2012, 10, 12, 21, 5, 25).toInstant(ZoneOffset.UTC))
2143 .noMore();
2144
2145 VCard vcard = asserter.getVCard();
2146 asserter.validate()
2147 .prop(vcard.getNickname(), 2) //not supported in 2.1
2148 .prop(vcard.getFbUrls().get(0), 2) //not supported in 2.1
2149 .run();
2150 //@formatter:on
2151
2152 asserter.done();
2153 }
2154
2155 @Test
2156 public void thunderbird() throws Throwable {
2157 VCardAsserter asserter = read("thunderbird-MoreFunctionsForAddressBook-extension.vcf");
2158 asserter.next(V3_0);
2159
2160 //@formatter:off
2161 asserter.structuredName()
2162 .param("CHARSET", "UTF-8")
2163 .family("Doe")
2164 .given("John")
2165 .noMore();
2166
2167 asserter.simpleProperty(FormattedName.class)
2168 .param("CHARSET", "UTF-8")
2169 .value("John Doe")
2170 .noMore();
2171
2172 asserter.listProperty(Organization.class)
2173 .param("CHARSET", "UTF-8")
2174 .values("TheOrganization", "TheDepartment")
2175 .noMore();
2176
2177 asserter.listProperty(Nickname.class)
2178 .param("CHARSET", "UTF-8")
2179 .values("Johnny")
2180 .noMore();
2181
2182 asserter.address()
2183 .param("CHARSET", "UTF-8")
2184 .extendedAddress("222 Broadway")
2185 .streetAddress("Suite 100")
2186 .locality("New York")
2187 .region("NY")
2188 .postalCode("98765")
2189 .country("USA")
2190 .types(AddressType.WORK, AddressType.POSTAL)
2191 .next()
2192 .param("CHARSET", "UTF-8")
2193 .extendedAddress("123 Main St")
2194 .streetAddress("Apt 10")
2195 .locality("Austin")
2196 .region("TX")
2197 .postalCode("12345")
2198 .country("USA")
2199 .types(AddressType.HOME, AddressType.POSTAL)
2200 .noMore();
2201
2202 asserter.telephone()
2203 .types(TelephoneType.WORK, TelephoneType.VOICE)
2204 .text("555-555-1111")
2205 .next()
2206 .types(TelephoneType.HOME, TelephoneType.VOICE)
2207 .text("555-555-2222")
2208 .next()
2209 .types(TelephoneType.CELL, TelephoneType.VOICE)
2210 .text("555-555-5555")
2211 .next()
2212 .types(TelephoneType.FAX)
2213 .text("555-555-3333")
2214 .next()
2215 .types(TelephoneType.PAGER)
2216 .text("555-555-4444")
2217 .noMore();
2218
2219 asserter.email()
2220 .types(EmailType.PREF, EmailType.INTERNET)
2221 .value("[email protected]")
2222 .next()
2223 .types(EmailType.INTERNET)
2224 .value("[email protected]")
2225 .next()
2226 .types(EmailType.INTERNET)
2227 .value("[email protected]")
2228 .next()
2229 .types(EmailType.INTERNET)
2230 .value("[email protected]")
2231 .next()
2232 .types(EmailType.INTERNET)
2233 .value("[email protected]")
2234 .noMore();
2235
2236 asserter.simpleProperty(Url.class)
2237 .value("http://www.private-webpage.com")
2238 .param("TYPE", "HOME")
2239 .next()
2240 .value("http://www.work-webpage.com")
2241 .param("TYPE", "WORK")
2242 .noMore();
2243
2244 asserter.simpleProperty(Title.class)
2245 .param("CHARSET", "UTF-8")
2246 .value("TheTitle")
2247 .noMore();
2248
2249 asserter.listProperty(Categories.class)
2250 .param("CHARSET", "UTF-8")
2251 .values("category1, category2, category3") //commas are incorrectly escaped, so there is only 1 item
2252 .noMore();
2253
2254 asserter.dateProperty(Birthday.class)
2255 .date(LocalDate.of(1970, 9, 21))
2256 .noMore();
2257
2258 asserter.simpleProperty(Note.class)
2259 .param("CHARSET", "UTF-8")
2260 .value("This is the notes field." + NEWLINE + "Second Line" + NEWLINE + NEWLINE + "Fourth Line" + NEWLINE + "You can put anything in the \"note\" field; even curse words.")
2261 .noMore();
2262
2263 asserter.binaryProperty(Photo.class)
2264 .param("ENCODING", "b")
2265 .param("TYPE", "JPEG")
2266 .contentType(ImageType.JPEG)
2267 .dataLength(8940)
2268 .noMore();
2269
2270 asserter.rawProperty("X-SPOUSE")
2271 .value("TheSpouse")
2272 .noMore();
2273
2274 asserter.rawProperty("X-ANNIVERSARY")
2275 .value("1990-04-30")
2276 .noMore();
2277
2278 VCard vcard = asserter.getVCard();
2279 asserter.validate()
2280 .prop(vcard.getStructuredName(), 6) //CHARSET not supported in 3.0
2281 .prop(vcard.getFormattedName(), 6) //CHARSET not supported in 3.0
2282 .prop(vcard.getOrganization(), 6) //CHARSET not supported in 3.0
2283 .prop(vcard.getNickname(), 6) //CHARSET not supported in 3.0
2284 .prop(vcard.getAddresses().get(0), 6) //CHARSET not supported in 3.0
2285 .prop(vcard.getAddresses().get(1), 6) //CHARSET not supported in 3.0
2286 .prop(vcard.getTitles().get(0), 6) //CHARSET not supported in 3.0
2287 .prop(vcard.getCategories(), 6) //CHARSET not supported in 3.0
2288 .prop(vcard.getNotes().get(0), 6) //CHARSET not supported in 3.0
2289 .run();
2290 //@formatter:on
2291
2292 asserter.done();
2293 }
2294
2295 @Test
2296 public void rfc6350_example() throws Throwable {
2297 VCardAsserter asserter = read("rfc6350-example.vcf");
2298 asserter.next(V4_0);
2299
2300 //@formatter:off
2301 asserter.simpleProperty(FormattedName.class)
2302 .value("Simon Perreault")
2303 .noMore();
2304
2305 asserter.structuredName()
2306 .family("Perreault")
2307 .given("Simon")
2308 .suffixes("ing. jr", "M.Sc.")
2309 .noMore();
2310
2311 asserter.dateProperty(Birthday.class)
2312 .partialDate(PartialDate.builder().month(2).date(3).build())
2313 .noMore();
2314
2315 asserter.dateProperty(Anniversary.class)
2316 .partialDate(PartialDate.builder().year(2009).month(8).date(8).hour(14).minute(30).offset(ZoneOffset.ofHours(-5)).build())
2317 .noMore();
2318
2319 asserter.property(Gender.class)
2320 .expected(Gender.male())
2321 .noMore();
2322
2323 asserter.simpleProperty(Language.class)
2324 .value("fr")
2325 .param("PREF", "1")
2326 .next()
2327 .value("en")
2328 .param("PREF", "2")
2329 .noMore();
2330
2331 asserter.listProperty(Organization.class)
2332 .param("TYPE", "work")
2333 .values("Viagenie")
2334 .noMore();
2335
2336 asserter.address()
2337 .extendedAddress("Suite D2-630")
2338 .streetAddress("2875 Laurier")
2339 .locality("Quebec")
2340 .region("QC")
2341 .postalCode("G1V 2M2")
2342 .country("Canada")
2343 .types(AddressType.WORK)
2344 .noMore();
2345
2346 asserter.telephone()
2347 .types(TelephoneType.WORK, TelephoneType.VOICE)
2348 .uri(new TelUri.Builder("+1-418-656-9254").extension("102").build())
2349 .param("PREF", "1")
2350 .next()
2351 .types(TelephoneType.WORK, TelephoneType.CELL, TelephoneType.VOICE, TelephoneType.VIDEO, TelephoneType.TEXT)
2352 .uri(new TelUri.Builder("+1-418-262-6501").build())
2353 .noMore();
2354
2355 asserter.email()
2356 .types(EmailType.WORK)
2357 .value("[email protected]")
2358 .noMore();
2359
2360 asserter.geo()
2361 .latitude(46.772673)
2362 .longitude(-71.282945)
2363 .param("TYPE", "work")
2364 .noMore();
2365
2366 asserter.binaryProperty(Key.class)
2367 .url("http://www.viagenie.ca/simon.perreault/simon.asc")
2368 .param("TYPE", "work")
2369 .noMore();
2370
2371 asserter.timezone()
2372 .offset(ZoneOffset.ofHours(-5))
2373 .noMore();
2374
2375 asserter.simpleProperty(Url.class)
2376 .value("http://nomis80.org")
2377 .param("TYPE", "home")
2378 .noMore();
2379 //@formatter:on
2380
2381 asserter.validate().run();
2382 asserter.done();
2383 }
2384
2385 @Test
2386 public void rfc2426_example() throws Throwable {
2387 VCardAsserter asserter = read("rfc2426-example.vcf");
2388
2389 {
2390 asserter.next(V3_0);
2391
2392 //@formatter:off
2393 asserter.simpleProperty(FormattedName.class)
2394 .value("Frank Dawson")
2395 .noMore();
2396
2397 asserter.listProperty(Organization.class)
2398 .values("Lotus Development Corporation")
2399 .noMore();
2400
2401 asserter.address()
2402 .streetAddress("6544 Battleford Drive")
2403 .locality("Raleigh")
2404 .region("NC")
2405 .postalCode("27613-3502")
2406 .country("U.S.A.")
2407 .types(AddressType.WORK, AddressType.POSTAL, AddressType.PARCEL)
2408 .noMore();
2409
2410 asserter.telephone()
2411 .types(TelephoneType.VOICE, TelephoneType.MSG, TelephoneType.WORK)
2412 .text("+1-919-676-9515")
2413 .next()
2414 .types(TelephoneType.FAX, TelephoneType.WORK)
2415 .text("+1-919-676-9564")
2416 .noMore();
2417
2418 asserter.email()
2419 .types(EmailType.INTERNET, EmailType.PREF)
2420 .value("[email protected]")
2421 .next()
2422 .types(EmailType.INTERNET)
2423 .value("[email protected]")
2424 .noMore();
2425
2426 asserter.simpleProperty(Url.class)
2427 .value("http://home.earthlink.net/~fdawson")
2428 .noMore();
2429
2430 asserter.validate()
2431 .prop(null, 0) //N property required
2432 .run();
2433 //@formatter:on
2434 }
2435
2436 {
2437 asserter.next(V3_0);
2438
2439 //@formatter:off
2440 asserter.simpleProperty(FormattedName.class)
2441 .value("Tim Howes")
2442 .noMore();
2443
2444 asserter.listProperty(Organization.class)
2445 .values("Netscape Communications Corp.")
2446 .noMore();
2447
2448 asserter.address()
2449 .streetAddress("501 E. Middlefield Rd.")
2450 .locality("Mountain View")
2451 .region("CA")
2452 .postalCode(" 94043")
2453 .country("U.S.A.")
2454 .types(AddressType.WORK)
2455 .noMore();
2456
2457 asserter.telephone()
2458 .types(TelephoneType.VOICE, TelephoneType.MSG, TelephoneType.WORK)
2459 .text("+1-415-937-3419")
2460 .next()
2461 .types(TelephoneType.FAX, TelephoneType.WORK)
2462 .text("+1-415-528-4164")
2463 .noMore();
2464
2465 asserter.email()
2466 .types(EmailType.INTERNET)
2467 .value("[email protected]")
2468 .noMore();
2469
2470 asserter.validate()
2471 .prop(null, 0) //N property required
2472 .run();
2473 //@formatter:on
2474 }
2475
2476 asserter.done();
2477 }
2478
2479 private static VCardAsserter read(String filename) {
2480 VCardReader reader = new VCardReader(SampleVCardsTest.class.getResourceAsStream(filename));
2481 return new VCardAsserter(reader);
2482 }
2483 }