use of org.openrdf.repository.RepositoryException in project gocd by gocd.
the class SesameGraph method addStatement.
public void addStatement(Resource subject, RDFProperty predicate, Boolean object) {
AbstractSesameResource sesameSubject = (AbstractSesameResource) subject;
URI sesameNativePredicate = getSesameNativeProperty(predicate);
try {
conn.add(sesameSubject.getSesameNativeResource(), sesameNativePredicate, conn.getValueFactory().createLiteral(String.valueOf(object), XMLSchema.BOOLEAN), 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 SesameGraph method addStatement.
public void addStatement(Resource subject, RDFProperty predicate, Integer object) {
AbstractSesameResource sesameSubject = (AbstractSesameResource) subject;
URI sesameNativePredicate = getSesameNativeProperty(predicate);
try {
conn.add(sesameSubject.getSesameNativeResource(), sesameNativePredicate, conn.getValueFactory().createLiteral(String.valueOf(object), XMLSchema.INTEGER), 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 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");
}
use of org.openrdf.repository.RepositoryException in project gocd by gocd.
the class SesameGraphTest method checkWhenAddStatementWithStringObjectExplodesItThrowsAShineRuntimeException.
@Test(expected = ShineRuntimeException.class)
public void checkWhenAddStatementWithStringObjectExplodesItThrowsAShineRuntimeException() 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.Literal) 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, "foo");
}
Aggregations