-
Notifications
You must be signed in to change notification settings - Fork 14
/
ListTestUtil.java
56 lines (50 loc) · 2.46 KB
/
ListTestUtil.java
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
53
54
55
56
package cz.cvut.kbss.ontodriver.jena.list;
import cz.cvut.kbss.ontodriver.jena.connector.StorageConnector;
import cz.cvut.kbss.ontodriver.jena.environment.Generator;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.apache.jena.rdf.model.ResourceFactory.createResource;
import static org.apache.jena.rdf.model.ResourceFactory.createStatement;
import static org.mockito.Mockito.when;
public class ListTestUtil {
static List<URI> generateSimpleList(Resource owner, Property hasList, Property hasNext,
StorageConnector connectorMock) {
final List<URI> list = new ArrayList<>();
URI previous = null;
for (int i = 0; i < 5; i++) {
final URI node = Generator.generateUri();
list.add(node);
if (previous != null) {
final Resource prevResource = createResource(previous.toString());
when(connectorMock.find(prevResource, hasNext, null)).thenReturn(Collections
.singletonList(createStatement(prevResource, hasNext, createResource(node.toString()))));
}
previous = node;
}
when(connectorMock.find(owner, hasList, null)).thenReturn(
Collections.singletonList(createStatement(owner, hasList, createResource(list.get(0).toString()))));
return list;
}
static List<URI> generateSimpleList(Resource owner, Property hasList, Property hasNext,
StorageConnector connectorMock, String context) {
final List<URI> list = new ArrayList<>();
URI previous = null;
for (int i = 0; i < 5; i++) {
final URI node = Generator.generateUri();
list.add(node);
if (previous != null) {
final Resource prevResource = createResource(previous.toString());
when(connectorMock.find(prevResource, hasNext, null, context)).thenReturn(Collections
.singletonList(createStatement(prevResource, hasNext, createResource(node.toString()))));
}
previous = node;
}
when(connectorMock.find(owner, hasList, null, context)).thenReturn(
Collections.singletonList(createStatement(owner, hasList, createResource(list.get(0).toString()))));
return list;
}
}