Skip to content

Commit

Permalink
[Upd] Updated dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
ledsoft committed Dec 19, 2018
1 parent d462c93 commit ba4b0c6
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 73 deletions.
32 changes: 16 additions & 16 deletions pom.xml
Expand Up @@ -16,12 +16,13 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

<cz.cvut.kbss.jb4jsonld.version>0.3.6</cz.cvut.kbss.jb4jsonld.version>
<cz.cvut.kbss.jb4jsonld.version>0.3.7</cz.cvut.kbss.jb4jsonld.version>
<junit.version>4.12</junit.version>
<org.mockito.version>1.10.19</org.mockito.version>
<ch.qos.logback.version>1.1.6</ch.qos.logback.version>
<com.fasterxml.jackson.version>2.8.1</com.fasterxml.jackson.version>
<com.github.jsonld-java.version>0.11.1</com.github.jsonld-java.version>
<ch.qos.logback.version>1.2.3</ch.qos.logback.version>
<com.fasterxml.jackson.version>2.9.8</com.fasterxml.jackson.version>
<com.github.jsonld-java.version>0.12.3</com.github.jsonld-java.version>
<org.eclipse.rdf4j.version>2.4.2</org.eclipse.rdf4j.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -82,21 +83,15 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.jsonld-java</groupId>
<artifactId>jsonld-java-sesame</artifactId>
<version>0.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-runtime</artifactId>
<version>2.8.9</version>
<groupId>org.eclipse.rdf4j</groupId>
<artifactId>rdf4j-runtime</artifactId>
<version>${org.eclipse.rdf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-model</artifactId>
<version>2.8.9</version>
<groupId>org.eclipse.rdf4j</groupId>
<artifactId>rdf4j-model</artifactId>
<version>${org.eclipse.rdf4j.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -183,6 +178,11 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>

<!-- Code coverage plugin -->
<plugin>
Expand Down
@@ -1,26 +1,24 @@
/**
* Copyright (C) 2017 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* <p>
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
* version.
* <p>
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package cz.cvut.kbss.jsonld.jackson.environment;

import org.openrdf.model.Statement;
import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.RepositoryException;
import org.openrdf.rio.RDFHandlerException;
import org.openrdf.rio.helpers.RDFHandlerBase;
import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.repository.RepositoryConnection;
import org.eclipse.rdf4j.repository.RepositoryException;
import org.eclipse.rdf4j.rio.RDFHandlerException;
import org.eclipse.rdf4j.rio.helpers.AbstractRDFHandler;

public class StatementCopyingHandler extends RDFHandlerBase {
public class StatementCopyingHandler extends AbstractRDFHandler {

private final RepositoryConnection connection;

Expand Down
@@ -1,21 +1,19 @@
/**
* Copyright (C) 2017 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* <p>
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
* version.
* <p>
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package cz.cvut.kbss.jsonld.jackson.environment.model;

import cz.cvut.kbss.jopa.CommonVocabulary;
import cz.cvut.kbss.jopa.model.annotations.*;
import cz.cvut.kbss.jopa.vocabulary.RDFS;
import cz.cvut.kbss.jsonld.jackson.environment.Vocabulary;

import java.net.URI;
Expand All @@ -35,7 +33,7 @@ public class Organization {
@OWLAnnotationProperty(iri = Vocabulary.DATE_CREATED)
private Date dateCreated;

@OWLAnnotationProperty(iri = CommonVocabulary.RDFS_LABEL)
@OWLAnnotationProperty(iri = RDFS.LABEL)
private String name;

@OWLDataProperty(iri = Vocabulary.BRAND)
Expand Down
Expand Up @@ -69,14 +69,14 @@ public void writeNumberLongWritesLong() throws Exception {

@Test
public void writeNumberFloatWritesFloat() throws Exception {
final Float number = Float.MIN_VALUE;
final float number = Float.MIN_VALUE;
writer.writeNumber(number);
verify(generator).writeNumber(number);
}

@Test
public void writeNumberDoubleWritesDouble() throws Exception {
final Double number = Double.MAX_VALUE;
final double number = Double.MAX_VALUE;
writer.writeNumber(number);
verify(generator).writeNumber(number);
}
Expand Down
Expand Up @@ -13,11 +13,11 @@
package cz.cvut.kbss.jsonld.jackson.serialization;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.jsonldjava.sesame.SesameJSONLDParserFactory;
import cz.cvut.kbss.jopa.model.annotations.Id;
import cz.cvut.kbss.jopa.model.annotations.OWLDataProperty;
import cz.cvut.kbss.jopa.model.annotations.Types;
import cz.cvut.kbss.jopa.vocabulary.RDF;
import cz.cvut.kbss.jopa.vocabulary.RDFS;
import cz.cvut.kbss.jsonld.exception.MissingTypeInfoException;
import cz.cvut.kbss.jsonld.jackson.JsonLdModule;
import cz.cvut.kbss.jsonld.jackson.environment.Generator;
Expand All @@ -26,23 +26,19 @@
import cz.cvut.kbss.jsonld.jackson.environment.model.Employee;
import cz.cvut.kbss.jsonld.jackson.environment.model.Organization;
import cz.cvut.kbss.jsonld.jackson.environment.model.User;
import org.eclipse.rdf4j.model.Value;
import org.eclipse.rdf4j.model.ValueFactory;
import org.eclipse.rdf4j.repository.Repository;
import org.eclipse.rdf4j.repository.RepositoryConnection;
import org.eclipse.rdf4j.repository.RepositoryException;
import org.eclipse.rdf4j.repository.sail.SailRepository;
import org.eclipse.rdf4j.rio.*;
import org.eclipse.rdf4j.sail.memory.MemoryStore;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.openrdf.model.Value;
import org.openrdf.model.ValueFactory;
import org.openrdf.model.vocabulary.RDFS;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.RepositoryException;
import org.openrdf.repository.sail.SailRepository;
import org.openrdf.rio.RDFHandlerException;
import org.openrdf.rio.RDFParseException;
import org.openrdf.rio.RDFParser;
import org.openrdf.rio.RDFParserFactory;
import org.openrdf.sail.memory.MemoryStore;

import java.io.ByteArrayInputStream;
import java.io.IOException;
Expand All @@ -68,24 +64,23 @@ public class JsonLdSerializationTest {
private ObjectMapper objectMapper;

@Before
public void setUp() throws Exception {
public void setUp() {
initRepository();
final RDFParserFactory factory = new SesameJSONLDParserFactory();
this.parser = factory.getParser();
this.parser = Rio.createParser(RDFFormat.JSONLD);
parser.setRDFHandler(new StatementCopyingHandler(connection));

this.objectMapper = new ObjectMapper();
objectMapper.registerModule(new JsonLdModule());
}

private void initRepository() throws Exception {
private void initRepository() {
this.repository = new SailRepository(new MemoryStore());
repository.initialize();
this.connection = repository.getConnection();
}

@After
public void tearDown() throws Exception {
public void tearDown() {
connection.close();
repository.shutDown();
}
Expand All @@ -107,11 +102,11 @@ private void serializeAndStore(Object instance)
connection.commit();
}

private boolean contains(URI subject, String property, Object value) throws Exception {
private boolean contains(URI subject, String property, Object value) {
final ValueFactory vf = connection.getValueFactory();
Value rdfVal = null;
if (value instanceof URI) {
rdfVal = vf.createURI(value.toString());
rdfVal = vf.createIRI(value.toString());
} else if (value instanceof Integer) {
rdfVal = vf.createLiteral((Integer) value);
} else if (value instanceof Long) {
Expand All @@ -125,11 +120,11 @@ private boolean contains(URI subject, String property, Object value) throws Exce
} else if (value instanceof String) {
rdfVal = vf.createLiteral(value.toString());
}
return connection
.getStatements(vf.createURI(subject.toString()), vf.createURI(property), rdfVal, false).hasNext();
return connection.getStatements(vf.createIRI(subject.toString()), vf.createIRI(property), rdfVal, false)
.hasNext();
}

private void verifyUserAttributes(User user) throws Exception {
private void verifyUserAttributes(User user) {
assertTrue(contains(user.getUri(), RDF.TYPE, URI.create(Vocabulary.PERSON)));
assertTrue(contains(user.getUri(), RDF.TYPE, URI.create(Vocabulary.USER)));
assertTrue(contains(user.getUri(), Vocabulary.FIRST_NAME, user.getFirstName()));
Expand All @@ -148,8 +143,8 @@ public void testSerializeInstanceWithSingularReference() throws Exception {
verifyOrganizationAttributes(org);
}

private void verifyOrganizationAttributes(Organization org) throws Exception {
assertTrue(contains(org.getUri(), RDFS.LABEL.stringValue(), org.getName()));
private void verifyOrganizationAttributes(Organization org) {
assertTrue(contains(org.getUri(), RDFS.LABEL, org.getName()));
// There is currently a grey zone of representing dates - we're using long timestamp, but RDF4J parses it XML integer
assertTrue(contains(org.getUri(), Vocabulary.DATE_CREATED, null));
for (String brand : org.getBrands()) {
Expand Down

0 comments on commit ba4b0c6

Please sign in to comment.