-
Notifications
You must be signed in to change notification settings - Fork 62
/
ReadmeTest.java
53 lines (40 loc) · 2.03 KB
/
ReadmeTest.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
package be.ugent.rml.readme;
import be.ugent.idlab.knows.functions.agent.Agent;
import be.ugent.idlab.knows.functions.agent.AgentFactory;
import be.ugent.rml.Executor;
import be.ugent.rml.Utils;
import be.ugent.rml.records.RecordsFactory;
import be.ugent.rml.store.QuadStore;
import be.ugent.rml.store.QuadStoreFactory;
import be.ugent.rml.store.RDF4JStore;
import be.ugent.rml.term.NamedNode;
import org.junit.jupiter.api.Test;
import java.io.*;
import static org.junit.jupiter.api.Assertions.fail;
public class ReadmeTest {
@Test
public void standard() {
try {
File mappingFile = Utils.getFile("argument/mapping.ttl");
// Get the mapping string stream
InputStream mappingStream = new FileInputStream(mappingFile);
// Load the mapping in a QuadStore
QuadStore rmlStore = QuadStoreFactory.read(mappingStream);
// Set up the basepath for the records factory, i.e., the basepath for the (local file) data sources
RecordsFactory factory = new RecordsFactory(mappingFile.getParent(), mappingFile.getParent());
// Set up the functions used during the mapping
Agent functionAgent = AgentFactory.createFromFnO("fno/functions_idlab.ttl", "fno/functions_idlab_test_classes_java_mapping.ttl");
// Set up the outputstore (needed when you want to output something else than nquads
QuadStore outputStore = new RDF4JStore();
// Create the Executor
Executor executor = new Executor(rmlStore, factory, outputStore, Utils.getBaseDirectiveTurtleOrDefault(mappingStream, "http://example.com"), functionAgent);
// Execute the mapping
QuadStore result = executor.execute(null).get(new NamedNode("rmlmapper://default.store"));
// Output the result
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
result.write(out, "turtle");
} catch (Exception e) {
fail("No exception was expected.");
}
}
}