예제 #1
0
  @Test
  public void parseHtml() {
    // @formatter:off
    sensei
        .assertParseHtml(
            "<div>"
                + "<span class=\"post-office-box\">P.O. Box 1234;</span>"
                + "<span class=\"extended-address\">Apt, 11</span>"
                + "<span class=\"street-address\">123 Main St</span>"
                + "<span class=\"locality\">Austin</span>"
                + "<span class=\"region\">TX</span>"
                + "<span class=\"postal-code\">12345</span>"
                + "<span class=\"country-name\">USA</span>"
                + "</div>")
        .run(is(withAllFields));

    sensei
        .assertParseHtml(
            "<div>"
                + "<span class=\"post-office-box\">P.O. Box 1234;</span>"
                + "<span class=\"locality\">Austin</span>"
                + "<span class=\"region\">TX</span>"
                + "<span class=\"postal-code\">12345</span>"
                + "</div>")
        .run(is(withSomeFields));

    sensei.assertParseHtml("<div></div>").run(is(empty));
    // @formatter:on
  }
예제 #2
0
  @Test
  public void parseHtml() {
    Email expected = new Email("*****@*****.**");

    // @formatter:off
    sensei.assertParseHtml("<a href=\"mailto:[email protected]\">Email Me</a>").run(expected);

    sensei.assertParseHtml("<a href=\"MAILTO:[email protected]\">Email Me</a>").run(expected);

    sensei
        .assertParseHtml("<a href=\"http://www.example.com\">[email protected]</a>")
        .run(expected);

    sensei.assertParseHtml("<div>[email protected]</div>").run(expected);
    // @formatter:on
  }
 @Test
 public void parseHtml() {
   sensei
       .assertParseHtml("<div>value<del>ignore</del>value</div>")
       .warnings(1)
       .run(
           new Check<TestProperty>() {
             public void check(TestProperty property) {
               assertEquals("valuevalue", property.value);
               assertNull(property.parsedDataType);
             }
           });
 }
예제 #4
0
  @Test
  public void parseHtml_types() {
    Email expected = new Email("*****@*****.**");
    expected.addType(EmailType.HOME);

    // @formatter:off
    sensei
        .assertParseHtml(
            "<a href=\"mailto:[email protected]\">"
                + "<span class=\"type\">Home</span> Email"
                + "</a>")
        .run(expected);
    // @formatter:on
  }
예제 #5
0
 @Test
 public void parseHtml_type_parameters() {
   // @formatter:off
   sensei
       .assertParseHtml(
           "<div>"
               + "<span class=\"type\">home</span>"
               + "<span class=\"type\">postal</span>"
               + "<span class=\"type\">other</span>"
               + "<span class=\"post-office-box\">P.O. Box 1234;</span>"
               + "<span class=\"extended-address\">Apt, 11</span>"
               + "<span class=\"street-address\">123 Main St</span>"
               + "<span class=\"locality\">Austin</span>"
               + "<span class=\"region\">TX</span>"
               + "<span class=\"postal-code\">12345</span>"
               + "<span class=\"country-name\">USA</span>"
               + "</div>")
       .run(
           new Check<Address>() {
             public void check(Address property) {
               assertEquals("P.O. Box 1234;", property.getPoBox());
               assertEquals("Apt, 11", property.getExtendedAddress());
               assertEquals("123 Main St", property.getStreetAddress());
               assertEquals("Austin", property.getLocality());
               assertEquals("TX", property.getRegion());
               assertEquals("12345", property.getPostalCode());
               assertEquals("USA", property.getCountry());
               assertSetEquals(
                   property.getTypes(),
                   AddressType.HOME,
                   AddressType.POSTAL,
                   AddressType.get("other"));
             }
           });
   // @formatter:on
 }