@Test public void toMap() { String tokens = "1:Ted|2:Mary"; MutableMap<String, String> results = StringIterate.tokensToMap(tokens); Verify.assertSize(2, results); Verify.assertContainsKeyValue("1", "Ted", results); Verify.assertContainsKeyValue("2", "Mary", results); }
@Test public void toMapWithFunctions() { String tokens = "1:Ted|2:Mary"; Function<String, String> stringPassThruFunction = Functions.getPassThru(); MutableMap<Integer, String> results = StringIterate.tokensToMap( tokens, "|", ":", Functions.getStringToInteger(), stringPassThruFunction); Verify.assertSize(2, results); Verify.assertContainsKeyValue(1, "Ted", results); Verify.assertContainsKeyValue(2, "Mary", results); }