Revision 45126
Added by Claudio Atzori over 7 years ago
ISStoreServiceImplTest.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.enabling.is.store; // NOPMD |
2 | 2 |
|
3 |
import static org.junit.Assert.assertFalse; |
|
3 | 4 |
import static org.junit.Assert.assertNotNull; |
4 | 5 |
import static org.junit.Assert.assertTrue; |
5 | 6 |
import static org.mockito.Matchers.anyString; |
6 | 7 |
import static org.mockito.Mockito.mock; |
7 | 8 |
import static org.mockito.Mockito.when; |
8 | 9 |
|
10 |
import java.util.Iterator; |
|
9 | 11 |
import java.util.List; |
10 | 12 |
|
11 | 13 |
import org.junit.Before; |
12 | 14 |
import org.junit.Test; |
13 | 15 |
import org.junit.runner.RunWith; |
14 | 16 |
import org.mockito.Mock; |
15 |
import org.mockito.runners.MockitoJUnit44Runner;
|
|
17 |
import org.mockito.junit.MockitoJUnitRunner;
|
|
16 | 18 |
import org.xmldb.api.base.XMLDBException; |
17 | 19 |
|
18 | 20 |
import eu.dnetlib.enabling.is.store.rmi.ISStoreException; |
19 |
import eu.dnetlib.xml.database.XMLDBResultSet; |
|
20 | 21 |
import eu.dnetlib.xml.database.XMLDatabase; |
21 | 22 |
|
22 | 23 |
/** |
... | ... | |
25 | 26 |
* @author marko |
26 | 27 |
* |
27 | 28 |
*/ |
28 |
@RunWith(MockitoJUnit44Runner.class)
|
|
29 |
@RunWith(MockitoJUnitRunner.class) |
|
29 | 30 |
public class ISStoreServiceImplTest { |
30 | 31 |
|
31 | 32 |
/** |
... | ... | |
56 | 57 |
*/ |
57 | 58 |
@Test |
58 | 59 |
public void testQuickSearchXML() throws XMLDBException, ISStoreException { |
59 |
final XMLDBResultSet rset = mock(XMLDBResultSet.class);
|
|
60 |
when(rset.getSize()).thenReturn(0L);
|
|
60 |
final Iterator<String> rset = mock(Iterator.class);
|
|
61 |
when(rset.hasNext()).thenReturn(true, false);
|
|
61 | 62 |
when(xmlDatabase.xquery(anyString())).thenReturn(rset); |
62 | 63 |
|
63 | 64 |
final List<String> res = storeService.quickSearchXML("someQuery"); |
64 | 65 |
|
65 | 66 |
assertNotNull("empty result not null", res); |
66 |
assertTrue("empty result is empty", res.isEmpty());
|
|
67 |
assertFalse("empty result is empty", res.isEmpty());
|
|
67 | 68 |
} |
68 | 69 |
|
69 | 70 |
} |
Also available in: Unified diff
migrated to dnet45, using updated mockito version in tests