aboutsummaryrefslogtreecommitdiffstats
path: root/docproc/src/test/java/com/yahoo/docproc/ProcessingTestCase.java
blob: 961aeac4f470ad16fee0c3ab896354c78f84bff7 (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 Yahoo. 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.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

/**
 * @author Einar M R Rosenvinge
 * @since 5.1.10
 */
public class ProcessingTestCase {

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

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

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

        Iterator<Map.Entry<String, Object>> it = p.getVariableAndNameIterator();
        assertTrue(it.hasNext());
        assertNotNull(it.next());
        assertTrue(it.hasNext());
        assertNotNull(it.next());
        assertFalse(it.hasNext());

        assertTrue(p.hasVariable("foo"));
        assertTrue(p.hasVariable("bar"));
        assertFalse(p.hasVariable("baz"));

        assertEquals("banana", p.removeVariable("foo"));

        p.clearVariables();

        it = p.getVariableAndNameIterator();
        assertFalse(it.hasNext());
    }
}