//TEL
{
List<TelType> it = vcard.getTels();
assertEquals(2, it.size());
TelType f = it.get(0);
assertEquals("905-666-1234", f.getTelephone());
List<TelParamType> types = f.getParams();
assertEquals(1, types.size());
assertTrue(types.contains(TelParamType.CELL));
List<ExtendedParamType> xlist = f.getExtendedParams();
assertEquals(1, xlist.size());
assertEquals("X-COUCHDB-UUID", xlist.get(0).getTypeName());
assertEquals("c2fa1caa-2926-4087-8971-609cfc7354ce".toUpperCase(), xlist.get(0).getTypeValue());
f = it.get(1);
assertEquals("905-555-1234", f.getTelephone());
types = f.getParams();
assertEquals(2, types.size());
assertTrue(types.contains(TelParamType.WORK));
assertTrue(types.contains(TelParamType.VOICE));
xlist = f.getExtendedParams();
assertEquals(1, xlist.size());
assertEquals("X-COUCHDB-UUID", xlist.get(0).getTypeName());
assertEquals("fbfb2722-4fd8-4dbf-9abd-eeb24072fd8e".toUpperCase(), xlist.get(0).getTypeValue());
}
//UID
{
UidType f = vcard.getUid();
assertEquals("477343c8e6bf375a9bac1f96a5000837", f.getUid());
}
//N
{
NType f = vcard.getN();
assertEquals("Doe", f.getFamilyName());
assertEquals("John", f.getGivenName());
List<String> it = f.getAdditionalNames();
assertEquals(1, it.size());
assertEquals("Richter, James", it.get(0));
it = f.getHonorificPrefixes();
assertEquals(1, it.size());
assertEquals("Mr.", it.get(0));
it = f.getHonorificSuffixes();
assertEquals(1, it.size());
assertEquals("Sr.", it.get(0));
}
//FN
{
FNType f = vcard.getFN();
assertEquals("Mr. John Richter, James Doe Sr.", f.getFormattedName());
}
//NICKNAME
{
NicknameType f = vcard.getNicknames();
List<String> it = f.getNicknames();
assertEquals(1, it.size());
assertEquals("Johny", it.get(0));
}
//ORG
{
OrgType f = vcard.getOrg();
assertEquals("IBM", f.getOrgName());
List<String> it = f.getOrgUnits();
assertEquals(2, it.size());
assertEquals("Accounting", it.get(0));
assertEquals("Dungeon", it.get(1));
}
//TITLE
{
TitleType f = vcard.getTitle();
assertEquals("Money Counter", f.getTitle());
}
//CATEGORIES
{
CategoriesType f = vcard.getCategories();
List<String> it = f.getCategories();
assertEquals(1, it.size());
assertEquals("VIP", it.get(0));
}
//NOTE
{
List<NoteType> it = vcard.getNotes();
assertEquals(1, it.size());
NoteFeature f = it.get(0);
assertEquals("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.", f.getNote());
}
//EMAIL
{
List<EmailType> it = vcard.getEmails();
assertEquals(1, it.size());
EmailType f = it.get(0);
assertEquals("john.doe@ibm.com", f.getEmail());
List<EmailParamType> types = f.getParams();
assertEquals(1, types.size());
assertTrue(types.contains(EmailParamType.WORK));
List<ExtendedParamType> xlist = f.getExtendedParams();
assertEquals(1, xlist.size());
assertEquals("X-COUCHDB-UUID", xlist.get(0).getTypeName());
assertEquals("83a75a5d-2777-45aa-bab5-76a4bd972490".toUpperCase(), xlist.get(0).getTypeValue());
}
//ADR
{
List<AdrType> it = vcard.getAdrs();
assertEquals(1, it.size());
AdrType f = it.get(0);
assertEquals("ASB-123", f.getPostOfficeBox());
assertEquals("", f.getExtendedAddress());
assertEquals("15 Crescent moon drive", f.getStreetAddress());
assertEquals("Albaney", f.getLocality());
assertEquals("New York", f.getRegion());
assertEquals("12345", f.getPostalCode());
/*
* This would fail under normal circumstances because Evolution
* assumes that only the first white-space character is discarded
* as part of the folding and that the rest are preserved. If every
* application followed the RFC standard then that would be so, but
* it is not.
*/
assertEquals("United States of America", f.getCountryName());
List<AdrParamType> types = f.getParams();
assertEquals(1, types.size());
assertTrue(types.contains(AdrParamType.HOME));
}
//BDAY
{
BDayType f = vcard.getBDay();
assertEquals(1980, f.getBirthday().get(Calendar.YEAR));
assertEquals(Calendar.MARCH, f.getBirthday().get(Calendar.MONTH));
assertEquals(22, f.getBirthday().get(Calendar.DAY_OF_MONTH));
}
//REV
{
RevType f = vcard.getRev();
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
c.clear();
c.set(Calendar.YEAR, 2012);
c.set(Calendar.MONTH, Calendar.MARCH);
c.set(Calendar.DAY_OF_MONTH, 5);
c.set(Calendar.HOUR_OF_DAY, 13);
c.set(Calendar.MINUTE, 32);
c.set(Calendar.SECOND, 54);
Calendar actual = f.getRevision();
assertEquals(c.getTime(), actual.getTime());
}
//custom types
{
List<ExtendedType> it = vcard.getExtendedTypes();
assertEquals(7, it.size());
ExtendedType f = it.get(0);
assertEquals("X-COUCHDB-APPLICATION-ANNOTATIONS", f.getExtendedName());
assertEquals("{\"Evolution\":{\"revision\":\"2012-03-05T13:32:54Z\"}}", f.getExtendedValue());
f = it.get(1);
assertEquals("X-AIM", f.getExtendedName());
assertEquals("johnny5@aol.com", f.getExtendedValue());
List<ExtendedParamType> xParamTypes = f.getExtendedParams();
assertEquals(2, xParamTypes.size());
ExtendedParamType xParamType = xParamTypes.get(0);
assertEquals("TYPE", xParamType.getTypeName());
assertEquals("HOME", xParamType.getTypeValue());
xParamType = xParamTypes.get(1);
assertEquals("X-COUCHDB-UUID",xParamType.getTypeName());
assertEquals("cb9e11fc-bb97-4222-9cd8-99820c1de454".toUpperCase(), xParamType.getTypeValue());
f = it.get(2);
assertEquals("X-EVOLUTION-FILE-AS", f.getExtendedName());
assertEquals("Doe, John", f.getExtendedValue());
f = it.get(3);
assertEquals("X-EVOLUTION-SPOUSE", f.getExtendedName());
assertEquals("Maria", f.getExtendedValue());
f = it.get(4);
assertEquals("X-EVOLUTION-MANAGER", f.getExtendedName());
assertEquals("Big Blue", f.getExtendedValue());
f = it.get(5);
assertEquals("X-EVOLUTION-ASSISTANT", f.getExtendedName());
assertEquals("Little Red", f.getExtendedValue());
f = it.get(6);
assertEquals("X-EVOLUTION-ANNIVERSARY", f.getExtendedName());
assertEquals("1980-03-22", f.getExtendedValue());
}
VCardImpl vcard2 = (VCardImpl)vcard;
if(vcard2.hasErrors()) {