test_class.declarator: sharedPreferences
test_class.modifier: private
test_class.original_string: private SharedPreferences sharedPreferences;
test_class.type: SharedPreferences
test_class.var_name: sharedPreferences
test_class.declarator: printStream = System.out
test_class.modifier: private final
test_class.original_string: private final PrintStream printStream = System.out;
test_class.type: PrintStream
test_class.var_name: printStream
test_class.declarator: affectedKeys = Arrays.asList(
              KEY_METADATA_MIGRATED,
              KEY_METADATA_USERNAME,
              KEY_METADATA_PHONENUMBER,
              KEY_METADATA_EMAIL,
              KEY_USERNAME,
              KEY_SELECTED_GOOGLE_ACCOUNT)
test_class.modifier: private final
test_class.original_string: private final List<String> affectedKeys = Arrays.asList(
              KEY_METADATA_MIGRATED,
              KEY_METADATA_USERNAME,
              KEY_METADATA_PHONENUMBER,
              KEY_METADATA_EMAIL,
              KEY_USERNAME,
              KEY_SELECTED_GOOGLE_ACCOUNT);
test_class.type: List<String>
test_class.var_name: affectedKeys
test_class.declarator: sourceKeyValuePairs = {
              {KEY_USERNAME,                  "a user"},
              {KEY_SELECTED_GOOGLE_ACCOUNT,   "a Google email address"}
      }
test_class.modifier: private final
test_class.original_string: private final String[][] sourceKeyValuePairs = {
              {KEY_USERNAME,                  "a user"},
              {KEY_SELECTED_GOOGLE_ACCOUNT,   "a Google email address"}
      };
test_class.type: String[][]
test_class.var_name: sourceKeyValuePairs
test_class.declarator: modifiedMetadataValuePairs = {
              {KEY_METADATA_USERNAME,         "a user--changed"},
              {KEY_METADATA_PHONENUMBER,      "a phone number--changed"},
              {KEY_METADATA_EMAIL,            "an email--changed"},
      }
test_class.modifier: private final
test_class.original_string: private final String[][] modifiedMetadataValuePairs = {
              {KEY_METADATA_USERNAME,         "a user--changed"},
              {KEY_METADATA_PHONENUMBER,      "a phone number--changed"},
              {KEY_METADATA_EMAIL,            "an email--changed"},
      };
test_class.type: String[][]
test_class.var_name: modifiedMetadataValuePairs
test_class.file: collect_app/src/test/java/org/odk/collect/android/preferences/FormMetadataMigratorTest.java
test_class.identifier: FormMetadataMigratorTest
test_case.body: @Test
      public void shouldMigrateDataCorrectly() {
          setPreferencesToPreMigrationValues();
          displayAffectedPreferences("Before calling migrate");
  
          migrate(sharedPreferences);
          displayAffectedPreferences("After calling migrate");
          checkPostMigrationValues();
  
          setPreferencesToValues(modifiedMetadataValuePairs);
          displayAffectedPreferences("After changing metadata");
          migrate(sharedPreferences);
          displayAffectedPreferences("After calling migrate again");
          ensureSecondMigrationCallPreservesMetadata();
      }
test_case.class_method_signature: FormMetadataMigratorTest.shouldMigrateDataCorrectly()
test_case.full_signature: @Test public void shouldMigrateDataCorrectly()
test_case.identifier: shouldMigrateDataCorrectly
test_case.invocations: setPreferencesToPreMigrationValues displayAffectedPreferences migrate displayAffectedPreferences checkPostMigrationValues setPreferencesToValues displayAffectedPreferences migrate displayAffectedPreferences ensureSecondMigrationCallPreservesMetadata
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void shouldMigrateDataCorrectly()
focal_class.declarator: SOURCE_TARGET_VALUE_PAIRS = {
              {KEY_USERNAME,                  KEY_METADATA_USERNAME},
              {KEY_SELECTED_GOOGLE_ACCOUNT,   KEY_METADATA_EMAIL}
      }
focal_class.modifier: static final
focal_class.original_string: static final String[][] SOURCE_TARGET_VALUE_PAIRS = {
              {KEY_USERNAME,                  KEY_METADATA_USERNAME},
              {KEY_SELECTED_GOOGLE_ACCOUNT,   KEY_METADATA_EMAIL}
      };
focal_class.type: String[][]
focal_class.var_name: SOURCE_TARGET_VALUE_PAIRS
focal_class.file: collect_app/src/main/java/org/odk/collect/android/preferences/FormMetadataMigrator.java
focal_class.identifier: FormMetadataMigrator
focal_class.class_method_signature: FormMetadataMigrator.FormMetadataMigrator()
focal_class.full_signature: private  FormMetadataMigrator()
focal_class.identifier: FormMetadataMigrator
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.signature:  FormMetadataMigrator()
focal_class.class_method_signature: FormMetadataMigrator.migrate(SharedPreferences sharedPreferences)
focal_class.full_signature: @SuppressLint("ApplySharedPref") public static void migrate(SharedPreferences sharedPreferences)
focal_class.identifier: migrate
focal_class.modifiers: @SuppressLint("ApplySharedPref") public static
focal_class.parameters: (SharedPreferences sharedPreferences)
focal_class.return: void
focal_class.signature: void migrate(SharedPreferences sharedPreferences)
focal_method.body: @SuppressLint("ApplySharedPref")
      public static void migrate(SharedPreferences sharedPreferences) {
          boolean migrationAlreadyDone = sharedPreferences.getBoolean(KEY_METADATA_MIGRATED, false);
          Timber.i("migrate called, %s",
                  migrationAlreadyDone ? "migration already done" : "will migrate");
  
          if (!migrationAlreadyDone) {
              SharedPreferences.Editor editor = sharedPreferences.edit();
  
              for (String[] pair : SOURCE_TARGET_VALUE_PAIRS) {
                  String migratingValue = sharedPreferences.getString(pair[0], "").trim();
                  if (!migratingValue.isEmpty()) {
                      Timber.i("Copying %s from %s to %s", migratingValue, pair[0], pair[1]);
                      editor.putString(pair[1], migratingValue);
                  }
              }
  
              // Save that we’ve migrated the values
              editor.putBoolean(KEY_METADATA_MIGRATED, true);
              editor.commit();
          }
      }
focal_method.class_method_signature: FormMetadataMigrator.migrate(SharedPreferences sharedPreferences)
focal_method.full_signature: @SuppressLint("ApplySharedPref") public static void migrate(SharedPreferences sharedPreferences)
focal_method.identifier: migrate
focal_method.invocations: getBoolean i edit trim getString isEmpty i putString putBoolean commit
focal_method.modifiers: @SuppressLint("ApplySharedPref") public static
focal_method.parameters: (SharedPreferences sharedPreferences)
focal_method.return: void
focal_method.signature: void migrate(SharedPreferences sharedPreferences)