Search in sources :

Example 16 with FormattedName

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

the class EzvcardTest method writeXml_dom.

@Test
public void writeXml_dom() throws Exception {
    VCard vcard = new VCard();
    vcard.setFormattedName(new FormattedName("John Doe"));
    Document actual = Ezvcard.writeXml(vcard).prodId(false).dom();
    // @formatter:off
    String html = "<vcards xmlns=\"" + VCardVersion.V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<fn><text>John Doe</text></fn>" + "</vcard>" + "</vcards>";
    Document expected = XmlUtils.toDocument(html);
    // @formatter:on
    assertXMLEqual(expected, actual);
}
Also used : FormattedName(ezvcard.property.FormattedName) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 17 with FormattedName

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

the class EzvcardTest method write_multiple.

@Test
public void write_multiple() throws Exception {
    VCard vcard1 = new VCard();
    vcard1.setVersion(VCardVersion.V2_1);
    vcard1.setFormattedName(new FormattedName("John Doe"));
    VCard vcard2 = new VCard();
    vcard2.setVersion(VCardVersion.V3_0);
    vcard2.setFormattedName(new FormattedName("Jane Doe"));
    VCard vcard3 = new VCard();
    vcard3.setVersion(VCardVersion.V4_0);
    vcard3.setFormattedName(new FormattedName("Janet Doe"));
    String actual = Ezvcard.write(vcard1, vcard2, vcard3).go();
    assertTrue(actual.matches("(?s)BEGIN:VCARD.*?VERSION:2\\.1.*?FN:John Doe.*?END:VCARD.*?BEGIN:VCARD.*?VERSION:3\\.0.*?FN:Jane Doe.*?END:VCARD.*?BEGIN:VCARD.*?VERSION:4\\.0.*?FN:Janet Doe.*?END:VCARD.*"));
}
Also used : FormattedName(ezvcard.property.FormattedName) Test(org.junit.Test)

Example 18 with FormattedName

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

the class EzvcardTest method writeXml_indent.

@Test
public void writeXml_indent() throws Exception {
    VCard vcard = new VCard();
    vcard.setFormattedName(new FormattedName("John Doe"));
    String actual = Ezvcard.writeXml(vcard).indent(2).go();
    assertTrue(actual.contains("    <fn>" + NEWLINE + "      <text>John Doe</text>" + NEWLINE + "    </fn>"));
}
Also used : FormattedName(ezvcard.property.FormattedName) Test(org.junit.Test)

Example 19 with FormattedName

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

the class EzvcardTest method write_caretEncoding.

@Test
public void write_caretEncoding() throws Exception {
    VCard vcard = new VCard();
    vcard.setVersion(VCardVersion.V4_0);
    FormattedName fn = vcard.setFormattedName("test");
    fn.getParameters().put("X-TEST", "George Herman \"Babe\" Ruth");
    // default should be "false"
    try {
        Ezvcard.write(vcard).go();
        fail("IllegalArgumentException expected.");
    } catch (IllegalArgumentException e) {
    // expected
    }
    String actual = Ezvcard.write(vcard).caretEncoding(true).go();
    assertTrue(actual.contains("\r\nFN;X-TEST=George Herman ^'Babe^' Ruth:"));
    try {
        Ezvcard.write(vcard).caretEncoding(false).go();
        fail("IllegalArgumentException expected.");
    } catch (IllegalArgumentException e) {
    // expected
    }
}
Also used : FormattedName(ezvcard.property.FormattedName) Test(org.junit.Test)

Aggregations

FormattedName (ezvcard.property.FormattedName)19 Test (org.junit.Test)11 VCard (ezvcard.VCard)6 RawProperty (ezvcard.property.RawProperty)3 StructuredName (ezvcard.property.StructuredName)3 Uid (ezvcard.property.Uid)3 Photo (ezvcard.property.Photo)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Bitmap (android.graphics.Bitmap)1 RingAccountViewModelImpl (cx.ring.account.RingAccountViewModelImpl)1 VCardVersion (ezvcard.VCardVersion)1 VCardReader (ezvcard.io.text.VCardReader)1 AddressType (ezvcard.parameter.AddressType)1 EmailType (ezvcard.parameter.EmailType)1 TelephoneType (ezvcard.parameter.TelephoneType)1 Address (ezvcard.property.Address)1 Email (ezvcard.property.Email)1 Note (ezvcard.property.Note)1 ProductId (ezvcard.property.ProductId)1 Telephone (ezvcard.property.Telephone)1