Search in sources :

Example 6 with Agent

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

the class VCardWriterTest method setVersionStrict_embedded.

@Test
public void setVersionStrict_embedded() throws Throwable {
    VCard vcard = new VCard();
    VCard agentVCard = new VCard();
    // only supported by 4.0
    agentVCard.setGender(Gender.male());
    Agent agent = new Agent(agentVCard);
    vcard.setAgent(agent);
    StringWriter sw = new StringWriter();
    VCardWriter vcw = new VCardWriter(sw, VCardVersion.V3_0);
    vcw.setAddProdId(false);
    vcw.setVersionStrict(false);
    vcw.write(vcard);
    String actual = sw.toString();
    // @formatter:off
    String expected = "BEGIN:VCARD\r\n" + "VERSION:3.0\r\n" + "AGENT:BEGIN:VCARD\\nVERSION:3.0\\nGENDER:M\\nEND:VCARD\\n\r\n" + "END:VCARD\r\n";
    // @formatter:on
    assertEquals(actual, expected);
}
Also used : Agent(ezvcard.property.Agent) StringWriter(java.io.StringWriter) VCard(ezvcard.VCard) Test(org.junit.Test)

Aggregations

Agent (ezvcard.property.Agent)6 VCard (ezvcard.VCard)4 StringWriter (java.io.StringWriter)4 Test (org.junit.Test)4 EmbeddedVCardException (ezvcard.io.EmbeddedVCardException)2 Note (ezvcard.property.Note)1