use of sqlite.kripton111.model.PhoneNumber in project data-transfer-project by google.
the class GoogleContactsImportConversionTest method testConversionToGooglePhones.
@Test
public void testConversionToGooglePhones() {
// Set up test: vCard with 2 primary phone numbers and 1 secondary phone number
String primaryValue1 = "334-844-4244";
String primaryValue2 = "411";
String secondaryValue = "(555) 867-5309";
Telephone primaryTelephone1 = new Telephone(primaryValue1);
primaryTelephone1.setPref(VCARD_PRIMARY_PREF);
Telephone primaryTelephone2 = new Telephone(primaryValue2);
primaryTelephone2.setPref(VCARD_PRIMARY_PREF);
Telephone secondaryTelephone = new Telephone(secondaryValue);
secondaryTelephone.setPref(VCARD_PRIMARY_PREF + 1);
// Add numbers to vCard. Order shouldn't matter.
VCard vCard = defaultVCard;
vCard.addTelephoneNumber(secondaryTelephone);
vCard.addTelephoneNumber(primaryTelephone1);
vCard.addTelephoneNumber(primaryTelephone2);
// Run test
Person person = GoogleContactsImporter.convert(vCard);
// Check results
// Correct number of phone numbers
assertThat(person.getPhoneNumbers().size()).isEqualTo(3);
// Check primary phone numbers
List<PhoneNumber> actualPrimaryNumbers = person.getPhoneNumbers().stream().filter(a -> a.getMetadata().getPrimary()).collect(Collectors.toList());
List<String> actualPrimaryNumberStrings = getValuesFromFields(actualPrimaryNumbers, PhoneNumber::getValue);
assertThat(actualPrimaryNumberStrings).containsExactly(primaryValue1, primaryValue2);
// Check secondary phone numbers
List<PhoneNumber> actualSecondaryNumbers = person.getPhoneNumbers().stream().filter(a -> !a.getMetadata().getPrimary()).collect(Collectors.toList());
List<String> actualSecondaryNumberStrings = getValuesFromFields(actualSecondaryNumbers, PhoneNumber::getValue);
assertThat(actualSecondaryNumberStrings).containsExactly(secondaryValue);
}
Aggregations