Search in sources :

Example 26 with VCardParameters

use of ezvcard.parameter.VCardParameters in project ez-vcard by mangstadt.

the class JCardRawReaderTest method different_data_types.

@Test
public void different_data_types() throws Throwable {
    // @formatter:off
    String json = "[\"vcard\"," + "[" + "[\"prop\", {}, \"text\", false, true, 1.1, 1, null, \"text\" ]" + "]" + "]";
    // @formatter:on
    JCardRawReader reader = createReader(json);
    JCardDataStreamListener listener = mock(JCardDataStreamListener.class);
    reader.readNext(listener);
    verify(listener).beginVCard();
    verify(listener).readProperty(null, "prop", new VCardParameters(), VCardDataType.TEXT, JCardValue.multi(false, true, 1.1, 1L, null, "text"));
    verifyNoMoreInteractions(listener);
}
Also used : VCardParameters(ezvcard.parameter.VCardParameters) JCardDataStreamListener(ezvcard.io.json.JCardRawReader.JCardDataStreamListener) Test(org.junit.Test)

Example 27 with VCardParameters

use of ezvcard.parameter.VCardParameters in project ez-vcard by mangstadt.

the class VCardPropertyScribeTest method parseJson_single.

@Test
public void parseJson_single() {
    final VCardParameters params = new VCardParameters();
    JCardValue value = JCardValue.single("value");
    sensei.assertParseJson(value).dataType(VCardDataType.TEXT).params(params).warnings((Integer) null).run(new Check<TestProperty>() {

        public void check(TestProperty property) {
            assertEquals("value", property.value);
            assertSame(params, property.getParameters());
        }
    });
}
Also used : VCardParameters(ezvcard.parameter.VCardParameters) JCardValue(ezvcard.io.json.JCardValue) Test(org.junit.Test)

Example 28 with VCardParameters

use of ezvcard.parameter.VCardParameters in project ez-vcard by mangstadt.

the class VCardPropertyScribeTest method parseText.

@Test
public void parseText() {
    final VCardParameters params = new VCardParameters();
    sensei.assertParseText("value").dataType(VCardDataType.TEXT).warnings((Integer) null).params(params).run(new Check<TestProperty>() {

        public void check(TestProperty property) {
            assertEquals("value", property.value);
            assertEquals(VCardDataType.TEXT, property.parsedDataType);
            assertSame(params, property.getParameters());
        }
    });
}
Also used : VCardParameters(ezvcard.parameter.VCardParameters) Test(org.junit.Test)

Example 29 with VCardParameters

use of ezvcard.parameter.VCardParameters in project ez-vcard by mangstadt.

the class PidParameterListTest method invalid_value.

@Test
public void invalid_value() {
    PidParameterListProperty property = new PidParameterListProperty();
    VCardParameters parameters = property.getParameters();
    List<Pid> pids = property.getPids();
    parameters.put(VCardParameters.PID, "foobar");
    try {
        pids.get(0);
        fail();
    } catch (IllegalStateException e) {
        assertTrue(e.getCause() instanceof NumberFormatException);
    }
}
Also used : VCardParameters(ezvcard.parameter.VCardParameters) Pid(ezvcard.parameter.Pid) Test(org.junit.Test)

Example 30 with VCardParameters

use of ezvcard.parameter.VCardParameters in project ez-vcard by mangstadt.

the class PropertyAsserter method reset.

private void reset() {
    group = null;
    parameters = new VCardParameters();
    _reset();
}
Also used : VCardParameters(ezvcard.parameter.VCardParameters)

Aggregations

VCardParameters (ezvcard.parameter.VCardParameters)32 Test (org.junit.Test)24 JCardDataStreamListener (ezvcard.io.json.JCardRawReader.JCardDataStreamListener)12 VCard (ezvcard.VCard)5 VCardVersion (ezvcard.VCardVersion)5 VCardPropertyScribe (ezvcard.io.scribe.VCardPropertyScribe)4 VCardDataType (ezvcard.VCardDataType)3 EmbeddedVCardException (ezvcard.io.EmbeddedVCardException)3 SkipMeException (ezvcard.io.SkipMeException)3 VCardProperty (ezvcard.property.VCardProperty)3 StringWriter (java.io.StringWriter)3 Pid (ezvcard.parameter.Pid)2 VObjectParameters (com.github.mangstadt.vinnie.VObjectParameters)1 ParseContext (ezvcard.io.ParseContext)1 JCardValue (ezvcard.io.json.JCardValue)1 Xml (ezvcard.property.Xml)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 QName (javax.xml.namespace.QName)1