ReferencedListPropertyStrategy extends
        ListPropertyStrategy<ReferencedListDescriptor, ReferencedListValueDescriptor, X> { @Override void addValueFromAxiom(Axiom<?> ax) { final ReferencedListDescriptor listDescriptor = createListDescriptor(ax); final Collection<Axiom<NamedResource>> sequence = mapper.loadReferencedList(listDescriptor); sequence.stream() .filter(a -> a.getAssertion().getIdentifier().equals(attribute.getOWLPropertyHasContentsIRI().toURI())) .forEach(super::addValueFromAxiom); } ReferencedListPropertyStrategy(EntityType<X> et, ListAttributeImpl<? super X, ?> att, Descriptor descriptor,
                                   EntityMappingHelper mapper);   }
@Test void buildsInstanceFieldFromAxiomsIncludingNodes() throws Exception { final OWLClassC c = new OWLClassC(PK); final List<Axiom<NamedResource>> axioms = initRefListAxioms(true); when(mapperMock.loadReferencedList(any(ReferencedListDescriptor.class))).thenReturn(axioms); strategy.addValueFromAxiom(axioms.iterator().next()); assertNull(c.getReferencedList()); strategy.buildInstanceFieldValue(c); assertNotNull(c.getReferencedList()); assertEquals(list, c.getReferencedList()); final ArgumentCaptor<ReferencedListDescriptor> captor = ArgumentCaptor.forClass(ReferencedListDescriptor.class); verify(mapperMock).loadReferencedList(captor.capture()); final ReferencedListDescriptor listDescriptor = captor.getValue(); assertEquals(PK, listDescriptor.getListOwner().getIdentifier()); assertEquals(refListMock.getIRI().toURI(), listDescriptor.getListProperty().getIdentifier()); assertEquals(refListMock.getOWLObjectPropertyHasNextIRI().toURI(), listDescriptor.getNextNode() .getIdentifier()); assertEquals(refListMock.getOWLPropertyHasContentsIRI().toURI(), listDescriptor .getNodeContent().getIdentifier()); }
@Test void buildsInstanceFieldFromAxiomsWithoutNodes() throws Exception { final OWLClassC c = new OWLClassC(PK); final List<Axiom<NamedResource>> axioms = initRefListAxioms(false); when(mapperMock.loadReferencedList(any(ReferencedListDescriptor.class))).thenReturn(axioms); strategy.addValueFromAxiom(axioms.iterator().next()); assertNull(c.getReferencedList()); strategy.buildInstanceFieldValue(c); assertNotNull(c.getReferencedList()); assertEquals(list, c.getReferencedList()); }
@Test void buildsInstanceFieldWithPlainIdentifiers() throws Exception { final ListAttributeImpl<OWLClassP, URI> listAtt = mocks.forOwlClassP().pReferencedListAttribute(); final ReferencedListPropertyStrategy<OWLClassP> strategy = new ReferencedListPropertyStrategy<>(mocks.forOwlClassP().entityType(), listAtt, descriptor, mapperMock); final List<Axiom<NamedResource>> axioms = initRefListAxioms(true); when(mapperMock.loadReferencedList(any(ReferencedListDescriptor.class))).thenReturn(axioms); strategy.addValueFromAxiom(axioms.iterator().next()); final OWLClassP p = new OWLClassP(); p.setUri(PK); strategy.buildInstanceFieldValue(p); assertNotNull(p.getReferencedList()); assertEquals(list.size(), p.getReferencedList().size()); for (int i = 0; i < list.size(); i++) { assertEquals(list.get(i).getUri(), p.getReferencedList().get(i)); } }