Search in sources :

Example 61 with VCardAsserter

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

the class HCardParserTest method assign_labels_to_addresses.

@Test
public void assign_labels_to_addresses() throws Exception {
    // @formatter:off
    VCardAsserter asserter = readHtml("<html>" + "<body>" + "<div class=\"vcard\">" + "<div class=\"adr\">" + "<span class=\"type\">Home</span>:<br>" + "<span class=\"street-address\">123 Main St.</span><br>" + "<span class=\"locality\">Austin</span>, <span class=\"region\">TX</span> <span class=\"postal-code\">12345</span>" + "</div>" + "<div class=\"label\"><abbr class=\"type\" title=\"home\"></abbr>123 Main St.\nAustin, TX 12345</div>" + "<abbr class=\"label\" title=\"456 Wall St., New York, NY 67890\"><abbr class=\"type\" title=\"work\"></abbr></abbr>" + "</div>" + "</body>" + "</html>");
    asserter.next(V3_0);
    asserter.address().streetAddress("123 Main St.").locality("Austin").region("TX").postalCode("12345").label("123 Main St. Austin, TX 12345").types(AddressType.HOME).noMore();
    asserter.simpleProperty(Label.class).value("456 Wall St., New York, NY 67890").param("TYPE", "work").noMore();
    asserter.done();
// @formatter:on
}
Also used : Label(ezvcard.property.Label) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 62 with VCardAsserter

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

the class HCardParserTest method read_multiple.

@Test
public void read_multiple() throws Exception {
    // @formatter:off
    VCardAsserter asserter = readHtml("<html>" + "<body>" + "<div class=\"vcard\">" + "<span class=\"fn\">John Doe</span>" + "</div>" + "<div class=\"vcard\">" + "<span class=\"fn\">Jane Doe</span>" + "</div>" + "</body>" + "</html>");
    asserter.next(V3_0);
    asserter.simpleProperty(FormattedName.class).value("John Doe").noMore();
    asserter.next(V3_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 63 with VCardAsserter

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

the class HCardParserTest method cannotParseException.

@Test
public void cannotParseException() throws Exception {
    // @formatter:off
    String html = "<html>" + "<body>" + "<div class=\"vcard\">" + "<span class=\"cannotparse\">value</span>" + "<span class=\"x-foo\">value</span>" + "</div>" + "</body>" + "</html>";
    HCardParser parser = new HCardParser(html);
    parser.registerScribe(new CannotParseScribe());
    VCardAsserter asserter = new VCardAsserter(parser);
    asserter.next(V3_0);
    asserter.rawProperty("x-foo").value("value").noMore();
    asserter.rawProperty("cannotparse").value("<span class=\"cannotparse\">value</span>").noMore();
    asserter.warnings(25);
    asserter.done();
// @formatter:on
}
Also used : CannotParseScribe(ezvcard.io.scribe.CannotParseScribe) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 64 with VCardAsserter

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

the class HCardParserTest method skipMeException.

@Test
public void skipMeException() throws Exception {
    // @formatter:off
    String html = "<html>" + "<body>" + "<div class=\"vcard\">" + "<span class=\"skipme\">value</span>" + "<span class=\"x-foo\">value</span>" + "</div>" + "</body>" + "</html>";
    HCardParser parser = new HCardParser(html);
    parser.registerScribe(new SkipMeScribe());
    VCardAsserter asserter = new VCardAsserter(parser);
    asserter.next(V3_0);
    asserter.rawProperty("x-foo").value("value").noMore();
    asserter.warnings(22);
    asserter.done();
// @formatter:on
}
Also used : SkipMeScribe(ezvcard.io.scribe.SkipMeScribe) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 65 with VCardAsserter

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

the class HCardParserTest method non_existant_anchor.

@Test
public void non_existant_anchor() 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#non-existant");
    VCardAsserter asserter = new VCardAsserter(parser);
    asserter.next(V3_0);
    asserter.simpleProperty(FormattedName.class).value("John Doe").noMore();
    asserter.simpleProperty(Source.class).value("http://johndoe.com/vcard.html#non-existant").noMore();
    asserter.next(V3_0);
    asserter.simpleProperty(FormattedName.class).value("Jane Doe").noMore();
    asserter.simpleProperty(Source.class).value("http://johndoe.com/vcard.html#non-existant").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