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();
}
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();
}
Aggregations