TypesHandler { Set<Axiom<URI>> getTypes(NamedResource individual, URI context, boolean includeInferred) throws SesameDriverException { final Collection<Statement> statements = getTypesStatements(individual, context, includeInferred); if (statements.isEmpty()) { return Collections.emptySet(); } return resolveTypes(individual, includeInferred, statements); } TypesHandler(Connector connector, ValueFactory valueFactory);   }
@Test public void getsTypesWithoutContext() throws Exception { final Collection<Statement> statements = initStatements(null); when(connectorMock.findStatements(vf.createIRI(STR_PK), RDF.TYPE, null, false, null)) .thenReturn(statements); final Set<Axiom<java.net.URI>> res = handler.getTypes(NamedResource.create(STR_PK), null, false); assertEquals(statements.size(), res.size()); final Set<java.net.URI> uris = new HashSet<>(); for (Axiom<java.net.URI> u : res) { uris.add(u.getValue().getValue()); } for (Statement stmt : statements) { assertTrue(uris.contains(java.net.URI.create(stmt.getObject().stringValue()))); } }
@Test public void getsTypesIncludingInferredAndInContext() throws Exception { final IRI context = vf.createIRI("http: final Collection<Statement> statements = initStatements(context); when(connectorMock.findStatements(vf.createIRI(STR_PK), RDF.TYPE, null, true, context)).thenReturn(statements); final Set<Axiom<java.net.URI>> res = handler .getTypes(NAMED_PK, java.net.URI.create(context.stringValue()), true); assertEquals(statements.size(), res.size()); final Set<java.net.URI> uris = new HashSet<>(); for (Axiom<java.net.URI> u : res) { uris.add(u.getValue().getValue()); } for (Statement stmt : statements) { assertTrue(uris.contains(java.net.URI.create(stmt.getObject().stringValue()))); } verify(connectorMock).findStatements(vf.createIRI(STR_PK), RDF.TYPE, null, true, context); }
@Test public void getsEmptyTypes() throws Exception { when(connectorMock.findStatements(vf.createIRI(STR_PK), RDF.TYPE, null, false)) .thenReturn(Collections.emptySet()); final Set<Axiom<java.net.URI>> res = handler.getTypes(NamedResource.create(STR_PK), null, true); assertTrue(res.isEmpty()); }