Search in sources :

Example 81 with VCardAsserter

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

the class XCardReaderTest method read_groups.

@Test
public void read_groups() throws Exception {
    // @formatter:off
    VCardAsserter asserter = readXml("<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<group name=\"item1\">" + "<fn><text>John Doe</text></fn>" + "<note><text>Hello world!</text></note>" + "</group>" + "<group>" + "<prodid><text>no name attribute</text></prodid>" + "</group>" + "<note><text>A property without a group</text></note>" + "</vcard>" + "</vcards>");
    asserter.next(V4_0);
    asserter.simpleProperty(FormattedName.class).group("item1").value("John Doe").noMore();
    asserter.simpleProperty(Note.class).group("item1").value("Hello world!").next().value("A property without a group").noMore();
    asserter.simpleProperty(ProductId.class).value("no name attribute").noMore();
    asserter.done();
// @formatter:on
}
Also used : FormattedName(ezvcard.property.FormattedName) Note(ezvcard.property.Note) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 82 with VCardAsserter

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

the class XCardReaderTest method read_utf8.

@Test
public void read_utf8() throws Exception {
    // @formatter:off
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<note><text>\u019dote</text></note>" + "</vcard>" + "</vcards>";
    File file = tempFolder.newFile();
    Writer writer = new Utf8Writer(file);
    writer.write(xml);
    writer.close();
    XCardReader reader = new XCardReader(file);
    VCardAsserter asserter = new VCardAsserter(reader);
    asserter.next(V4_0);
    asserter.simpleProperty(Note.class).value("\u019dote").noMore();
    asserter.done();
// @formatter:on
}
Also used : Utf8Writer(ezvcard.util.Utf8Writer) VCardAsserter(ezvcard.property.asserter.VCardAsserter) File(java.io.File) Writer(java.io.Writer) Utf8Writer(ezvcard.util.Utf8Writer) Test(org.junit.Test)

Example 83 with VCardAsserter

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

the class XCardReaderTest method read_namespace_prefix.

@Test
public void read_namespace_prefix() throws Exception {
    // @formatter:off
    VCardAsserter asserter = readXml("<v:vcards xmlns:v=\"" + V4_0.getXmlNamespace() + "\">" + "<v:vcard>" + "<v:fn><x:text xmlns:x=\"" + V4_0.getXmlNamespace() + "\">Dr. Gregory House M.D.</x:text></v:fn>" + "</v:vcard>" + "</v:vcards>");
    asserter.next(V4_0);
    asserter.simpleProperty(FormattedName.class).value("Dr. Gregory House M.D.").noMore();
    asserter.done();
// @formatter:on
}
Also used : VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 84 with VCardAsserter

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

the class XCardReaderTest method read_preserve_whitespace.

@Test
public void read_preserve_whitespace() throws Exception {
    // @formatter:off
    VCardAsserter asserter = readXml("<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<note><text>  This \t  is \n   a   note </text></note>" + "</vcard>" + "</vcards>");
    asserter.next(V4_0);
    asserter.simpleProperty(Note.class).value("  This \t  is \n   a   note ").noMore();
    asserter.done();
// @formatter:on
}
Also used : VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 85 with VCardAsserter

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

the class XCardReaderTest method read_identical_element_names.

@Test
public void read_identical_element_names() throws Exception {
    // @formatter:off
    VCardAsserter asserter = readXml("<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<vcard>" + "<parameters>" + "<parameters><text>paramValue1</text></parameters>" + "<group><text>paramValue2</text></group>" + "</parameters>" + "<vcard>propValue</vcard>" + "</vcard>" + "<group name=\"grp\">" + "<group>" + "<text>value</text>" + "</group>" + "</group>" + "</vcard>" + "</vcards>");
    asserter.next(V4_0);
    asserter.rawProperty("VCARD").dataType(VCardDataType.get("VCARD")).value("propValue").param("PARAMETERS", "paramValue1").param("GROUP", "paramValue2").noMore();
    asserter.rawProperty("GROUP").dataType(VCardDataType.TEXT).group("grp").value("value").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