aboutsummaryrefslogtreecommitdiffstats
path: root/predicate-search-core/src/test/java/com/yahoo/document/predicate/BooleanPredicateTest.java
blob: 92c455205041c592e91ed35098e56f21f51c05f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.document.predicate;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;

/**
 * @author Simon Thoresen Hult
 */
public class BooleanPredicateTest {

    @Test
    public void requireThatFalseIsAValue() {
        assertTrue(PredicateValue.class.isAssignableFrom(BooleanPredicate.class));
    }

    @Test
    public void requireThatCloneIsImplemented() throws CloneNotSupportedException {
        BooleanPredicate node1 = new BooleanPredicate(true);
        BooleanPredicate node2 = node1.clone();
        assertEquals(node1, node2);
        assertNotSame(node1, node2);
    }

    @Test
    public void requireThatHashCodeIsImplemented() {
        assertEquals(new BooleanPredicate(true).hashCode(), new BooleanPredicate(true).hashCode());
        assertEquals(new BooleanPredicate(false).hashCode(), new BooleanPredicate(false).hashCode());
    }

    @Test
    public void requireThatEqualsIsImplemented() {
        BooleanPredicate lhs = new BooleanPredicate(true);
        assertTrue(lhs.equals(lhs));
        assertFalse(lhs.equals(new Object()));

        BooleanPredicate rhs = new BooleanPredicate(false);
        assertFalse(lhs.equals(rhs));
        rhs.setValue(true);
        assertTrue(lhs.equals(rhs));
    }

}