private static StructuredName convertToVCardNameSingle(Name personName) { StructuredName structuredName = new StructuredName(); structuredName.setFamily(personName.getFamilyName()); structuredName.setGiven(personName.getGivenName()); structuredName.setParameter( SOURCE_PARAM_NAME_TYPE, personName.getMetadata().getSource().getType()); // TODO(olsona): address formatting, structure, phonetics, suffixes, prefixes return structuredName; }
private static StructuredName makeStructuredName( String givenName, String familyName, @Nullable String sourceType) { StructuredName structuredName = new StructuredName(); structuredName.setGiven(givenName); structuredName.setFamily(familyName); if (sourceType != null) { structuredName.setParameter(SOURCE_PARAM_NAME_TYPE, sourceType); } return structuredName; }
@Test public void importFirstResources() throws IOException { // Set up: small number of VCards to be imported int numberOfVCards = 5; List<VCard> vCardList = new LinkedList<>(); for (int i = 0; i < numberOfVCards; i++) { StructuredName structuredName = new StructuredName(); structuredName.setFamily("Family" + i); structuredName.setParameter(SOURCE_PARAM_NAME_TYPE, CONTACT_SOURCE_TYPE); VCard vCard = new VCard(); vCard.setStructuredName(structuredName); vCardList.add(vCard); } String vCardString = GoogleContactsExporter.makeVCardString(vCardList); ContactsModelWrapper wrapper = new ContactsModelWrapper(vCardString); // Run test contactsService.importItem(UUID.randomUUID(), null, wrapper); // Check that the right methods were called verify(people, times(numberOfVCards)).createContact(any(Person.class)); verify(createContact, times(numberOfVCards)).execute(); } }