### Question:
SecurityQuestionTransformer implements ConfigTransformer<Map<String, Map<String, String>>> { @Override public Map<String, Map<String, String>> transform(Set<String> values, Class<?> parameterType) { Map<String, Map<String, String>> localisedQuestions = new HashMap<>(); for (String question : values) { Matcher matcher = QUESTION_PATTERN.matcher(question); if (!matcher.matches()) { throw new IllegalArgumentException( "Expected question format id|locale|question but got " + question); } String id = matcher.group(1); String locale = matcher.group(2); String text = matcher.group(3); if (!localisedQuestions.containsKey(id)) { localisedQuestions.put(id, new HashMap<String, String>()); } localisedQuestions.get(id).put(locale, text); } return localisedQuestions; }  @Override Map<String, Map<String, String>> transform(Set<String> values, Class<?> parameterType);  }### Answer:
@Test public void parsesValidMessages() { Set<String> questions = asSet("123|en|Some question", "abc|fr|Another question"); Map<String, Map<String, String>> parsedQuestions = securityQuestionTransformer.transform(questions, Map.class); assertThat(parsedQuestions).containsEntry("123", Collections.singletonMap("en", "Some question")); assertThat(parsedQuestions).containsEntry("abc", Collections.singletonMap("fr", "Another question")); }
@Test(expectedExceptions = IllegalArgumentException.class) public void failsToParseInvalidMessage() { Set<String> questions = asSet("en|Some question", "fr-Another question"); securityQuestionTransformer.transform(questions, Map.class); }