public void testParseExtrasIgnoreUnhandled() {
    final ContactsSource source = getSource();
    final EntityDelta state = getEntity(TEST_ID);

    // We should silently ignore types unsupported by source
    final Bundle extras = new Bundle();
    extras.putString(Insert.POSTAL, TEST_POSTAL);
    EntityModifier.parseExtras(mContext, source, state, extras);

    assertNull("Broke source rules", state.getMimeEntries(StructuredPostal.CONTENT_ITEM_TYPE));
  }
  public void testParseExtrasJobTitle() {
    final ContactsSource source = getSource();
    final EntityDelta state = getEntity(TEST_ID);

    // Make sure that we create partial Organizations
    final Bundle extras = new Bundle();
    extras.putString(Insert.JOB_TITLE, TEST_NAME);
    EntityModifier.parseExtras(mContext, source, state, extras);

    final int count = state.getMimeEntries(Organization.CONTENT_ITEM_TYPE).size();
    assertEquals("Expected to create organization", 1, count);
  }
  public void testParseExtrasExistingName() {
    final ContactsSource source = getSource();
    final DataKind kindName = source.getKindForMimetype(StructuredName.CONTENT_ITEM_TYPE);

    // Build "before" name
    final ContentValues first = new ContentValues();
    first.put(Data._ID, TEST_ID);
    first.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
    first.put(StructuredName.GIVEN_NAME, TEST_NAME);

    // Parse extras, making sure we keep single name
    final EntityDelta state = getEntity(TEST_ID, first);
    final Bundle extras = new Bundle();
    extras.putString(Insert.NAME, TEST_NAME2);
    EntityModifier.parseExtras(mContext, source, state, extras);

    final int nameCount = state.getMimeEntriesCount(StructuredName.CONTENT_ITEM_TYPE, true);
    assertEquals("Unexpected names", 1, nameCount);
  }
  public void testParseExtrasIgnoreLimit() {
    final ContactsSource source = getSource();
    final DataKind kindIm = source.getKindForMimetype(Im.CONTENT_ITEM_TYPE);

    // Build "before" IM
    final ContentValues first = new ContentValues();
    first.put(Data._ID, TEST_ID);
    first.put(Data.MIMETYPE, Im.CONTENT_ITEM_TYPE);
    first.put(Im.DATA, TEST_IM);

    final EntityDelta state = getEntity(TEST_ID, first);
    final int beforeCount = state.getMimeEntries(Im.CONTENT_ITEM_TYPE).size();

    // We should ignore data that doesn't fit source rules, since source
    // only allows single Im
    final Bundle extras = new Bundle();
    extras.putInt(Insert.IM_PROTOCOL, Im.PROTOCOL_GOOGLE_TALK);
    extras.putString(Insert.IM_HANDLE, TEST_IM);
    EntityModifier.parseExtras(mContext, source, state, extras);

    final int afterCount = state.getMimeEntries(Im.CONTENT_ITEM_TYPE).size();
    assertEquals("Broke source rules", beforeCount, afterCount);
  }