Skip to content

Commit

Permalink
#393 #487 code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-asprino committed Jul 27, 2024
1 parent 57e3240 commit 4076a81
Show file tree
Hide file tree
Showing 21 changed files with 107 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ public void testBN() throws MalformedURLException {
// Node n = NodeFactory.createURI(
// url.toString()+"#");
// expectedGraph.add(Triple.create(n, RDF.type.asNode(), NodeFactory.createURI(Triplifier.FACADE_X_TYPE_ROOT)));
// expectedGraph.add(Triple.create(n, RDF.li(1).asNode(), NodeFactory.createLiteral(url + "#test.csv")));
// expectedGraph.add(Triple.create(n, RDF.li(2).asNode(), NodeFactory.createLiteral(url + "#test.json")));
// expectedGraph.add(Triple.create(n, RDF.li(3).asNode(), NodeFactory.createLiteral(url + "#test.xml")));
// expectedGraph.add(Triple.create(n, RDF.li(4).asNode(), NodeFactory.createLiteral(url + "#test.txt")));
// expectedGraph.add(Triple.create(n, RDF.li(1).asNode(), NodeFactory.createLiteralString(url + "#test.csv")));
// expectedGraph.add(Triple.create(n, RDF.li(2).asNode(), NodeFactory.createLiteralString(url + "#test.json")));
// expectedGraph.add(Triple.create(n, RDF.li(3).asNode(), NodeFactory.createLiteralString(url + "#test.xml")));
// expectedGraph.add(Triple.create(n, RDF.li(4).asNode(), NodeFactory.createLiteralString(url + "#test.txt")));
// assertTrue(dg.getDefaultGraph().isIsomorphicWith(expectedGraph));
// assertTrue(dg.getGraph(NodeFactory.createURI(url.toString())).isIsomorphicWith(expectedGraph));
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testContent() throws TriplifierHTTPException {
expected.add(n, RDF.li(1).asNode(), article);
expected.add(article, RDF.type.asNode(), NodeFactory.createURI(Triplifier.XYZ_NS + "article"));
expected.add(article, NodeFactory.createURI(Triplifier.XYZ_NS + "title"),
NodeFactory.createLiteral("Literate Programming"));
NodeFactory.createLiteralString("Literate Programming"));
assertTrue(g1.getDefaultGraph().isIsomorphicWith(expected));

} catch (IOException e1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.Set;

import io.github.sparqlanything.model.*;
import io.github.sparqlanything.model.annotations.Example;
import io.github.sparqlanything.model.annotations.Option;
import org.apache.commons.codec.binary.Base64;
import org.apache.jena.datatypes.xsd.XSDDatatype;
Expand All @@ -41,7 +40,7 @@ public class BinaryTriplifier implements Triplifier {
@Option(description = "The encoding to use for generating the representation of the file.", validValues = "BASE64")
public static final IRIArgument ENCODING = new IRIArgument("bin.encoding", Encoding.BASE64.name());

public static enum Encoding {
public enum Encoding {
BASE64
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testBase64() throws MalformedURLException {
Node n = NodeFactory.createBlankNode();
expectedGraph.add(Triple.create(n,RDF.type.asNode(), NodeFactory.createURI(Triplifier.FACADE_X_TYPE_ROOT)));
expectedGraph.add(Triple.create(n, RDF.li(1).asNode(),
NodeFactory.createLiteral("dGhpcyBpcyBhIHRlc3Q=", XSDDatatype.XSDbase64Binary)));
NodeFactory.createLiteralDT("dGhpcyBpcyBhIHRlc3Q=", XSDDatatype.XSDbase64Binary)));
assertTrue(dg.getDefaultGraph().isIsomorphicWith(expectedGraph));
assertTrue(dg.getGraph(NodeFactory.createURI(Triplifier.getRootArgument(p))).isIsomorphicWith(expectedGraph));
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
import org.junit.Assume;
import io.github.sparqlanything.model.HTTPHelper;

import java.util.Objects;

public class LoadSubdirsTest {
public static final Logger L = LoggerFactory.getLogger(LoadSubdirsTest.class);

public LoadSubdirsTest() {
JenaSystem.init();
Expand All @@ -35,8 +36,8 @@ public LoadSubdirsTest() {
public void test() throws Exception {
Assume.assumeTrue(HTTPHelper.checkHostIsReachable("https://schema.org"));

String q = getClass().getClassLoader().getResource("count-triples.sparql").toString();
String d = getClass().getClassLoader().getResource("./load-subdirs").toURI().toString();
String q = Objects.requireNonNull(getClass().getClassLoader().getResource("count-triples.sparql")).toString();
String d = Objects.requireNonNull(getClass().getClassLoader().getResource("./load-subdirs")).toURI().toString();
SPARQLAnything sa = new SPARQLAnything();
String out = sa.callMain(new String[]{
"-q", q, "-l", d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void testCsvNullString(String nullString) throws IOException, TriplifierH
triplifier.triplify(properties, b);
DatasetGraph graph = b.getDatasetGraph();
// with csv.null-string set to nullString we should not see any quads with nullString in the object position
if (graph.find(Node.ANY, Node.ANY, Node.ANY, NodeFactory.createLiteral(nullString)).hasNext()) {
if (graph.find(Node.ANY, Node.ANY, Node.ANY, NodeFactory.createLiteralString(nullString)).hasNext()) {
fail("csv.null-string didn't work for: \"" + nullString + "\"");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import io.github.sparqlanything.model.*;
import io.github.sparqlanything.model.annotations.Example;
import io.github.sparqlanything.model.annotations.Option;
import org.apache.jena.datatypes.xsd.XSDDatatype;
import org.apache.jena.graph.NodeFactory;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
Expand Down Expand Up @@ -99,7 +98,7 @@ public void triplify(Properties properties, FacadeXGraphBuilder builder) throws
sb.append("\n");
}
builder.addValue(dataSourceId, SPARQLAnythingConstants.ROOT_ID, count,
NodeFactory.createLiteral(sb.toString(), XSDDatatype.XSDstring));
NodeFactory.createLiteralString(sb.toString()));
count++;
}

Expand Down
Loading

0 comments on commit 4076a81

Please sign in to comment.