pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / facet / src / test / org / apache / lucene / facet / enhancements / association / AssociationPropertyTest.java
1 package org.apache.lucene.facet.enhancements.association;
2
3 import org.junit.Test;
4
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;
10
11 /**
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
18  *
19  *     http://www.apache.org/licenses/LICENSE-2.0
20  *
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.
26  */
27
28 /** Test {@link AssociationProperty}-ies. */
29 public class AssociationPropertyTest extends LuceneTestCase {
30
31   @Test
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());
37     aa1.merge(aa2);
38     assertEquals("Wrong association for property", 8, aa1.getAssociation());
39   }
40
41   @Test
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);
47     aa1.merge(aa2);
48     assertEquals("Wrong association for property", 8.0, aa1.getFloatAssociation(), 0.00001);
49   }
50
51   @Test
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);
57
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));
63   }
64   
65 }