<commit_before>package com.wmba.preference.test;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.wmba.preference.ObjectPersistentPreference;
import com.wmba.preference.Preference;
import com.wmba.preference.PreferenceSerializer;

import java.lang.reflect.Type;

public class MutableObjectPersistentPreferenceTest extends MutableObjectMemoryPreferenceTest {
  @Override protected Preference<TestObject> createPreference(TestObject defaultValue) {
    final Gson gson = new Gson();
    PreferenceSerializer preferenceSerializer = new PreferenceSerializer() {
      @Override public String serialize(Object value) {
        return gson.toJson(value);
      }

      @Override public Object deserialize(String serializedValue, Type type) {
        return gson.fromJson(serializedValue, type);
      }
    };
    return new ObjectPersistentPreference<TestObject>(new MockSharedPreferences(), "test_key",
        preferenceSerializer, new TypeToken<TestObject>() {}.getType(), defaultValue);
  }
}<commit_msg>add copy<commit_after>package com.wmba.preference.test;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.wmba.preference.ObjectPersistentPreference;
import com.wmba.preference.Preference;
import com.wmba.preference.PreferenceSerializer;

import java.lang.reflect.Type;

public class MutableObjectPersistentPreferenceTest extends MutableObjectMemoryPreferenceTest {
  @Override protected Preference<TestObject> createPreference(TestObject defaultValue) {
    final Gson gson = new Gson();
    PreferenceSerializer preferenceSerializer = new PreferenceSerializer() {
      @Override public String serialize(Object value) {
        return gson.toJson(value);
      }

      @Override public Object deserialize(String serializedValue, Type type) {
        return gson.fromJson(serializedValue, type);
      }
    };
    return new ObjectPersistentPreference<TestObject>(new MockSharedPreferences(), "test_key",
        preferenceSerializer, new TypeToken<TestObject>() {}.getType(), defaultValue) {
      @Override protected TestObject copy(TestObject value) {
        return new TestObject(value.getStringValue(), value.getIntValue());
      }
    };
  }
}
{'fraction_non_alphanumeric': 0.09123595505617978, 'fraction_numerical': 0.0, 'mean_word_length': 4.904509283819628, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3233009', 'n_tokens_mistral': 610, 'n_tokens_neox': 611, 'n_words': 130}