<commit_before>package org.apache.lucene.demo.facet;

import java.util.List;

import org.apache.lucene.facet.collections.ObjectToIntMap;
import org.apache.lucene.facet.search.FacetResult;
import org.apache.lucene.facet.search.FacetResultNode;
import org.apache.lucene.facet.taxonomy.CategoryPath;
import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test;

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class TestSimpleSortedSetFacetsExample extends LuceneTestCase {

  private static final ObjectToIntMap<CategoryPath> expectedCounts = new ObjectToIntMap<CategoryPath>();
  static {
    expectedCounts.put(new CategoryPath("Publish Year", "2012"), 2);
    expectedCounts.put(new CategoryPath("Publish Year", "2010"), 2);
    expectedCounts.put(new CategoryPath("Publish Year", "1999"), 1);
    expectedCounts.put(new CategoryPath("Author", "Lisa"), 2);
    expectedCounts.put(new CategoryPath("Author", "Frank"), 1);
    expectedCounts.put(new CategoryPath("Author", "Susan"), 1);
    expectedCounts.put(new CategoryPath("Author", "Bob"), 1);
  }
  
  private static final ObjectToIntMap<CategoryPath> expectedCountsDrillDown = new ObjectToIntMap<CategoryPath>();
  static {
    expectedCountsDrillDown.put(new CategoryPath("Author", "Lisa"), 1);
    expectedCountsDrillDown.put(new CategoryPath("Author", "Bob"), 1);
  }
  
  private void assertExpectedCounts(List<FacetResult> facetResults, ObjectToIntMap<CategoryPath> expCounts) {
    for (FacetResult res : facetResults) {
      FacetResultNode root = res.getFacetResultNode();
      for (FacetResultNode node : root.subResults) {
        assertEquals("incorrect count for " + node.label, expCounts.get(node.label), (int) node.value);
      }
    }
  }
  
  @Test
  public void testSimple() throws Exception {
    assumeTrue("Test requires SortedSetDV support", defaultCodecSupportsSortedSet());
    List<FacetResult> facetResults = new SimpleSortedSetFacetsExample().runSearch();
    assertEquals(2, facetResults.size());
    assertExpectedCounts(facetResults, expectedCounts);
  }

  @Test
  public void testDrillDown() throws Exception {
    assumeTrue("Test requires SortedSetDV support", defaultCodecSupportsSortedSet());
    List<FacetResult> facetResults = new SimpleSortedSetFacetsExample().runDrillDown();
    assertEquals(1, facetResults.size());
    assertExpectedCounts(facetResults, expectedCountsDrillDown);
  }
  
}<commit_msg>change assume to SuppressCodecs for more test iterations over time<commit_after>package org.apache.lucene.demo.facet;

import java.util.List;

import org.apache.lucene.facet.collections.ObjectToIntMap;
import org.apache.lucene.facet.search.FacetResult;
import org.apache.lucene.facet.search.FacetResultNode;
import org.apache.lucene.facet.taxonomy.CategoryPath;
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test;

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// We require sorted set DVs:
@SuppressCodecs({"Lucene40", "Lucene41"})
public class TestSimpleSortedSetFacetsExample extends LuceneTestCase {

  private static final ObjectToIntMap<CategoryPath> expectedCounts = new ObjectToIntMap<CategoryPath>();
  static {
    expectedCounts.put(new CategoryPath("Publish Year", "2012"), 2);
    expectedCounts.put(new CategoryPath("Publish Year", "2010"), 2);
    expectedCounts.put(new CategoryPath("Publish Year", "1999"), 1);
    expectedCounts.put(new CategoryPath("Author", "Lisa"), 2);
    expectedCounts.put(new CategoryPath("Author", "Frank"), 1);
    expectedCounts.put(new CategoryPath("Author", "Susan"), 1);
    expectedCounts.put(new CategoryPath("Author", "Bob"), 1);
  }
  
  private static final ObjectToIntMap<CategoryPath> expectedCountsDrillDown = new ObjectToIntMap<CategoryPath>();
  static {
    expectedCountsDrillDown.put(new CategoryPath("Author", "Lisa"), 1);
    expectedCountsDrillDown.put(new CategoryPath("Author", "Bob"), 1);
  }
  
  private void assertExpectedCounts(List<FacetResult> facetResults, ObjectToIntMap<CategoryPath> expCounts) {
    for (FacetResult res : facetResults) {
      FacetResultNode root = res.getFacetResultNode();
      for (FacetResultNode node : root.subResults) {
        assertEquals("incorrect count for " + node.label, expCounts.get(node.label), (int) node.value);
      }
    }
  }
  
  @Test
  public void testSimple() throws Exception {
    List<FacetResult> facetResults = new SimpleSortedSetFacetsExample().runSearch();
    assertEquals(2, facetResults.size());
    assertExpectedCounts(facetResults, expectedCounts);
  }

  @Test
  public void testDrillDown() throws Exception {
    List<FacetResult> facetResults = new SimpleSortedSetFacetsExample().runDrillDown();
    assertEquals(1, facetResults.size());
    assertExpectedCounts(facetResults, expectedCountsDrillDown);
  }
  
}
{'fraction_non_alphanumeric': 0.10301981755268952, 'fraction_numerical': 0.009122365523749607, 'mean_word_length': 4.993402450518379, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '987106', 'n_tokens_mistral': 1879, 'n_tokens_neox': 1801, 'n_words': 508}