### Question:
FilePreferences implements Preferences, LifecycleCallback { @Override public <T> T get(String key, Class<T> clazz) { return rootNode.get(key, clazz); } FilePreferences(File preferencesFile); @Override T get(String key, Class<T> clazz); @Override void put(String key, Object value); @Override void merge(String key, Object value); @Override void delete(String key); @Override Preferences path(String key); @Override Preferences walk(String key); @Override boolean pathExists(String key); @Override void notify(LifecycleEvent lifecycleEvent); FilePreferences setDisableSaveOnChanges();  }### Answer:
@Test public void testPerfectPojoMatchPreferences() throws IOException { FilePreferences filePreferences = getPreferencesFile("perfectPojoMatchPreferences.json"); FakePojo fakePojo = filePreferences.get(USELESS_POJO_KEY, FakePojo.class); assertThat(FakePojo.getDumbInstance()).isEqualToComparingFieldByField(fakePojo); }
@Test public void testMorePropertiesThanPojoPreferences() throws IOException { FilePreferences filePreferences = getPreferencesFile("morePropertiesThanPojoPreferences.json"); FakePojo fakePojo = filePreferences.get(USELESS_POJO_KEY, FakePojo.class); assertThat(FakePojo.getDumbInstance()).isEqualToComparingFieldByField(fakePojo); }
@Test public void testTwoConsumersWithDifferentsPojo() throws IOException { FilePreferences filePreferences = getPreferencesFile("morePropertiesThanPojoPreferences.json"); FakePojo fakePojo = filePreferences.get(USELESS_POJO_KEY, FakePojo.class); assertThat(FakePojo.getDumbInstance()).isEqualToComparingFieldByField(fakePojo); OtherPojo otherPojo = filePreferences.get(USELESS_POJO_KEY, OtherPojo.class); assertThat(OtherPojo.getInstance().withName(DUMB_POJO_NAME)).isEqualToComparingFieldByField(otherPojo); }
@Test public void testLessPropertiesThanPojoPreferences() throws IOException { FilePreferences filePreferences = getPreferencesFile("lessPropertiesThanPojoPreferences.json"); FakePojo fakePojo = filePreferences.get(USELESS_POJO_KEY, FakePojo.class); assertThat(FakePojo.getDumbInstance().withName(null)).isEqualToComparingFieldByField(fakePojo); }