예제 #1
0
  /**
   * 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() {
    // TODO move this test to VCardPropertyScribeTest (except for the "label" part)
    VCard vcard = new VCard();

    Address adr2 = new Address();
    adr2.setPref(2);
    vcard.addAddress(adr2);

    Address adr1 = new Address();
    adr1.setPref(1);
    vcard.addAddress(adr1);

    Address adr3 = new Address();
    vcard.addAddress(adr3);

    // 2.1 and 3.0 converts the lowest PREF parameter to "TYPE=pref", and removes all the rest
    sensei
        .assertPrepareParams(adr1)
        .versions(V2_1, V3_0)
        .vcard(vcard)
        .expected("TYPE", "pref")
        .run();
    sensei.assertPrepareParams(adr2).versions(V2_1, V3_0).vcard(vcard).run();
    sensei.assertPrepareParams(adr3).versions(V2_1, V3_0).vcard(vcard).run();

    // 4.0 keeps it
    sensei.assertPrepareParams(adr1).versions(V4_0).vcard(vcard).expected("PREF", "1").run();
    sensei.assertPrepareParams(adr2).versions(V4_0).vcard(vcard).expected("PREF", "2").run();
    sensei.assertPrepareParams(adr3).versions(V4_0).vcard(vcard).run();
  }
예제 #2
0
  /**
   * 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() {
    Address property = new Address();
    property.addType(AddressType.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();
  }
예제 #3
0
  @Test
  public void prepareParameters_label() {
    Address property = new Address();
    property.setLabel("label");

    // 2.1 and 3.0 should remove it
    sensei.assertPrepareParams(property).versions(V2_1, V3_0).run();

    // 4.0 should keep it
    sensei.assertPrepareParams(property).versions(V4_0).expected("LABEL", "label").run();
  }
예제 #4
0
  @Test
  public void prepareParameters_pref_parameter() {
    Email property = new Email("*****@*****.**");
    property.setPref(1);

    VCard vcard = new VCard();
    vcard.addEmail(property);

    sensei
        .assertPrepareParams(property)
        .versions(V2_1, V3_0)
        .vcard(vcard)
        .expected("TYPE", "pref")
        .run();
    sensei.assertPrepareParams(property).versions(V4_0).vcard(vcard).expected("PREF", "1").run();
  }
예제 #5
0
  @Test
  public void prepareParameters_type_pref() {
    Email property = new Email("*****@*****.**");
    property.addType(EmailType.PREF);

    sensei.assertPrepareParams(property).versions(V2_1, V3_0).expected("TYPE", "pref").run();
    sensei.assertPrepareParams(property).versions(V4_0).expected("PREF", "1").run();
  }