aboutsummaryrefslogtreecommitdiffstats
path: root/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/OutputAssertTestCase.java
blob: c3b4298e54339f81cc61eced0b06069ffbacc398 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.indexinglanguage.expressions;

import com.yahoo.document.DataType;
import org.junit.Test;

import static com.yahoo.vespa.indexinglanguage.expressions.OutputAssert.assertVerify;
import static com.yahoo.vespa.indexinglanguage.expressions.OutputAssert.assertVerifyThrows;
import static org.junit.Assert.assertNotNull;

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

    @Test
    public void requireThatAssertVerifyMethodThrowsWhenAppropriate() {
        Throwable thrown = null;
        try {
            assertVerify(null, DataType.INT, SimpleExpression.newRequired(DataType.STRING));
        } catch (Throwable t) {
            thrown = t;
        }
        assertNotNull(thrown);

        thrown = null;
        try {
            assertVerifyThrows(null, DataType.INT, SimpleExpression.newRequired(DataType.INT),
                               "unchecked expected exception message");
        } catch (Throwable t) {
            thrown = t;
        }
        assertNotNull(thrown);

        thrown = null;
        try {
            assertVerifyThrows(null, DataType.INT, SimpleExpression.newRequired(DataType.STRING),
                               "wrong expected exception message");
        } catch (Throwable t) {
            thrown = t;
        }
        assertNotNull(thrown);
    }
}