SingularDataPropertyStrategy extends DataPropertyFieldStrategy<AbstractAttribute<? super X, ?>, X> { @Override void buildAxiomValuesFromInstance(X instance, AxiomValueGatherer valueBuilder) { final Object extractedValue = toAxiomValue(extractFieldValueFromInstance(instance)); final Value<?> val = extractedValue != null ? new Value<>(extractedValue) : Value.nullValue(); valueBuilder.addValue(createAssertion(), val, getAttributeContext()); } SingularDataPropertyStrategy(EntityType<X> et, AbstractAttribute<? super X, ?> att,
                                 Descriptor descriptor, EntityMappingHelper mapper);   }
@Test void buildAxiomsTransformsLocalDateToJavaUtilDate() throws Exception { final SingularDataPropertyStrategy<OWLClassT> strategy = new SingularDataPropertyStrategy<>( mocks.forOwlClassT().entityType(), mocks.forOwlClassT().tLocalDateAtt(), descriptor, mapperMock); final OWLClassT t = new OWLClassT(); t.setUri(PK); t.setLocalDate(LocalDate.now()); final AxiomValueGatherer builder = new AxiomValueGatherer(NamedResource.create(PK), null); strategy.buildAxiomValuesFromInstance(t, builder); final AxiomValueDescriptor valueDescriptor = OOMTestUtils.getAxiomValueDescriptor(builder); assertEquals(1, valueDescriptor.getAssertions().size()); final List<Value<?>> values = valueDescriptor .getAssertionValues(valueDescriptor.getAssertions().iterator().next()); assertEquals(1, values.size()); final Object value = values.get(0).getValue(); assertTrue(value instanceof Date); }
@Test void buildAxiomsTransformsLocalDateTimeToJavaUtilDate() throws Exception { final SingularDataPropertyStrategy<OWLClassT> strategy = new SingularDataPropertyStrategy<>( mocks.forOwlClassT().entityType(), mocks.forOwlClassT().tLocalDateTimeAtt(), descriptor, mapperMock); final OWLClassT t = new OWLClassT(); t.setUri(PK); t.setLocalDateTime(LocalDateTime.now()); final AxiomValueGatherer builder = new AxiomValueGatherer(NamedResource.create(PK), null); strategy.buildAxiomValuesFromInstance(t, builder); final AxiomValueDescriptor valueDescriptor = OOMTestUtils.getAxiomValueDescriptor(builder); assertEquals(1, valueDescriptor.getAssertions().size()); final List<Value<?>> values = valueDescriptor .getAssertionValues(valueDescriptor.getAssertions().iterator().next()); assertEquals(1, values.size()); final Object value = values.get(0).getValue(); assertTrue(value instanceof Date); }