### Question:
SMTPConfigStringToMapConverter { public Map<String,String> convertToMap(String smtpConfigString) { Map<String,String> map = new TreeMap<>(); if (smtpConfigString==null) { return map; } String[] splitted = smtpConfigString.split(","); for (String splitter: splitted) { String[] keyValuePair = splitter.split("="); if (keyValuePair==null || keyValuePair.length!=2) { continue; } String key= keyValuePair[0]; String value= keyValuePair[1]; if (key==null || value==null) { continue; } map.put(key.trim(), value.trim()); } return map; }  Map<String,String> convertToMap(String smtpConfigString);  }### Answer:
@Test public void null_results_in_empty_map() { Map<String, String> map = converterToTest.convertToMap(null); assertNotNull(map); assertTrue(map.isEmpty()); }
@Test public void empty_results_in_empty_map() { Map<String, String> map = converterToTest.convertToMap(""); assertNotNull(map); assertTrue(map.isEmpty()); }
@Test public void one_entry_all_correct_set() { Map<String, String> map = converterToTest.convertToMap("mail.smtp.auth=false"); assertConfig(map).with("mail.smtp.auth", "false"); }
@Test public void one_entry_all_correct_set_but_spaces() { Map<String, String> map = converterToTest.convertToMap("mail.smtp.auth = false"); assertConfig(map).with("mail.smtp.auth", "false"); }
@Test public void two_entry_all_correct_set_but_spaces() { Map<String, String> map = converterToTest.convertToMap("mail.smtp.auth = false,mail.smtp.auth.mechanism=PLAIN"); assertConfig(map).with("mail.smtp.auth", "false").with("mail.smtp.auth.mechanism", "PLAIN"); }
@Test public void one_entry_no_value() { Map<String, String> map = converterToTest.convertToMap("mail.smtp.auth="); assertConfig(map).without("mail.smtp.auth"); }