### Question:
CreoleToJSPWikiTranslator { public String translateSignature(Properties wikiProps, final String content, String username) { String dateFormat = wikiProps.getProperty("creole.dateFormat"); if (dateFormat == null) { dateFormat = DEFAULT_DATEFORMAT; } SimpleDateFormat df = null; try { df = new SimpleDateFormat(dateFormat); } catch (Exception e) { e.printStackTrace(); df = new SimpleDateFormat(DEFAULT_DATEFORMAT); } String result = content; result = protectMarkup(result, PREFORMATTED_PROTECTED, "", ""); result = protectMarkup(result, URL_PROTECTED, "", ""); Calendar cal = Calendar.getInstance(); result = translateElement(result, SIGNATURE_AND_DATE, "-- [[" + username + "]], " + df.format(cal.getTime())); result = translateElement(result, SIGNATURE, "-- [[" + username + "]]"); result = unprotectMarkup(result, false); return result; }  String translateSignature(Properties wikiProps, final String content, String username); String translate(Properties wikiProps, final String content); static final String VAR_VERSION; static final String VAR_CREOLE_VERSION; static final String VAR_LINEBREAK_BLOGLIKE; static final String VAR_LINEBREAK_C2LIKE; }### Answer:
@Test public void testSignature() { String src = "Hallo\r\n--~~~"; String target = "Hallo\r\n-- [[Hanno]]"; Properties props = new Properties(); props.put("creole.dateFormat", "dd/MM/yyyy"); Assertions.assertEquals(target, new CreoleToJSPWikiTranslator().translateSignature(props, src, "Hanno")); }
@Test public void testSignatureDate() { String src = "Hallo\r\n--~~~~"; Calendar cal = Calendar.getInstance(); String target = "Hallo\r\n-- [[Hanno]], " + (new SimpleDateFormat("dd/MM/yyyy")).format(cal.getTime()); Properties props = new Properties(); props.put("creole.dateFormat", "dd/MM/yyyy"); Assertions.assertEquals(target, new CreoleToJSPWikiTranslator().translateSignature(props, src, "Hanno")); }
@Test public void testSignatureDate2() { String format = "\n yyyy-MM-dd HH:mm "; String src = "Hallo\r\n--~~~~"; Calendar cal = Calendar.getInstance(); String target = "Hallo\r\n-- [[Hanno]], " + (new SimpleDateFormat(format)).format(cal.getTime()); Properties props = new Properties(); props.put("creole.dateFormat", format); Assertions.assertEquals(target, new CreoleToJSPWikiTranslator().translateSignature(props, src, "Hanno")); }
@Test public void testSignatureSourceCode() { String format = "\n yyyy-MM-dd HH:mm "; String src = "{{{Hallo\r\n" + "--~~~~\r\n" + "Hallo\r\n" + "}}}"; Properties props = new Properties(); props.put("creole.dateFormat", format); Assertions.assertEquals(src, new CreoleToJSPWikiTranslator().translateSignature(props, src, "Hanno")); }