use of ezvcard.io.json.JCardRawReader.JCardDataStreamListener in project ez-vcard by mangstadt.
the class JCardRawReaderTest method ignore_other_json.
@Test
public void ignore_other_json() throws Throwable {
// @formatter:off
String json = "{" + "\"website\": \"example.com\"," + "\"vcard\":" + "[\"vcard\"," + "[" + "[\"prop\", {}, \"text\", \"value\"]" + "]" + "]" + "}";
// @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.single("value"));
verifyNoMoreInteractions(listener);
}
use of ezvcard.io.json.JCardRawReader.JCardDataStreamListener in project ez-vcard by mangstadt.
the class JCardRawReaderTest method group.
@Test
public void group() throws Throwable {
// @formatter:off
String json = "[\"vcard\"," + "[" + "[\"prop\", { \"group\": \"one\" }, \"text\", \"value\"]" + "]" + "]";
// @formatter:on
JCardRawReader reader = createReader(json);
JCardDataStreamListener listener = mock(JCardDataStreamListener.class);
reader.readNext(listener);
verify(listener).beginVCard();
verify(listener).readProperty("one", "prop", new VCardParameters(), VCardDataType.TEXT, JCardValue.single("value"));
verifyNoMoreInteractions(listener);
}
use of ezvcard.io.json.JCardRawReader.JCardDataStreamListener in project ez-vcard by mangstadt.
the class JCardRawReaderTest method empty.
@Test
public void empty() throws Throwable {
// @formatter:off
String json = "";
// @formatter:on
JCardRawReader reader = createReader(json);
JCardDataStreamListener listener = mock(JCardDataStreamListener.class);
reader.readNext(listener);
verify(listener, never()).beginVCard();
verifyNoMoreInteractions(listener);
}
use of ezvcard.io.json.JCardRawReader.JCardDataStreamListener in project ez-vcard by mangstadt.
the class JCardRawReaderTest method no_vcard.
@Test
public void no_vcard() throws Throwable {
// @formatter:off
String json = "{" + "\"foo\": \"bar\"" + "}";
// @formatter:on
JCardRawReader reader = createReader(json);
JCardDataStreamListener listener = mock(JCardDataStreamListener.class);
reader.readNext(listener);
verify(listener, never()).beginVCard();
verifyNoMoreInteractions(listener);
}
use of ezvcard.io.json.JCardRawReader.JCardDataStreamListener in project ez-vcard by mangstadt.
the class JCardRawReaderTest method data_type_unrecognized.
@Test
public void data_type_unrecognized() throws Throwable {
// @formatter:off
String json = "[\"vcard\"," + "[" + "[\"prop\", {}, \"foo\", \"value\"]" + "]" + "]";
// @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.get("foo"), JCardValue.single("value"));
verifyNoMoreInteractions(listener);
}
Aggregations