private int assertPivotCountsAreCorrect(String pivotName,SolrParams baseParams,PivotField constraint) throws SolrServerException {
  SolrParams p=SolrParams.wrapAppended(baseParams,params("fq",buildFilter(constraint)));
  List<PivotField> subPivots=null;
  try {
    assertNumFound(pivotName,constraint.getCount(),p);
    subPivots=constraint.getPivot();
  }
 catch (  Exception e) {
    throw new RuntimeException(pivotName + ": count query failed: " + p+ ": "+ e.getMessage(),e);
  }
  int depth=0;
  if (null != subPivots) {
    assertTraceOk(pivotName,baseParams,subPivots);
    for (    PivotField subPivot : subPivots) {
      depth=assertPivotCountsAreCorrect(pivotName,p,subPivot);
    }
  }
  return depth + 1;
}

private int assertPivotCountsAreCorrect ( String pivotName , SolrParams baseParams , PivotField constraint ) throws SolrServerException { SolrParams p = SolrParams . wrapAppended ( baseParams , params ( "fq" , buildFilter ( constraint ) ) ) ; List < PivotField > subPivots = null ; try { assertNumFound ( pivotName , constraint . getCount ( ) , p ) ; subPivots = constraint . getPivot ( ) ; } catch ( Exception e ) { throw new RuntimeException ( pivotName + ": count query failed: " + p + ": " + e . getMessage ( ) , e ) ; } int depth = 0 ; if ( null != subPivots ) { assertTraceOk ( pivotName , baseParams , subPivots ) ; for ( PivotField subPivot : subPivots ) { depth = assertPivotCountsAreCorrect ( pivotName , p , subPivot ) ; } } return depth + 1 ; }
recursive helper method for asserting that pivot constraint counds match results when filtering on those constraints . returns the recursive depth reached ( for sanity checking )
