use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class JCardReaderTest method no_properties_multiple.
@Test
public void no_properties_multiple() throws Throwable {
// @formatter:off
VCardAsserter asserter = readJson("[" + "[\"vcard\"," + "[" + "]" + "]," + "[\"vcard\"," + "[" + "]" + "]" + "]");
// default to 4.0
asserter.next(V4_0);
// missing VERSION property
asserter.warnings(29);
// default to 4.0
asserter.next(V4_0);
// missing VERSION property
asserter.warnings(29);
asserter.done();
// @formatter:on
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class JCardReaderTest method extendedType.
@Test
public void extendedType() throws Throwable {
// @formatter:off
VCardAsserter asserter = readJson("[\"vcard\"," + "[" + "[\"version\", {}, \"text\", \"4.0\"]," + "[\"x-type\", {}, \"text\", \"value\"]" + "]" + "]");
asserter.next(V4_0);
asserter.rawProperty("x-type").dataType(VCardDataType.TEXT).value("value").noMore();
asserter.done();
// @formatter:on
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class JCardReaderTest method utf8.
@Test
public void utf8() throws Throwable {
// @formatter:off
String json = "[\"vcard\"," + "[" + "[\"version\", {}, \"text\", \"4.0\"]," + "[\"note\", {}, \"text\", \"\u019dote\"]" + "]" + "]";
File file = tempFolder.newFile();
Writer writer = new Utf8Writer(file);
writer.write(json);
writer.close();
JCardReader reader = new JCardReader(file);
VCardAsserter asserter = new VCardAsserter(reader);
asserter.next(V4_0);
asserter.simpleProperty(Note.class).value("\u019dote").noMore();
asserter.done();
// @formatter:on
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class JCardReaderTest method jcard_example.
@Test
public void jcard_example() throws Throwable {
JCardReader reader = new JCardReader(getClass().getResourceAsStream("jcard-example.json"));
VCardAsserter asserter = new VCardAsserter(reader);
asserter.next(V4_0);
// @formatter:off
asserter.simpleProperty(FormattedName.class).value("Simon Perreault").noMore();
asserter.structuredName().family("Perreault").given("Simon").suffixes("ing. jr", "M.Sc.").noMore();
asserter.dateProperty(Birthday.class).partialDate(PartialDate.builder().month(2).date(3).build()).noMore();
asserter.dateProperty(Anniversary.class).date("2009-08-08 19:30:00 +0000").noMore();
asserter.property(Gender.class).expected(Gender.male()).noMore();
asserter.simpleProperty(Language.class).value("fr").param("PREF", "1").next().value("en").param("PREF", "2").noMore();
asserter.listProperty(Organization.class).values("Viagenie").param("TYPE", "work").noMore();
asserter.address().extendedAddress("Suite D2-630").streetAddress("2875 Laurier").locality("Quebec").region("QC").postalCode("G1V 2M2").country("Canada").types(AddressType.WORK).noMore();
asserter.telephone().uri(new TelUri.Builder("+1-418-656-9254").extension("102").build()).types(TelephoneType.WORK, TelephoneType.VOICE).param("PREF", "1").next().uri(new TelUri.Builder("+1-418-262-6501").build()).types(TelephoneType.WORK, TelephoneType.CELL, TelephoneType.VOICE, TelephoneType.VIDEO, TelephoneType.TEXT).noMore();
asserter.email().value("simon.perreault@viagenie.ca").types(EmailType.WORK).noMore();
asserter.geo().latitude(46.772673).longitude(-71.282945).param("TYPE", "work").noMore();
asserter.binaryProperty(Key.class).url("http://www.viagenie.ca/simon.perreault/simon.asc").param("TYPE", "work").noMore();
asserter.timezone().offset(new UtcOffset(false, -5, 0)).noMore();
asserter.simpleProperty(Url.class).value("http://nomis80.org").param("TYPE", "home").noMore();
// @formatter:on
asserter.validate().run();
asserter.done();
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class JCardReaderTest method skipMeException.
@Test
public void skipMeException() throws Throwable {
// @formatter:off
String json = "[\"vcard\"," + "[" + "[\"version\", {}, \"text\", \"4.0\"]," + "[\"skipme\", {}, \"text\", \"value\"]" + "]" + "]";
// @formatter:on
JCardReader reader = new JCardReader(json);
reader.registerScribe(new SkipMeScribe());
VCardAsserter asserter = new VCardAsserter(reader);
asserter.next(V4_0);
asserter.warnings(22);
asserter.done();
}
Aggregations