/** * @param expected the expected value * @param typeAdapter the body adapter for the cell * @param formatter the formatter * @param minLenForToggle the value determining whether the content should be rendered as a * collapseable section. * @return the formatted content for a cell with a wrong expectation */ public static String makeContentForWrongCell( String expected, RestDataTypeAdapter typeAdapter, CellFormatter<?> formatter, int minLenForToggle) { StringBuffer sb = new StringBuffer(); sb.append(Tools.toHtml(expected)); if (formatter.isDisplayActual()) { sb.append(toHtml("\n")); sb.append(formatter.label("expected")); String actual = typeAdapter.toString(); sb.append(toHtml("-----")); sb.append(toHtml("\n")); if (minLenForToggle >= 0 && actual.length() > minLenForToggle) { sb.append(makeToggleCollapseable("toggle actual", toHtml(actual))); } else { sb.append(toHtml(actual)); } sb.append(toHtml("\n")); sb.append(formatter.label("actual")); } List<String> errors = typeAdapter.getErrors(); if (errors.size() > 0) { sb.append(toHtml("-----")); sb.append(toHtml("\n")); for (String e : errors) { sb.append(toHtml(e + "\n")); } sb.append(toHtml("\n")); sb.append(formatter.label("errors")); } return sb.toString(); }
@Test public void dualityOfToAndFromHtml() { String stuff = "<a> " + System.getProperty("line.separator") + " </a>"; assertEquals(stuff, Tools.fromHtml(Tools.toHtml(stuff))); }