blob: 9f14a78d8c51f6f1b5de707e3100c7e2c8f8133a (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.search.test;
import com.yahoo.document.select.parser.ParseException;
import com.yahoo.vespa.model.search.DocumentSelectionConverter;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* Unit tests for RemoveSelection.
* @author Ulf Lilleengen
*/
public class DocumentSelectionConverterTest {
@Test
public void testQueryConversion() throws ParseException, IllegalArgumentException, UnsupportedOperationException {
DocumentSelectionConverter converter = new DocumentSelectionConverter("music.expire>now() - 3600 and video.expire > now() - 300");
assertEquals("expire:>now(3600)", converter.getQuery("music"));
assertEquals("expire:<now(3600)", converter.getInvertedQuery("music"));
assertEquals("expire:>now(300)", converter.getQuery("video"));
assertEquals("expire:<now(300)", converter.getInvertedQuery("video"));
assertTrue(null == converter.getQuery("book"));
assertTrue(null == converter.getInvertedQuery("book"));
}
@Test
public void testSelection() throws ParseException, IllegalArgumentException, UnsupportedOperationException {
DocumentSelectionConverter converter = new DocumentSelectionConverter("music.expire>music.expire.nowdate");
assertTrue(converter.getQuery("music") == null);
assertTrue(converter.getInvertedQuery("music") == null);
}
}
|