Search in sources :

Example 6 with VCardVersion

use of ezvcard.VCardVersion in project ez-vcard by mangstadt.

the class VCardReaderTest method warnings_in_nested_vcard.

@Test
public void warnings_in_nested_vcard() throws Exception {
    for (VCardVersion version : VCardVersion.values()) {
        // @formatter:off
        String str = "BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "AGENT:\r\n" + "BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "WARNINGS:value\r\n" + "END:VCARD\r\n" + "END:VCARD\r\n";
        // @formatter:on
        VCardReader reader = new VCardReader(str);
        reader.registerScribe(new WarningsScribe());
        reader.readNext();
        assertParseWarnings(reader, (Integer) null);
        assertNoMoreVCards(reader);
    }
}
Also used : VCardVersion(ezvcard.VCardVersion) Test(org.junit.Test)

Example 7 with VCardVersion

use of ezvcard.VCardVersion in project ez-vcard by mangstadt.

the class VCardReaderTest method warnings_list_cleared.

@Test
public void warnings_list_cleared() throws Exception {
    for (VCardVersion version : VCardVersion.values()) {
        // @formatter:off
        VCardAsserter asserter = read("BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "bad-line\r\n" + "END:VCARD\r\n" + "BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "END:VCARD\r\n");
        // @formatter:on
        asserter.next(version);
        asserter.warnings(27);
        asserter.next(version);
        asserter.done();
    }
}
Also used : VCardVersion(ezvcard.VCardVersion) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 8 with VCardVersion

use of ezvcard.VCardVersion in project ez-vcard by mangstadt.

the class VCardReaderTest method extended_properties_override_standard_property_scribes.

@Test
public void extended_properties_override_standard_property_scribes() throws Exception {
    for (VCardVersion version : VCardVersion.values()) {
        // @formatter:off
        String str = "BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "FN:John Doe\r\n" + "END:VCARD\r\n";
        // @formatter:on
        VCardReader reader = new VCardReader(str);
        reader.registerScribe(new MyFormattedNameScribe());
        VCard vcard = reader.readNext();
        assertVersion(version, vcard);
        assertPropertyCount(1, vcard);
        // read a type that has a type class
        MyFormattedNameProperty fn = vcard.getProperty(MyFormattedNameProperty.class);
        assertEquals("JOHN DOE", fn.value);
        assertParseWarnings(reader);
        assertNoMoreVCards(reader);
    }
}
Also used : MyFormattedNameScribe(ezvcard.io.MyFormattedNameProperty.MyFormattedNameScribe) MyFormattedNameProperty(ezvcard.io.MyFormattedNameProperty) VCardVersion(ezvcard.VCardVersion) VCard(ezvcard.VCard) Test(org.junit.Test)

Example 9 with VCardVersion

use of ezvcard.VCardVersion in project ez-vcard by mangstadt.

the class VCardReaderTest method skip_non_vcard_components.

@Test
public void skip_non_vcard_components() throws Exception {
    for (VCardVersion version : VCardVersion.values()) {
        // @formatter:off
        VCardAsserter asserter = read("BEGIN:VCALENDAR\r\n" + "VERSION:2.0\r\n" + "invalid line--warning should not be logged\r\n" + "PRODID:-//Company//Application//EN\r\n" + "END:VCALENDAR\r\n" + "invalid line--warning should not be logged\r\n" + "BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "FN:John Doe\r\n" + "END:VCARD\r\n");
        asserter.next(version);
        asserter.simpleProperty(FormattedName.class).value("John Doe").noMore();
        asserter.done();
    // @formatter:on
    }
}
Also used : VCardVersion(ezvcard.VCardVersion) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 10 with VCardVersion

use of ezvcard.VCardVersion in project ez-vcard by mangstadt.

the class VCardReaderTest method label_properties.

/**
 * LABEL properties should be assigned to an ADR and stored in the
 * "Address.getLabel()" field. LABELs that could not be assigned to an ADR
 * should go in "VCard.getOrphanedLabels()".
 */
@Test
public void label_properties() throws Exception {
    for (VCardVersion version : VCardVersion.values()) {
        // @formatter:off
        VCardAsserter asserter = read("BEGIN:VCARD\r\n" + "VERSION:" + version.getVersion() + "\r\n" + "ADR;TYPE=home;TYPE=parcel:;;123 Main St.;Austin;TX;91827;USA\r\n" + "LABEL;TYPE=parcel;TYPE=home:123 Main St.\\nAustin\\, TX 91827\\nUSA\r\n" + "ADR;TYPE=work:;;200 Broadway;New York;NY;12345;USA\r\n" + "LABEL;TYPE=parcel:200 Broadway\\nNew York\\, NY 12345\\nUSA\r\n" + "END:VCARD\r\n");
        asserter.next(version);
        asserter.address().streetAddress("123 Main St.").locality("Austin").region("TX").postalCode("91827").country("USA").label("123 Main St." + NEWLINE + "Austin, TX 91827" + NEWLINE + "USA").types(AddressType.HOME, AddressType.PARCEL).next().streetAddress("200 Broadway").locality("New York").region("NY").postalCode("12345").country("USA").types(AddressType.WORK).noMore();
        asserter.simpleProperty(Label.class).value("200 Broadway" + NEWLINE + "New York, NY 12345" + NEWLINE + "USA").param("TYPE", "parcel").noMore();
        asserter.done();
    // @formatter:on
    }
}
Also used : Label(ezvcard.property.Label) VCardVersion(ezvcard.VCardVersion) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Aggregations

VCardVersion (ezvcard.VCardVersion)36 Test (org.junit.Test)30 VCard (ezvcard.VCard)14 VCardAsserter (ezvcard.property.asserter.VCardAsserter)10 VCardParameters (ezvcard.parameter.VCardParameters)5 Label (ezvcard.property.Label)4 RawProperty (ezvcard.property.RawProperty)4 VCardProperty (ezvcard.property.VCardProperty)4 Address (ezvcard.property.Address)3 ProductId (ezvcard.property.ProductId)3 VCardDataType (ezvcard.VCardDataType)2 EmbeddedVCardException (ezvcard.io.EmbeddedVCardException)2 VCardPropertyScribe (ezvcard.io.scribe.VCardPropertyScribe)2 ArrayList (java.util.ArrayList)2 SyntaxStyle (com.github.mangstadt.vinnie.SyntaxStyle)1 VObjectParameters (com.github.mangstadt.vinnie.VObjectParameters)1 AllowedCharacters (com.github.mangstadt.vinnie.validate.AllowedCharacters)1 ValidationWarning (ezvcard.ValidationWarning)1 LuckyNumProperty (ezvcard.io.LuckyNumProperty)1 LuckyNumScribe (ezvcard.io.LuckyNumProperty.LuckyNumScribe)1