Пример #1
0
 /**
  * @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();
 }
Пример #2
0
 /**
  * @param expected the expected value
  * @param typeAdapter the body type adaptor
  * @param formatter the formatter the value determining whether the content should be rendered as
  *     a collapseable section.
  * @param minLenForToggle the value determining whether the content should be rendered as a
  *     collapseable section.
  * @return the formatted content for a cell with a right expectation
  */
 public static String makeContentForRightCell(
     String expected,
     RestDataTypeAdapter typeAdapter,
     CellFormatter<?> formatter,
     int minLenForToggle) {
   StringBuffer sb = new StringBuffer();
   sb.append(toHtml(expected));
   String actual = typeAdapter.toString();
   if (formatter.isDisplayActual() && !expected.equals(actual)) {
     sb.append(toHtml("\n"));
     sb.append(formatter.label("expected"));
     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"));
   }
   return sb.toString();
 }