Search in sources :

Example 6 with VCardAsserter

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

the class JCardReaderTest method no_properties.

@Test
public void no_properties() throws Throwable {
    // @formatter:off
    VCardAsserter asserter = readJson("[\"vcard\"," + "[" + "]" + "]");
    // default to 4.0
    asserter.next(V4_0);
    // missing VERSION property
    asserter.warnings(29);
    asserter.done();
// @formatter:on
}
Also used : VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 7 with VCardAsserter

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

the class JCardReaderTest method invalid_version.

@Test
public void invalid_version() throws Exception {
    // @formatter:off
    VCardAsserter asserter = readJson("[\"vcard\"," + "[" + "[\"version\", {}, \"text\", \"3.0\"]," + "[\"fn\", {}, \"text\", \"John Doe\"]" + "]" + "]");
    // should still set the version to 4.0
    asserter.next(V4_0);
    asserter.simpleProperty(FormattedName.class).value("John Doe").noMore();
    asserter.warnings(30);
    asserter.done();
// @formatter:on
}
Also used : VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 8 with VCardAsserter

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

the class JCardReaderTest method read_multiple.

@Test
public void read_multiple() throws Throwable {
    // @formatter:off
    VCardAsserter asserter = readJson("[" + "[\"vcard\"," + "[" + "[\"version\", {}, \"text\", \"4.0\"]," + "[\"fn\", {}, \"text\", \"John Doe\"]" + "]" + "]," + "[\"vcard\"," + "[" + "[\"version\", {}, \"text\", \"4.0\"]," + "[\"fn\", {}, \"text\", \"Jane Doe\"]" + "]" + "]" + "]");
    asserter.next(V4_0);
    asserter.simpleProperty(FormattedName.class).value("John Doe").noMore();
    asserter.next(V4_0);
    asserter.simpleProperty(FormattedName.class).value("Jane Doe").noMore();
    asserter.done();
// @formatter:on
}
Also used : VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 9 with VCardAsserter

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

the class HCardParserTest method url_of_vcard_specified.

@Test
public void url_of_vcard_specified() throws Exception {
    // @formatter:off
    String html = "<html>" + "<body>" + "<div class=\"vcard\">" + "<a class=\"fn url\" href=\"index.html\">John Doe</span>" + "</div>" + "</body>" + "</html>";
    HCardParser parser = new HCardParser(html, "http://johndoe.com/vcard.html");
    VCardAsserter asserter = new VCardAsserter(parser);
    asserter.next(V3_0);
    asserter.simpleProperty(FormattedName.class).value("John Doe").noMore();
    asserter.simpleProperty(Url.class).value("http://johndoe.com/index.html").noMore();
    asserter.simpleProperty(Source.class).value("http://johndoe.com/vcard.html").noMore();
    asserter.done();
// @formatter:on
}
Also used : VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 10 with VCardAsserter

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

the class HCardParserTest method anchor_in_url.

@Test
public void anchor_in_url() throws Exception {
    // @formatter:off
    String html = "<html>" + "<body>" + "<div class=\"vcard\">" + "<span class=\"fn\">John Doe</span>" + "</div>" + "<div id=\"anchor\">" + "<div class=\"vcard\">" + "<span class=\"fn\">Jane Doe</span>" + "</div>" + "</div>" + "</body>" + "</html>";
    HCardParser parser = new HCardParser(html, "http://johndoe.com/vcard.html#anchor");
    VCardAsserter asserter = new VCardAsserter(parser);
    asserter.next(V3_0);
    asserter.simpleProperty(FormattedName.class).value("Jane Doe").noMore();
    asserter.simpleProperty(Source.class).value("http://johndoe.com/vcard.html#anchor").noMore();
    asserter.done();
// @formatter:on
}
Also used : VCardAsserter(ezvcard.property.asserter.VCardAsserter) 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