SimpleListPropertyStrategy extends
        ListPropertyStrategy<SimpleListDescriptor, SimpleListValueDescriptor, X> { @Override void addValueFromAxiom(Axiom<?> ax) { final SimpleListDescriptor listDescriptor = createListDescriptor(ax); final Collection<Axiom<NamedResource>> sequence = mapper.loadSimpleList(listDescriptor); sequence.forEach(super::addValueFromAxiom); } SimpleListPropertyStrategy(EntityType<X> et, ListAttributeImpl<? super X, ?> att, Descriptor descriptor,
                               EntityMappingHelper mapper);   }
@Test void buildsInstanceFieldFromAxioms() { final Axiom<URI> ax = new AxiomImpl<>(NamedResource.create(PK), Assertion.createObjectPropertyAssertion(simpleList.getIRI().toURI(), false), new Value<>( URI.create("http: final List<OWLClassA> entitiesA = generateList(); final Collection<Axiom<NamedResource>> axioms = buildAxiomsForList(simpleList, entitiesA); when(mapperMock.loadSimpleList(any(SimpleListDescriptor.class))).thenReturn(axioms); strategy.addValueFromAxiom(ax); final OWLClassC instance = new OWLClassC(); instance.setUri(PK); strategy.buildInstanceFieldValue(instance); assertEquals(entitiesA.size(), instance.getSimpleList().size()); for (OWLClassA a : entitiesA) { assertTrue(instance.getSimpleList().contains(a)); } }
@Test void buildsInstanceFieldOfPlainIdentifiersFromAxioms() { final ListAttributeImpl<OWLClassP, URI> simpleList = mocks.forOwlClassP().pSimpleListAttribute(); final SimpleListPropertyStrategy<OWLClassP> strategy = new SimpleListPropertyStrategy<>(mocks.forOwlClassP().entityType(), simpleList, descriptor, mapperMock); final Axiom<URI> ax = new AxiomImpl<>(NamedResource.create(PK), Assertion.createObjectPropertyAssertion(simpleList.getIRI().toURI(), false), new Value<>( URI.create("http: final List<OWLClassA> as = generateList(); final Collection<Axiom<NamedResource>> axioms = buildAxiomsForList(simpleList, as); when(mapperMock.loadSimpleList(any(SimpleListDescriptor.class))).thenReturn(axioms); strategy.addValueFromAxiom(ax); final OWLClassP instance = new OWLClassP(); instance.setUri(PK); strategy.buildInstanceFieldValue(instance); assertEquals(as.size(), instance.getSimpleList().size()); for (int i = 0; i < as.size(); i++) { assertEquals(as.get(i).getUri(), instance.getSimpleList().get(i)); } }
@Test void addsValueFromAxiomAndVerifiesCorrectDescriptorWasCreated() { final Axiom<NamedResource> ax = new AxiomImpl<>(NamedResource.create(PK), Assertion.createObjectPropertyAssertion(simpleList.getIRI() .toURI(), false), new Value<>( NamedResource.create("http: final Collection<Axiom<NamedResource>> axioms = Collections.emptyList(); when(mapperMock.loadSimpleList(any(SimpleListDescriptor.class))) .thenReturn(axioms); strategy.addValueFromAxiom(ax); final ArgumentCaptor<SimpleListDescriptor> captor = ArgumentCaptor .forClass(SimpleListDescriptor.class); verify(mapperMock).loadSimpleList(captor.capture()); final SimpleListDescriptor res = captor.getValue(); assertEquals(PK, res.getListOwner().getIdentifier()); assertEquals(simpleList.getIRI().toURI(), res.getListProperty() .getIdentifier()); assertEquals(simpleList.getOWLObjectPropertyHasNextIRI().toURI(), res .getNextNode().getIdentifier()); assertNull(res.getContext()); }