aboutsummaryrefslogtreecommitdiffstats
path: root/predicate-search-core/src/test/java/com/yahoo/document/predicate/FeatureConjunctionTest.java
blob: 378a9c07a8bb04c2d58320422d5fae12887e7a91 (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
48
49
50
51
52
// Copyright 2017 Yahoo Holdings. 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 java.util.Arrays;
import java.util.Collections;

import static com.yahoo.document.predicate.Predicates.feature;
import static com.yahoo.document.predicate.Predicates.not;

/**
 * @author bjorncs
 */
public class FeatureConjunctionTest {

    @Test
    public void require_that_featureconjunction_with_valid_operands_can_be_constructed() {
        new FeatureConjunction(Arrays.asList(
                not(feature("a").inSet("1")),
                feature("b").inSet("1")));
    }

    @Test(expected = IllegalArgumentException.class)
    public void require_that_constructor_throws_exception_if_all_operands_are_not_featuresets() {
        new FeatureConjunction(Arrays.asList(
                not(feature("a").inSet("1")),
                feature("b").inRange(1, 2)));
    }

    @Test(expected = IllegalArgumentException.class)
    public void require_that_constructor_throws_exception_if_single_operand() {
        new FeatureConjunction(Arrays.asList(feature("a").inSet("1")));
    }

    @Test(expected = IllegalArgumentException.class)
    public void require_that_constructor_throws_exception_if_no_operands() {
        new FeatureConjunction(Collections.emptyList());
    }

    @Test(expected = IllegalArgumentException.class)
    public void require_that_contructor_throws_exception_if_featuresets_contain_multiple_values() {
        new FeatureConjunction(Arrays.asList(feature("a").inSet("1"), feature("b").inSet("2", "3")));
    }

    @Test(expected = IllegalArgumentException.class)
    public void require_that_constructor_throws_exception_if_featureset_keys_are_not_unique() {
        new FeatureConjunction(Arrays.asList(
                not(feature("a").inSet("1")),
                feature("a").inSet("2")));
    }
}