public void testGetQueryWithValueSpecified() {
   DBTreeListClass dbtlc = new DBTreeListClass();
   dbtlc.setValueField("doc.name");
   assertEquals(
       "select distinct doc.name, doc.name, doc.parent from XWikiDocument as doc",
       dbtlc.getQuery(getContext()));
 }
 public void testGetQueryWithIdValueParentAndClassSpecified() {
   DBTreeListClass dbtlc = new DBTreeListClass();
   dbtlc.setClassname("XWiki.XWikiUsers");
   dbtlc.setIdField("doc.name");
   dbtlc.setValueField("doc.name");
   dbtlc.setParentField("doc.name");
   assertEquals(
       "select distinct doc.name, doc.name, doc.name"
           + " from XWikiDocument as doc, BaseObject as obj"
           + " where doc.fullName=obj.name and obj.className='XWiki.XWikiUsers'",
       dbtlc.getQuery(getContext()));
   dbtlc.setIdField("prop1");
   dbtlc.setValueField("prop1");
   dbtlc.setParentField("prop1");
   assertEquals(
       "select distinct idprop.value, idprop.value, idprop.value"
           + " from BaseObject as obj, StringProperty as idprop"
           + " where obj.className='XWiki.XWikiUsers'"
           + " and obj.id=idprop.id.id and idprop.id.name='prop1'",
       dbtlc.getQuery(getContext()));
   dbtlc.setValueField("prop2");
   assertEquals(
       "select distinct idprop.value, valueprop.value, idprop.value"
           + " from BaseObject as obj, StringProperty as idprop, StringProperty as valueprop"
           + " where obj.className='XWiki.XWikiUsers'"
           + " and obj.id=idprop.id.id and idprop.id.name='prop1'"
           + " and obj.id=valueprop.id.id and valueprop.id.name='prop2'",
       dbtlc.getQuery(getContext()));
   dbtlc.setParentField("prop2");
   assertEquals(
       "select distinct idprop.value, valueprop.value, valueprop.value"
           + " from BaseObject as obj, StringProperty as idprop, StringProperty as valueprop"
           + " where obj.className='XWiki.XWikiUsers'"
           + " and obj.id=idprop.id.id and idprop.id.name='prop1'"
           + " and obj.id=valueprop.id.id and valueprop.id.name='prop2'",
       dbtlc.getQuery(getContext()));
   dbtlc.setParentField("prop3");
   assertEquals(
       "select distinct idprop.value, valueprop.value, parentprop.value"
           + " from BaseObject as obj, StringProperty as idprop,"
           + " StringProperty as valueprop, StringProperty as parentprop"
           + " where obj.className='XWiki.XWikiUsers'"
           + " and obj.id=idprop.id.id and idprop.id.name='prop1'"
           + " and obj.id=valueprop.id.id and valueprop.id.name='prop2'"
           + " and obj.id=parentprop.id.id and parentprop.id.name='prop3'",
       dbtlc.getQuery(getContext()));
 }
 public void testGetQueryWithIdValueAndParentSpecified() {
   DBTreeListClass dbtlc = new DBTreeListClass();
   dbtlc.setIdField("doc.name");
   dbtlc.setValueField("doc.title");
   dbtlc.setParentField("doc.space");
   assertEquals(
       "select distinct doc.name, doc.title, doc.space" + " from XWikiDocument as doc",
       dbtlc.getQuery(getContext()));
   dbtlc.setValueField("obj.name");
   assertEquals(
       "select distinct doc.name, obj.name, doc.space"
           + " from XWikiDocument as doc, BaseObject as obj where doc.fullName=obj.name",
       dbtlc.getQuery(getContext()));
   dbtlc.setIdField("obj.className");
   dbtlc.setParentField("obj.id");
   assertEquals(
       "select distinct obj.className, obj.name, obj.id" + " from BaseObject as obj",
       dbtlc.getQuery(getContext()));
 }
  public void testGetQueryWithIdAndValueSpecified() {
    DBTreeListClass dbtlc = new DBTreeListClass();
    dbtlc.setIdField("doc.name");
    dbtlc.setValueField("doc.name");
    assertEquals(
        "select distinct doc.name, doc.name, doc.parent" + " from XWikiDocument as doc",
        dbtlc.getQuery(getContext()));
    dbtlc.setValueField("doc.creator");
    assertEquals(
        "select distinct doc.name, doc.creator, doc.parent" + " from XWikiDocument as doc",
        dbtlc.getQuery(getContext()));
    dbtlc.setValueField("obj.className");
    assertEquals(
        "select distinct doc.name, obj.className, doc.parent"
            + " from XWikiDocument as doc, BaseObject as obj where doc.fullName=obj.name",
        dbtlc.getQuery(getContext()));
    dbtlc.setValueField("property");
    assertEquals(
        "select distinct doc.name, doc.property, doc.parent" + " from XWikiDocument as doc",
        dbtlc.getQuery(getContext()));

    dbtlc.setIdField("obj.className");
    dbtlc.setValueField("doc.name");
    assertEquals(
        "select distinct obj.className, doc.name, doc.parent"
            + " from XWikiDocument as doc, BaseObject as obj where doc.fullName=obj.name",
        dbtlc.getQuery(getContext()));
    dbtlc.setValueField("obj.className");
    assertEquals(
        "select distinct obj.className, obj.className, doc.parent"
            + " from XWikiDocument as doc, BaseObject as obj where doc.fullName=obj.name",
        dbtlc.getQuery(getContext()));
    dbtlc.setValueField("obj.id");
    assertEquals(
        "select distinct obj.className, obj.id, doc.parent"
            + " from XWikiDocument as doc, BaseObject as obj where doc.fullName=obj.name",
        dbtlc.getQuery(getContext()));
    dbtlc.setValueField("property");
    assertEquals(
        "select distinct obj.className, doc.property, doc.parent"
            + " from XWikiDocument as doc, BaseObject as obj where doc.fullName=obj.name",
        dbtlc.getQuery(getContext()));

    dbtlc.setIdField("property");
    dbtlc.setValueField("doc.name");
    assertEquals(
        "select distinct doc.property, doc.name, doc.parent" + " from XWikiDocument as doc",
        dbtlc.getQuery(getContext()));
    dbtlc.setValueField("obj.className");
    assertEquals(
        "select distinct doc.property, obj.className, doc.parent"
            + " from XWikiDocument as doc, BaseObject as obj where doc.fullName=obj.name",
        dbtlc.getQuery(getContext()));
    dbtlc.setValueField("property");
    assertEquals(
        "select distinct doc.property, doc.property, doc.parent" + " from XWikiDocument as doc",
        dbtlc.getQuery(getContext()));
    dbtlc.setValueField("otherProperty");
    assertEquals(
        "select distinct doc.property, doc.otherProperty, doc.parent"
            + " from XWikiDocument as doc",
        dbtlc.getQuery(getContext()));
  }