aboutsummaryrefslogtreecommitdiffstats
path: root/docproc/src/test/java/com/yahoo/docproc/ProcessingTestCase.java
blob: 296c8d163e56fe7d19d26721a06e5d2f6505c3be (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
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.docproc;

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

import java.util.Iterator;
import java.util.Map;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;

/**
 * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
 * @since 5.1.10
 */
public class ProcessingTestCase {

    @Test
    public void serviceName() {
        assertThat(new Processing().getServiceName(), is("default"));
        assertThat(new Processing("foobar", (DocumentOperation) null, null).getServiceName(), is("foobar"));
    }

    @Test
    public void contextVariables() {
        Processing p = new Processing();

        p.setVariable("foo", "banana");
        p.setVariable("bar", "apple");

        Iterator<Map.Entry<String, Object>> it = p.getVariableAndNameIterator();
        assertThat(it.hasNext(), is(true));
        assertThat(it.next(), not(nullValue()));
        assertThat(it.hasNext(), is(true));
        assertThat(it.next(), not(nullValue()));
        assertThat(it.hasNext(), is(false));

        assertThat(p.hasVariable("foo"), is(true));
        assertThat(p.hasVariable("bar"), is(true));
        assertThat(p.hasVariable("baz"), is(false));

        assertThat(p.removeVariable("foo"), is("banana"));

        p.clearVariables();

        it = p.getVariableAndNameIterator();
        assertThat(it.hasNext(), is(false));
    }
}