### Question:
MessageParser { public static String normalizeSubject(String subject) { String s = subject; if (s != null) { s = s.replaceAll("\\[.*?\\][^$]","") .replaceAll("^\\s*(-*\\s*[a-zA-Z]{2,3}:\\s*)*","") .replaceAll("\\s+[a-zA-Z]{2,3}:","") .replaceAll("^\\s*-\\s*","") .replaceAll("\\s+"," ") .trim(); } return s; } private  MessageParser(); static MessageBuilder getMessageBuilder(); static Mail parse(Message message); static Mail parse(Message message, /*Map<String, String> data,*/ String idsuffix); static Map<String, Field> getMessageHeaders(Message message); static Author extractValue(MailboxListField field); static List<String> extractValue(AddressListField field); static Date extractValue(DateTimeField field); static String extractValue(UnstructuredField field); static String normalizeSubject(String subject); final static DateTimeFormatter defaultDatePrinter; }### Answer:
@Test public void subjectNormalizationShouldPass() { assertEquals("Test subject", MessageParser.normalizeSubject(" [] [x x] Re: Vor: Test RE: subject ")); assertEquals("Test subject", MessageParser.normalizeSubject(" Re: Fw: [] [x x] Test RE: [x] [] subject ")); assertEquals("Web Container Integration testing (WCI)", MessageParser.normalizeSubject("Re: [gatein-dev] Web Container Integration testing (WCI)")); assertEquals("Type Substitution doesn't work with Schema2Java Client a [Re: this should stay here]", MessageParser.normalizeSubject("[jbossws-users] [JBossWS] - Re: [another-tag] Fw: Type Substitution doesn't work with\tSchema2Java Client a [Re: this should stay here]")); assertEquals("Multiple Assignment of a task in - jBPM4", MessageParser.normalizeSubject("[jbpm-users] [jBPM Users] - [JBPM4] Multiple Assignment of a task in - jBPM4")); }