1 package org.apache.lucene.facet.enhancements.params;
7 import org.apache.lucene.util.LuceneTestCase;
8 import org.apache.lucene.facet.enhancements.CategoryEnhancement;
9 import org.apache.lucene.facet.enhancements.CategoryEnhancementDummy1;
10 import org.apache.lucene.facet.enhancements.CategoryEnhancementDummy2;
11 import org.apache.lucene.facet.enhancements.params.DefaultEnhancementsIndexingParams;
12 import org.apache.lucene.facet.enhancements.params.EnhancementsIndexingParams;
13 import org.apache.lucene.facet.index.DummyProperty;
14 import org.apache.lucene.facet.index.attributes.CategoryProperty;
17 * Licensed to the Apache Software Foundation (ASF) under one or more
18 * contributor license agreements. See the NOTICE file distributed with
19 * this work for additional information regarding copyright ownership.
20 * The ASF licenses this file to You under the Apache License, Version 2.0
21 * (the "License"); you may not use this file except in compliance with
22 * the License. You may obtain a copy of the License at
24 * http://www.apache.org/licenses/LICENSE-2.0
26 * Unless required by applicable law or agreed to in writing, software
27 * distributed under the License is distributed on an "AS IS" BASIS,
28 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29 * See the License for the specific language governing permissions and
30 * limitations under the License.
33 public class DefaultEnhancementsIndexingParamsTest extends LuceneTestCase {
36 public void testCategoryEnhancements() {
37 EnhancementsIndexingParams params =
38 new DefaultEnhancementsIndexingParams(
39 new CategoryEnhancementDummy1());
41 // check retainable properties
42 List<Class<? extends CategoryProperty>> retainableProps = params
43 .getRetainableProperties();
44 assertNull("Unexpected content in retainable list", retainableProps);
46 params.addCategoryEnhancements(new CategoryEnhancementDummy2());
48 List<CategoryEnhancement> enhancements = params
49 .getCategoryEnhancements();
51 assertEquals("Wrong number of enhancements", 2, enhancements.size());
53 assertTrue("Wrong first enhancement",
54 enhancements.get(0) instanceof CategoryEnhancementDummy1);
55 assertTrue("Wrong second enhancement",
56 enhancements.get(1) instanceof CategoryEnhancementDummy2);
58 // re-check retainable properties
59 retainableProps = params.getRetainableProperties();
60 assertNotNull("Unexpected empty retainable list", retainableProps);
61 assertEquals("Unexpected size of retainable list", 1, retainableProps
63 assertEquals("Wrong property in retainable list", DummyProperty.class,
64 retainableProps.get(0));