Buggy code:
public class CountingFacetsCollectorTest extends FacetTestCase { private static final Term A = new Term ( "f" , "a" ) ; private static final CategoryPath CP_A = new CategoryPath ( "A" ) ; private static final CategoryPath CP_B = new CategoryPath ( "B" ) ; private static final CategoryPath CP_C = new CategoryPath ( "C" ) ; private static final CategoryPath CP_D = new CategoryPath ( "D" ) ; private static final int NUM_CHILDREN_CP_A = 5 ; private static final int NUM_CHILDREN_CP_B = 3 ; private static final int NUM_CHILDREN_CP_C = 5 ; private static final int NUM_CHILDREN_CP_D = 5 ; private static final CategoryPath [ ] CATEGORIES_A ; private static final CategoryPath [ ] CATEGORIES_B ; private static final CategoryPath [ ] CATEGORIES_C ; private static final CategoryPath [ ] CATEGORIES_D ; private static Directory indexDir ; private static Directory taxoDir ; private static ObjectToIntMap < CategoryPath > allExpectedCounts ; private static ObjectToIntMap < CategoryPath > termExpectedCounts ; private static FacetIndexingParams fip ; @ AfterClass public static void afterClassCountingFacetsCollectorTest ( ) throws Exception { } private static List < CategoryPath > randomCategories ( Random random ) { } private static void addField ( Document doc ) { } private static void addFacets ( Document doc , FacetFields facetFields , boolean updateTermExpectedCounts ) throws IOException { } private static void indexDocsNoFacets ( IndexWriter indexWriter ) throws IOException { } private static void indexDocsWithFacetsNoTerms ( IndexWriter indexWriter , TaxonomyWriter taxoWriter , ObjectToIntMap < CategoryPath > expectedCounts ) throws IOException { } private static void indexDocsWithFacetsAndTerms ( IndexWriter indexWriter , TaxonomyWriter taxoWriter , ObjectToIntMap < CategoryPath > expectedCounts ) throws IOException { } private static void indexDocsWithFacetsAndSomeTerms ( IndexWriter indexWriter , TaxonomyWriter taxoWriter , ObjectToIntMap < CategoryPath > expectedCounts ) throws IOException { } private static ObjectToIntMap < CategoryPath > newCounts ( ) { } @ BeforeClass public static void beforeClassCountingFacetsCollectorTest ( ) throws Exception { } @ Test public void testInvalidParams ( ) throws Exception { } @ Test public void testDifferentNumResults ( ) throws Exception { } @ Test public void testAllCounts ( ) throws Exception { } @ Test public void testBigNumResults ( ) throws Exception { } @ Test public void testDirectSource ( ) throws Exception { DirectoryReader indexReader = DirectoryReader . open ( CountingFacetsCollectorTest . indexDir ) ; TaxonomyReader taxoReader = new org . apache . lucene . facet . taxonomy . directory . DirectoryTaxonomyReader ( CountingFacetsCollectorTest . taxoDir ) ; IndexSearcher searcher = new IndexSearcher ( indexReader ) ; FacetSearchParams fsp = new FacetSearchParams ( new org . apache . lucene . facet . search . params . CountFacetRequest ( CountingFacetsCollectorTest . CP_A , CountingFacetsCollectorTest . NUM_CHILDREN_CP_A ) , new org . apache . lucene . facet . search . params . CountFacetRequest ( CountingFacetsCollectorTest . CP_B , CountingFacetsCollectorTest . NUM_CHILDREN_CP_B ) ) ; <START_BUG> FacetsCollector fc = new CountingFacetsCollector ( fsp , taxoReader , new FacetArrays ( taxoReader . getSize ( ) ) , true ) ; <END_BUG> searcher . search ( new MatchAllDocsQuery ( ) , fc ) ; List < FacetResult > facetResults = fc . getFacetResults ( ) ; assertEquals ( "invalid<seq2seq4repair_space>number<seq2seq4repair_space>of<seq2seq4repair_space>facet<seq2seq4repair_space>results" , 2 , facetResults . size ( ) ) ; for ( FacetResult res : facetResults ) { FacetResultNode root = res . getFacetResultNode ( ) ; assertEquals ( ( "wrong<seq2seq4repair_space>count<seq2seq4repair_space>for<seq2seq4repair_space>" + ( root . label ) ) , CountingFacetsCollectorTest . allExpectedCounts . get ( root . label ) , ( ( int ) ( root . value ) ) ) ; for ( FacetResultNode child : root . subResults ) { assertEquals ( ( "wrong<seq2seq4repair_space>count<seq2seq4repair_space>for<seq2seq4repair_space>" + ( child . label ) ) , CountingFacetsCollectorTest . allExpectedCounts . get ( child . label ) , ( ( int ) ( child . value ) ) ) ; } } IOUtils . close ( indexReader , taxoReader ) ; } @ Test public void testNoParents ( ) throws Exception { } }

Fix:
FacetsCollector fc = new CountingFacetsCollector ( fsp , taxoReader , new FacetArrays ( taxoReader . getSize ( ) ) ) ;