PropertiesHandler implements Properties { @Override public Collection<Axiom<?>> getProperties(NamedResource individual, URI context, boolean includeInferred) { return new ExplicitAxiomLoader(connector).find(individual, context); } PropertiesHandler(StorageConnector connector); @Override Collection<Axiom<?>> getProperties(NamedResource individual, URI context, boolean includeInferred); @Override void addProperties(NamedResource individual, URI context, Map<Assertion, Set<Value<?>>> properties); @Override void removeProperties(NamedResource individual, URI context, Map<Assertion, Set<Value<?>>> properties);  }
@Test public void getPropertiesLoadsPropertyValues() { final Property pOne = createProperty(Generator.generateUri().toString()); final Property pTwo = createProperty(Generator.generateUri().toString()); final Integer vOne = 117; final URI vTwo = Generator.generateUri(); final List<Statement> statements = Arrays .asList(createStatement(SUBJECT_RESOURCE, pOne, ResourceFactory.createTypedLiteral(vOne)), createStatement(SUBJECT_RESOURCE, pTwo, createResource(vTwo.toString()))); when(connectorMock.find(SUBJECT_RESOURCE, null, null, null)).thenReturn(statements); final Collection<Axiom<?>> result = handler.getProperties(SUBJECT, null, false); final List<Axiom<?>> lResult = new ArrayList<>(result); assertEquals(2, result.size()); assertEquals(Assertion.createDataPropertyAssertion(URI.create(pOne.getURI()), false), lResult.get(0).getAssertion()); assertEquals(new Value<>(vOne), lResult.get(0).getValue()); assertEquals(Assertion.createObjectPropertyAssertion(URI.create(pTwo.getURI()), false), lResult.get(1).getAssertion()); assertEquals(new Value<>(NamedResource.create(vTwo)), lResult.get(1).getValue()); }
@Test public void getPropertiesLoadsPropertyValuesFromContext() { final Property pOne = createProperty(Generator.generateUri().toString()); final Integer vOne = 117; final String context = Generator.generateUri().toString(); final List<Statement> statements = Collections .singletonList(createStatement(SUBJECT_RESOURCE, pOne, ResourceFactory.createTypedLiteral(vOne))); when(connectorMock.find(SUBJECT_RESOURCE, null, null, context)).thenReturn(statements); final Collection<Axiom<?>> result = handler.getProperties(SUBJECT, URI.create(context), false); final List<Axiom<?>> lResult = new ArrayList<>(result); assertEquals(1, result.size()); assertEquals(Assertion.createDataPropertyAssertion(URI.create(pOne.getURI()), false), lResult.get(0).getAssertion()); assertEquals(new Value<>(vOne), lResult.get(0).getValue()); verify(connectorMock, never()).find(any(), any(), any(),eq(null)); }