### Question:
LocaleMessageTransformer implements ConfigTransformer<Map<Locale, String>> { @Override public Map<Locale, String> transform(Set<String> values, Class<?> parameterType) { Map<Locale, String> messageTranslations = new HashMap<>(); for (String value : values) { Matcher matcher = LOCALE_MESSAGE_PATTERN.matcher(value); if (!matcher.matches()) { throw new IllegalArgumentException( "Expected format locale|message but got " + value); } String localeString = matcher.group(1); String message = matcher.group(2); messageTranslations.put(getLocale(localeString), message); } return messageTranslations; }  @Override Map<Locale, String> transform(Set<String> values, Class<?> parameterType);  }### Answer:
@Test public void parsesValidMessages() { Set<String> messages = asSet("en|Some message", "fr|Another message"); Map<Locale, String> localeMessages = localeMessageTransformer.transform(messages, Map.class); assertThat(localeMessages).containsEntry(Locale.ENGLISH, "Some message"); assertThat(localeMessages).containsEntry(Locale.FRENCH, "Another message"); }
@Test(expectedExceptions = IllegalArgumentException.class) public void failsToParseInvalidMessage() { Set<String> messages = asSet("en|Some message", "fr-Another message"); localeMessageTransformer.transform(messages, Map.class); }