import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Map;
import org.testng.annotations.Test;
{ "a", "b*c", "cde" }, "*"));
}
- /**
- * Test the method that parses lines like <br>
- * ID=2345;Name=Something;
- */
- @Test(groups = { "Functional" })
- public void testParseNameValuePairs()
- {
- char[] separators = new char[] { ' ' };
- assertTrue(StringUtils.parseNameValuePairs(null, ";", separators)
- .isEmpty());
- assertTrue(StringUtils.parseNameValuePairs("", ";", separators)
- .isEmpty());
- assertTrue(StringUtils.parseNameValuePairs("hello=world", ";",
- separators).isEmpty());
-
- Map<String, List<String>> map = StringUtils.parseNameValuePairs(
- "hello world", ";", separators);
- assertEquals(1, map.size());
- assertEquals(1, map.get("hello").size());
- assertEquals("world", map.get("hello").get(0));
-
- separators = new char[] { ' ', '=' };
- map = StringUtils
- .parseNameValuePairs(
- "Method= manual curation ;nothing; Notes F2=S ; Notes=Metal; Type=",
- ";", separators);
-
- // Type is ignored as no value was supplied
- assertEquals(2, map.size());
-
- // equals separator used ahead of space separator:
- assertEquals(1, map.get("Method").size());
- assertEquals("manual curation", map.get("Method").get(0)); // trimmed
-
- assertEquals(2, map.get("Notes").size());
- // space separator used ahead of equals separator
- assertEquals("F2=S", map.get("Notes").get(0));
- assertEquals("Metal", map.get("Notes").get(1));
- }
-
@Test(groups = { "Functional" })
public void testListToDelimitedString()
{