@Test public void parseXml() { // @formatter:off sensei .assertParseXml( "<pobox>P.O. Box 1234;</pobox>" + "<ext>Apt, 11</ext>" + "<street>123 Main St</street>" + "<locality>Austin</locality>" + "<region>TX</region>" + "<code>12345</code>" + "<country>USA</country>") .run(is(withAllFields)); sensei .assertParseXml( "<pobox>P.O. Box 1234;</pobox>" + "<locality>Austin</locality>" + "<region>TX</region>" + "<code>12345</code>" + "<country></country>") .run(is(withSomeFields)); sensei.assertParseXml("").run(is(empty)); // @formatter:on }
@Test public void parseXml_unknown() { sensei .assertParseXml("<unknown>value</unknown>") .warnings(1) .run( new Check<TestProperty>() { public void check(TestProperty property) { assertEquals("value", property.value); assertEquals(null, property.parsedDataType); } }); }
@Test public void parseXml_no_child_elements() { sensei .assertParseXml("value") .warnings(1) .run( new Check<TestProperty>() { public void check(TestProperty property) { assertEquals("value", property.value); assertNull(property.parsedDataType); } }); }
@Test public void parseXml_no_xcard_element() { sensei .assertParseXml( "<one xmlns=\"http://example.com\">1</one><two xmlns=\"http://example.com\">2</two>") .warnings(1) .run( new Check<TestProperty>() { public void check(TestProperty property) { assertEquals("12", property.value); assertNull(property.parsedDataType); } }); }
@Test public void parseXml() { final VCardParameters params = new VCardParameters(); // @formatter:off sensei .assertParseXml( "<ignore xmlns=\"http://example.com\">ignore-me</ignore>" + "<integer>value</integer>" + "<text>ignore-me</text>") .params(params) .warnings(1) .run( new Check<TestProperty>() { public void check(TestProperty property) { assertEquals("value", property.value); assertEquals(VCardDataType.INTEGER, property.parsedDataType); assertSame(params, property.getParameters()); } }); // @formatter:on }