Search in sources :

Example 21 with Telephone

use of ezvcard.property.Telephone in project ez-vcard by mangstadt.

the class TelephoneScribeTest method prepareParameters_pref_parameter.

/**
 * If properties contain "PREF" parameters and they're being marshalled to
 * 2.1/3.0, then it should find the type with the lowest PREF value and add
 * "TYPE=pref" to it.
 */
@Test
public void prepareParameters_pref_parameter() {
    VCard vcard = new VCard();
    Telephone tel2 = new Telephone((String) null);
    tel2.setPref(2);
    vcard.addTelephoneNumber(tel2);
    Telephone tel1 = new Telephone((String) null);
    tel1.setPref(1);
    vcard.addTelephoneNumber(tel1);
    Telephone tel3 = new Telephone((String) null);
    vcard.addTelephoneNumber(tel3);
    // 2.1 and 3.0 converts the lowest PREF parameter to "TYPE=pref", and removes all the rest
    sensei.assertPrepareParams(tel1).versions(V2_1, V3_0).vcard(vcard).expected("TYPE", "pref").run();
    sensei.assertPrepareParams(tel2).versions(V2_1, V3_0).vcard(vcard).run();
    sensei.assertPrepareParams(tel3).versions(V2_1, V3_0).vcard(vcard).run();
    // 4.0 keeps it
    sensei.assertPrepareParams(tel1).versions(V4_0).vcard(vcard).expected("PREF", "1").run();
    sensei.assertPrepareParams(tel2).versions(V4_0).vcard(vcard).expected("PREF", "2").run();
    sensei.assertPrepareParams(tel3).versions(V4_0).vcard(vcard).run();
}
Also used : Telephone(ezvcard.property.Telephone) VCard(ezvcard.VCard) Test(org.junit.Test)

Example 22 with Telephone

use of ezvcard.property.Telephone in project ez-vcard by mangstadt.

the class TelephoneScribeTest method prepareParameters_type_pref.

/**
 * If a property contains a "TYPE=pref" parameter and it's being marshalled
 * to 4.0, it should replace "TYPE=pref" with "PREF=1".
 */
@Test
public void prepareParameters_type_pref() {
    // TODO move test to VCardPropertyScribeTest
    Telephone property = new Telephone((String) null);
    property.getTypes().add(TelephoneType.PREF);
    // 2.1 and 3.0 keep it
    sensei.assertPrepareParams(property).versions(V2_1, V3_0).expected("TYPE", "pref").run();
    // 4.0 converts it to "PREF=1"
    sensei.assertPrepareParams(property).versions(V4_0).expected("PREF", "1").run();
}
Also used : Telephone(ezvcard.property.Telephone) Test(org.junit.Test)

Aggregations

Telephone (ezvcard.property.Telephone)22 VCard (ezvcard.VCard)12 StructuredName (ezvcard.property.StructuredName)11 Test (org.junit.Test)10 Address (ezvcard.property.Address)8 TelUri (ezvcard.util.TelUri)8 Email (ezvcard.property.Email)6 Birthday (ezvcard.property.Birthday)5 Timezone (ezvcard.property.Timezone)5 UtcOffset (ezvcard.util.UtcOffset)5 Person (com.google.api.services.people.v1.model.Person)4 PhoneNumber (com.google.api.services.people.v1.model.PhoneNumber)4 Anniversary (ezvcard.property.Anniversary)4 Geo (ezvcard.property.Geo)4 Key (ezvcard.property.Key)4 List (java.util.List)3 Address (com.google.api.services.people.v1.model.Address)2 EmailAddress (com.google.api.services.people.v1.model.EmailAddress)2 Name (com.google.api.services.people.v1.model.Name)2 Truth.assertThat (com.google.common.truth.Truth.assertThat)2