### Question:
Configuration { public void addTemplatesDir(String templateDir) { templatesDirModified = true; addTemplatesDir(templateDir, false); }  static Configuration getDefault(); static String[] getSupportedLanguages(); static String getApplicationHome(); void resetModifiedFlag(); @Transient boolean isTemplatesDirModified(); int getPort(); void setPort(int port); boolean isShowTestData(); void setShowTestData(boolean showTestData); boolean isWebDevelopmentMode(); void setWebDevelopmentMode(boolean webDevelopmentMode); List<ConfigurationTemplatesDir> getTemplatesDirs(); void setTemplatesDirs(List<ConfigurationTemplatesDir> templatesDirs); void addTemplatesDir(String templateDir); void addTemplatesDir(String templateDir, boolean recursive); void copyFrom(Configuration other);  }### Answer:
@Test void configurationSaveTest() throws Exception { Preferences preferences = mock(Preferences.class); ConfigurationHandler configurationHandler = new ConfigurationHandler(preferences); Configuration configuration = configurationHandler.getConfiguration(); configurationHandler.save(); configuration.addTemplatesDir(null); configurationHandler.save(); configuration.addTemplatesDir(""); configurationHandler.save(); configuration.addTemplatesDir(" "); configurationHandler.save(); configuration.addTemplatesDir(DIR1); configurationHandler.save(); configuration.addTemplatesDir(DIR2); configuration.addTemplatesDir(" "); configurationHandler.save(); configuration.addTemplatesDir(DIR3); configurationHandler.save(); InOrder inOrder = Mockito.inOrder(preferences); inOrder.verify(preferences).remove(ConfigurationHandler.TEMPLATES_DIRS); inOrder.verify(preferences).remove(ConfigurationHandler.TEMPLATES_DIRS); inOrder.verify(preferences).remove(ConfigurationHandler.TEMPLATES_DIRS); inOrder.verify(preferences).remove(ConfigurationHandler.TEMPLATES_DIRS); inOrder.verify(preferences).put(ConfigurationHandler.TEMPLATES_DIRS, "[{\"directory\":\"" + DIR1 + "\",\"recursive\":false}]"); inOrder.verify(preferences).put(ConfigurationHandler.TEMPLATES_DIRS, "[{\"directory\":\"" + DIR1 + "\",\"recursive\":false},{\"directory\":\"" + DIR2 + "\",\"recursive\":false}]"); inOrder.verify(preferences).put(ConfigurationHandler.TEMPLATES_DIRS, "[{\"directory\":\"" + DIR1 + "\",\"recursive\":false},{\"directory\":\"" + DIR2 + "\",\"recursive\":false},{\"directory\":\"" + DIR3b + "\",\"recursive\":false}]"); inOrder.verify(preferences).flush(); inOrder.verifyNoMoreInteractions(); }