public void testCollectionWithManyColumns() throws Exception {

    HtmlMetawidgetTag metawidgetTag = new HtmlMetawidgetTag();
    metawidgetTag.setPageContext(new DummyPageContext());

    Document document =
        XmlUtils.documentFromString(
            "<inspection-result><entity><property name=\"column1\"/><property name=\"column2\"/><property name=\"column3\"/><property name=\"column4\"/><property name=\"column5\"/><property name=\"column6\"/></entity></inspection-result>");
    Element entity = (Element) document.getDocumentElement().getFirstChild();

    final List<String> columnsAdded = CollectionUtils.newArrayList();

    DisplayTagWidgetBuilder widgetBuilder =
        new DisplayTagWidgetBuilder() {

          @Override
          protected boolean addColumnTag(
              TableTag tableTag,
              Map<String, String> tableAttributes,
              Map<String, String> columnAttributes,
              MetawidgetTag innerMetawidgetTag) {

            columnsAdded.add(innerMetawidgetTag.getLabelString(columnAttributes));
            return true;
          }
        };

    TableTag tableTag = new TableTag();
    Map<String, String> attributes = CollectionUtils.newHashMap();
    widgetBuilder.addColumnTags(tableTag, attributes, entity.getChildNodes(), metawidgetTag);
    assertEquals(5, columnsAdded.size());
  }
  public void testWidgetBuilder() throws Exception {

    DisplayTagWidgetBuilder widgetBuilder = new DisplayTagWidgetBuilder();

    // No type

    Map<String, String> attributes = CollectionUtils.newHashMap();
    assertTrue(null == widgetBuilder.buildWidget(PROPERTY, attributes, null));

    // Hidden

    attributes.put(HIDDEN, TRUE);
    assertTrue(null == widgetBuilder.buildWidget(PROPERTY, attributes, null));
    attributes.remove(HIDDEN);

    // Lookup

    attributes.put(LOOKUP, TRUE);
    assertTrue(null == widgetBuilder.buildWidget(PROPERTY, attributes, null));
    attributes.remove(LOOKUP);

    // Bad type

    attributes.put(TYPE, "foo");
    assertTrue(null == widgetBuilder.buildWidget(PROPERTY, attributes, null));

    // Non-collection

    attributes.put(TYPE, String.class.getName());
    assertTrue(null == widgetBuilder.buildWidget(PROPERTY, attributes, null));
  }