public void testGetQueryWithIdAndParentSpecified() { DBTreeListClass dbtlc = new DBTreeListClass(); dbtlc.setIdField("doc.name"); dbtlc.setParentField("doc.name"); assertEquals( "select distinct doc.name, doc.name, doc.name from XWikiDocument as doc", dbtlc.getQuery(getContext())); dbtlc.setParentField("obj.className"); assertEquals( "select distinct doc.name, doc.name, obj.className" + " from XWikiDocument as doc, BaseObject as obj where doc.fullName=obj.name", dbtlc.getQuery(getContext())); dbtlc.setParentField("property"); assertEquals( "select distinct doc.name, doc.name, doc.property from XWikiDocument as doc", dbtlc.getQuery(getContext())); dbtlc.setIdField("obj.className"); dbtlc.setParentField("doc.name"); assertEquals( "select distinct obj.className, obj.className, doc.name" + " from XWikiDocument as doc, BaseObject as obj where doc.fullName=obj.name", dbtlc.getQuery(getContext())); dbtlc.setParentField("obj.className"); assertEquals( "select distinct obj.className, obj.className, obj.className" + " from BaseObject as obj", dbtlc.getQuery(getContext())); dbtlc.setParentField("property"); assertEquals( "select distinct obj.className, obj.className, doc.property" + " from XWikiDocument as doc, BaseObject as obj where doc.fullName=obj.name", dbtlc.getQuery(getContext())); dbtlc.setIdField("property"); dbtlc.setParentField("doc.name"); assertEquals( "select distinct doc.property, doc.property, doc.name" + " from XWikiDocument as doc", dbtlc.getQuery(getContext())); dbtlc.setParentField("obj.className"); assertEquals( "select distinct doc.property, doc.property, obj.className" + " from XWikiDocument as doc, BaseObject as obj where doc.fullName=obj.name", dbtlc.getQuery(getContext())); dbtlc.setParentField("property"); assertEquals( "select distinct doc.property, doc.property, doc.property" + " from XWikiDocument as doc", dbtlc.getQuery(getContext())); dbtlc.setParentField("property2"); assertEquals( "select distinct doc.property, doc.property, doc.property2" + " 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 testGetQueryWithClassAndParentSpecified() { DBTreeListClass dbtlc = new DBTreeListClass(); dbtlc.setClassname("XWiki.XWikiUsers"); dbtlc.setParentField("obj.id"); assertEquals( "select distinct doc.fullName, doc.fullName, obj.id" + " from XWikiDocument as doc, BaseObject as obj" + " where doc.fullName=obj.name and obj.className='XWiki.XWikiUsers'", dbtlc.getQuery(getContext())); }