Search in sources :

Example 1 with JCardValue

use of ezvcard.io.json.JCardValue in project ez-vcard by mangstadt.

the class StructuredNameScribeTest method parseJson.

@Test
public void parseJson() {
    JCardValue value = JCardValue.structured("Doe", "Jonathan", Arrays.asList("Joh;nny,", "John"), "Mr.", "III");
    sensei.assertParseJson(value).run(withAllValues);
    value = JCardValue.structured(null, "Jonathan", Arrays.asList("Joh;nny,", "John"), "", null);
    sensei.assertParseJson(value).run(withEmptyValues);
    value = JCardValue.structured(null, "Jonathan", Arrays.asList("Joh;nny,", "John"));
    sensei.assertParseJson(value).run(withEmptyValues);
    value = JCardValue.structured(null, null, "", null, null);
    sensei.assertParseJson(value).run(empty);
    sensei.assertParseJson("").run(empty);
}
Also used : JCardValue(ezvcard.io.json.JCardValue) Test(org.junit.Test)

Example 2 with JCardValue

use of ezvcard.io.json.JCardValue in project ez-vcard by mangstadt.

the class VCardPropertyScribeTest method parseJson_list.

@Test
public void parseJson_list() {
    JCardValue value = JCardValue.multi("value1", "val,;ue2");
    sensei.assertParseJson(value).dataType(VCardDataType.TEXT).warnings((Integer) null).run(new Check<TestProperty>() {

        public void check(TestProperty property) {
            assertEquals("value1,val\\,\\;ue2", property.value);
        }
    });
}
Also used : JCardValue(ezvcard.io.json.JCardValue) Test(org.junit.Test)

Example 3 with JCardValue

use of ezvcard.io.json.JCardValue in project ez-vcard by mangstadt.

the class ClientPidMapScribeTest method parseJson.

@Test
public void parseJson() {
    JCardValue value = JCardValue.structured(pid + "", uri);
    sensei.assertParseJson(value).run(withValue);
    value = JCardValue.structured("not-a-number", uri);
    sensei.assertParseJson(value).cannotParse(4);
    value = JCardValue.structured(pid + "");
    sensei.assertParseJson(value).run(has(pid, null));
}
Also used : JCardValue(ezvcard.io.json.JCardValue) Test(org.junit.Test)

Example 4 with JCardValue

use of ezvcard.io.json.JCardValue in project ez-vcard by mangstadt.

the class VCardPropertyScribeTest method parseJson_structured.

@Test
public void parseJson_structured() {
    JCardValue value = JCardValue.structured(null, "value1", "val,;ue2", Arrays.asList("value3", "value4"));
    sensei.assertParseJson(value).dataType(VCardDataType.TEXT).warnings((Integer) null).run(new Check<TestProperty>() {

        public void check(TestProperty property) {
            assertEquals(";value1;val\\,\\;ue2;value3,value4", property.value);
        }
    });
}
Also used : JCardValue(ezvcard.io.json.JCardValue) Test(org.junit.Test)

Example 5 with JCardValue

use of ezvcard.io.json.JCardValue in project ez-vcard by mangstadt.

the class AddressScribeTest method parseJson.

@Test
public void parseJson() {
    JCardValue value = JCardValue.structured("P.O. Box 1234;", "Apt, 11", "123 Main St", "Austin", "TX", "12345", "USA");
    sensei.assertParseJson(value).run(withAllFields);
    value = JCardValue.structured("P.O. Box 1234;", Arrays.asList("Apt, 11", "P.O. Box 12"), Arrays.asList("123 Main St", "555 Main St"), "Austin", "TX", "12345", "USA");
    sensei.assertParseJson(value).run(withMultipleValuesFields);
    value = JCardValue.structured("P.O. Box 1234;", "", "", "Austin", "TX", "12345", "");
    sensei.assertParseJson(value).run(withSomeFields);
    value = JCardValue.structured("", null, "", "", "", "", "");
    sensei.assertParseJson(value).run(empty);
    value = JCardValue.structured();
    sensei.assertParseJson(value).run(empty);
    value = JCardValue.structured("P.O. Box 1234;", "Apt, 11", "123 Main St", "Austin");
    sensei.assertParseJson(value).run(new Check<Address>() {

        public void check(Address property) {
            assertEquals("P.O. Box 1234;", property.getPoBox());
            assertEquals("Apt, 11", property.getExtendedAddress());
            assertEquals("123 Main St", property.getStreetAddress());
            assertEquals("Austin", property.getLocality());
            assertNull(property.getRegion());
            assertNull(property.getPostalCode());
            assertNull(property.getCountry());
        }
    });
}
Also used : Address(ezvcard.property.Address) JCardValue(ezvcard.io.json.JCardValue) Test(org.junit.Test)

Aggregations

JCardValue (ezvcard.io.json.JCardValue)7 Test (org.junit.Test)7 VCardParameters (ezvcard.parameter.VCardParameters)1 Address (ezvcard.property.Address)1