use of org.openrdf.repository.RepositoryException in project gocd by gocd.
the class SesameGraph method remove.
public void remove(Resource tripleSubject, RDFProperty triplePredicate, Integer integer) {
AbstractSesameResource sesameSubject = (AbstractSesameResource) tripleSubject;
URI sesameNativePredicate = getSesameNativeProperty(triplePredicate);
try {
conn.remove(sesameSubject.getSesameNativeResource(), sesameNativePredicate, conn.getValueFactory().createLiteral(String.valueOf(integer), XMLSchema.INTEGER), contextResource);
} catch (RepositoryException e) {
throw new ShineRuntimeException(e);
}
}
use of org.openrdf.repository.RepositoryException in project gocd by gocd.
the class SesameGraph method addStatement.
public void addStatement(Resource subject, RDFProperty predicate, String object) {
AbstractSesameResource sesameSubject = (AbstractSesameResource) subject;
URI sesameNativePredicate = getSesameNativeProperty(predicate);
try {
conn.add(sesameSubject.getSesameNativeResource(), sesameNativePredicate, conn.getValueFactory().createLiteral(String.valueOf(object), XMLSchema.STRING), contextResource);
} catch (RepositoryException e) {
throw new ShineRuntimeException("Could not add statement << [" + subject + "] [" + predicate + "] [" + object + "] >>", e);
}
}
use of org.openrdf.repository.RepositoryException in project gocd by gocd.
the class SesameGraphTest method checkWhenAddStatementWithResourceObjectExplodesItThrowsAShineRuntimeException.
@Test(expected = ShineRuntimeException.class)
public void checkWhenAddStatementWithResourceObjectExplodesItThrowsAShineRuntimeException() throws RepositoryException {
RDFProperty property = new RDFProperty("http://www.example.com/ontology#foo");
RepositoryConnection badConnection = mock(RepositoryConnection.class);
doThrow(new RepositoryException("")).when(badConnection).add((org.openrdf.model.Resource) any(), (org.openrdf.model.URI) any(), (org.openrdf.model.Value) any());
org.openrdf.model.ValueFactory stubValueFactory = mock(org.openrdf.model.ValueFactory.class);
when(badConnection.getValueFactory()).thenReturn(stubValueFactory);
SesameURIReference stubSubject = mock(SesameURIReference.class);
when(stubSubject.getSesameNativeResource()).thenReturn(null);
URIReference stubPredicate = mock(URIReference.class);
when(stubPredicate.getURIText()).thenReturn("");
SesameGraph badGraph = new SesameGraph(badConnection, null);
badGraph.addStatement(stubSubject, property, (Integer) null);
}
use of org.openrdf.repository.RepositoryException in project gocd by gocd.
the class SesameGraphTest method checkWhenAddNamespaceExplodesItThrowsAShineRuntimeException.
@Test(expected = ShineRuntimeException.class)
public void checkWhenAddNamespaceExplodesItThrowsAShineRuntimeException() throws Exception {
RepositoryConnection badConnection = mock(RepositoryConnection.class);
doThrow(new RepositoryException("")).when(badConnection).setNamespace("foo", "http://example.org/");
SesameGraph badGraph = new SesameGraph(badConnection, null);
badGraph.addNamespace(new Namespace("foo", "http://example.org/"));
}
use of org.openrdf.repository.RepositoryException in project gocd by gocd.
the class SesameGraphTest method checkGetNamespaceByPrefixExplodesItThrowsAShineRuntimeException.
@Test(expected = ShineRuntimeException.class)
public void checkGetNamespaceByPrefixExplodesItThrowsAShineRuntimeException() throws RepositoryException {
RepositoryConnection badConnection = mock(RepositoryConnection.class);
when(badConnection.getNamespace("ex")).thenThrow(new RepositoryException(""));
SesameGraph badGraph = new SesameGraph(badConnection, null);
badGraph.getNamespaceByPrefix("ex");
}
Aggregations