1 package org.apache.lucene.facet.enhancements.association;
5 import org.apache.lucene.facet.FacetException;
6 import org.apache.lucene.facet.enhancements.association.AssociationFloatProperty;
7 import org.apache.lucene.facet.enhancements.association.AssociationIntProperty;
8 import org.apache.lucene.facet.enhancements.association.AssociationProperty;
9 import org.apache.lucene.util.LuceneTestCase;
12 * Licensed to the Apache Software Foundation (ASF) under one or more
13 * contributor license agreements. See the NOTICE file distributed with
14 * this work for additional information regarding copyright ownership.
15 * The ASF licenses this file to You under the Apache License, Version 2.0
16 * (the "License"); you may not use this file except in compliance with
17 * the License. You may obtain a copy of the License at
19 * http://www.apache.org/licenses/LICENSE-2.0
21 * Unless required by applicable law or agreed to in writing, software
22 * distributed under the License is distributed on an "AS IS" BASIS,
23 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 * See the License for the specific language governing permissions and
25 * limitations under the License.
28 /** Test {@link AssociationProperty}-ies. */
29 public class AssociationPropertyTest extends LuceneTestCase {
32 public void testAssociationCountProperty() throws FacetException {
33 AssociationProperty aa1 = new AssociationIntProperty(5);
34 AssociationProperty aa2 = new AssociationIntProperty(3);
35 assertEquals("Wrong association for property", 5, aa1.getAssociation());
36 assertEquals("Wrong association for property", 3, aa2.getAssociation());
38 assertEquals("Wrong association for property", 8, aa1.getAssociation());
42 public void testAssociationFloatProperty() throws FacetException {
43 AssociationFloatProperty aa1 = new AssociationFloatProperty(5);
44 AssociationFloatProperty aa2 = new AssociationFloatProperty(3);
45 assertEquals("Wrong association for property", 5.0, aa1.getFloatAssociation(), 0.00001);
46 assertEquals("Wrong association for property", 3.0, aa2.getFloatAssociation(), 0.00001);
48 assertEquals("Wrong association for property", 8.0, aa1.getFloatAssociation(), 0.00001);
52 public void testEquals() {
53 AssociationProperty aa1 = new AssociationIntProperty(5);
54 AssociationProperty aa2 = new AssociationIntProperty(5);
55 AssociationProperty aa3 = new AssociationFloatProperty(5);
56 AssociationProperty aa4 = new AssociationFloatProperty(5);
58 assertTrue("Should be equal", aa1.equals(aa1));
59 assertTrue("Should be equal", aa1.equals(aa2));
60 assertFalse("Should not be equal", aa1.equals(aa3));
61 assertTrue("Should be equal", aa3.equals(aa3));
62 assertTrue("Should be equal", aa3.equals(aa4));