1
|
package eu.dnetlib.enabling.is.store; // NOPMD
|
2
|
|
3
|
import java.util.ArrayList;
|
4
|
import java.util.List;
|
5
|
|
6
|
import eu.dnetlib.xml.database.XMLDatabase;
|
7
|
import org.junit.Before;
|
8
|
import org.junit.Test;
|
9
|
import org.junit.runner.RunWith;
|
10
|
import org.mockito.Mock;
|
11
|
import org.mockito.junit.MockitoJUnitRunner;
|
12
|
import org.xmldb.api.base.XMLDBException;
|
13
|
|
14
|
import static org.junit.Assert.assertNotNull;
|
15
|
import static org.junit.Assert.assertTrue;
|
16
|
import static org.mockito.Matchers.anyString;
|
17
|
import static org.mockito.Mockito.when;
|
18
|
|
19
|
/**
|
20
|
* test the ISStore service.
|
21
|
*
|
22
|
* @author marko
|
23
|
*
|
24
|
*/
|
25
|
@RunWith(MockitoJUnitRunner.class)
|
26
|
public class ISStoreServiceImplTest {
|
27
|
|
28
|
/**
|
29
|
* instance under test.
|
30
|
*/
|
31
|
private transient ISStoreImpl storeService;
|
32
|
|
33
|
/**
|
34
|
* xml database mock.
|
35
|
*/
|
36
|
@Mock
|
37
|
private transient XMLDatabase xmlDatabase;
|
38
|
|
39
|
/**
|
40
|
* setup class under test.
|
41
|
*/
|
42
|
@Before
|
43
|
public void setUp() {
|
44
|
storeService = new ISStoreImpl();
|
45
|
storeService.setXmlDatabase(xmlDatabase);
|
46
|
}
|
47
|
|
48
|
/**
|
49
|
* test that quick search profile returns null instead of an empty list.
|
50
|
*
|
51
|
* @throws ISStoreException shouldn't happen
|
52
|
* @throws XMLDBException shouldn't happen
|
53
|
*/
|
54
|
@Test
|
55
|
public void testQuickSearchXML() throws ISStoreException, XMLDBException {
|
56
|
|
57
|
when(xmlDatabase.xquery(anyString())).thenReturn(new ArrayList<String>().iterator());
|
58
|
final List<String> res = storeService.quickSearchXML("someQuery");
|
59
|
assertNotNull("empty result not null", res);
|
60
|
assertTrue("empty result is empty", res.isEmpty());
|
61
|
}
|
62
|
|
63
|
}
|