use of ezvcard.util.XCardBuilder in project ez-vcard by mangstadt.
the class EzvcardTest method parseXml_all.
@Test
public void parseXml_all() throws Exception {
XCardBuilder xb = new XCardBuilder();
xb.prop("fn", "<text>John Doe</text>");
xb.begin();
xb.prop("fn", "<text>Jane Doe</text>");
List<List<ParseWarning>> warnings = new ArrayList<List<ParseWarning>>();
List<VCard> vcards = Ezvcard.parseXml(xb.toString()).warnings(warnings).all();
Iterator<VCard> it = vcards.iterator();
VCard vcard = it.next();
assertVersion(VCardVersion.V4_0, vcard);
assertEquals("John Doe", vcard.getFormattedName().getValue());
vcard = it.next();
assertVersion(VCardVersion.V4_0, vcard);
assertEquals("Jane Doe", vcard.getFormattedName().getValue());
assertEquals(2, warnings.size());
assertParseWarnings(warnings.get(0));
assertParseWarnings(warnings.get(1));
assertFalse(it.hasNext());
}
use of ezvcard.util.XCardBuilder in project ez-vcard by mangstadt.
the class EzvcardTest method parseXml_first.
@Test
public void parseXml_first() throws Exception {
XCardBuilder xb = new XCardBuilder();
xb.prop("fn", "<text>John Doe</text>");
List<List<ParseWarning>> warnings = new ArrayList<List<ParseWarning>>();
VCard vcard = Ezvcard.parseXml(xb.toString()).warnings(warnings).first();
assertVersion(VCardVersion.V4_0, vcard);
assertEquals("John Doe", vcard.getFormattedName().getValue());
assertEquals(1, warnings.size());
assertParseWarnings(warnings.get(0));
}
use of ezvcard.util.XCardBuilder in project ez-vcard by mangstadt.
the class EzvcardTest method parseXml_register.
@Test
public void parseXml_register() throws Exception {
XCardBuilder xb = new XCardBuilder();
xb.prop("http://luckynum.com", "lucky-num", "<num>22</num>");
VCard vcard = Ezvcard.parseXml(xb.toString()).register(new LuckyNumScribe()).first();
assertVersion(VCardVersion.V4_0, vcard);
List<LuckyNumProperty> ext = vcard.getProperties(LuckyNumProperty.class);
assertEquals(1, ext.size());
assertEquals(22, ext.get(0).luckyNum);
}
Aggregations