ParserUtil { public static Map<String, String> parseGeneratorParameters(String parameter) { if (parameter == null || parameter.isEmpty()) return Collections.emptyMap(); HashMap<String, String> map = new HashMap<>(); String[] parts = parameter.split(","); for (String part : parts) { int equalsIndex = part.indexOf("="); if (equalsIndex == -1) { map.put(part, ""); } else { String key = part.substring(0, equalsIndex); String value = part.substring(equalsIndex + 1); map.put(key, value); } } return map; }  static Map<String, String> getGeneratorParameters(CodeGeneratorRequest request); static Map<String, String> parseGeneratorParameters(String parameter); static CodeGeneratorResponse asErrorWithStackTrace(Exception e); static CodeGeneratorResponse asError(String errorMessage);  }
@Test public void parseEmptyParameters() { assertTrue(ParserUtil.parseGeneratorParameters("").isEmpty()); }
@Test public void parseSingleParameter() { assertEquals("value",ParserUtil.parseGeneratorParameters("key=value").get("key")); assertEquals("",ParserUtil.parseGeneratorParameters("key").get("key")); }
@Test public void parseMultiParameter() { Map<String,String> params = ParserUtil.parseGeneratorParameters("key1=value1,key2=value2,key3"); assertEquals("value1",params.get("key1")); assertEquals("value2",params.get("key2")); assertEquals("",params.get("key3")); }