@Test void testBasicConstraints1() { final Optional<ConstraintViolation> res = svc.constrainedBy(identifier, LDP.Container, asGraph("/invalidContainer1.ttl", domain + "foo"), domain).findFirst(); assertTrue(res.isPresent(), "no constraint violation found!"); res.ifPresent(violation -> { assertEquals(Trellis.InvalidProperty, violation.getConstraint(), "no InvalidProperty violation!"); assertTrue(violation.getTriples().contains(rdf.createTriple(rdf.createIRI(domain + "foo"), LDP.isMemberOfRelation, rdf.createIRI(domain + "resource"))), "Triple not found in constraint violation!"); }); }
@Override public Stream<ConstraintViolation> constrainedBy(final IRI identifier, final IRI model, final Graph graph, final String domain) { final Stream<ConstraintViolation> violations = graph.stream() .flatMap(t -> violatesModelConstraints(t, model, domain).stream()); if (violatesCardinality(graph, model)) { final List<Triple> triples = new ArrayList<>(graph.stream().collect(toList())); final BlankNode bnode = rdf.createBlankNode(); triples.add(rdf.createTriple(bnode, RDFS.label, rdf.createLiteral("Invalid cardinality", EN))); triples.add(rdf.createTriple(bnode, RDFS.comment, rdf.createLiteral( "The supplied graph contains at least one property with an invalid cardinality " + "for the provided interaction model", EN))); final ConstraintViolation cardinalityViolation = new ConstraintViolation(Trellis.InvalidCardinality, triples); return concat(violations, Stream.of(cardinalityViolation)); } return violations; }
LdpConstraintService implements ConstraintService { @Override public Stream<ConstraintViolation> constrainedBy(final IRI identifier, final IRI model, final Graph graph, final String domain) { final Stream<ConstraintViolation> violations = graph.stream() .flatMap(t -> violatesModelConstraints(t, model, domain).stream()); if (violatesCardinality(graph, model)) { final List<Triple> triples = new ArrayList<>(graph.stream().collect(toList())); final BlankNode bnode = rdf.createBlankNode(); triples.add(rdf.createTriple(bnode, RDFS.label, rdf.createLiteral("Invalid cardinality", EN))); triples.add(rdf.createTriple(bnode, RDFS.comment, rdf.createLiteral( "The supplied graph contains at least one property with an invalid cardinality " + "for the provided interaction model", EN))); final ConstraintViolation cardinalityViolation = new ConstraintViolation(Trellis.InvalidCardinality, triples); return concat(violations, Stream.of(cardinalityViolation)); } return violations; } }
LdpConstraintService implements ConstraintService { @Override public Stream<ConstraintViolation> constrainedBy(final IRI identifier, final IRI model, final Graph graph, final String domain) { final Stream<ConstraintViolation> violations = graph.stream() .flatMap(t -> violatesModelConstraints(t, model, domain).stream()); if (violatesCardinality(graph, model)) { final List<Triple> triples = new ArrayList<>(graph.stream().collect(toList())); final BlankNode bnode = rdf.createBlankNode(); triples.add(rdf.createTriple(bnode, RDFS.label, rdf.createLiteral("Invalid cardinality", EN))); triples.add(rdf.createTriple(bnode, RDFS.comment, rdf.createLiteral( "The supplied graph contains at least one property with an invalid cardinality " + "for the provided interaction model", EN))); final ConstraintViolation cardinalityViolation = new ConstraintViolation(Trellis.InvalidCardinality, triples); return concat(violations, Stream.of(cardinalityViolation)); } return violations; }  }
LdpConstraintService implements ConstraintService { @Override public Stream<ConstraintViolation> constrainedBy(final IRI identifier, final IRI model, final Graph graph, final String domain) { final Stream<ConstraintViolation> violations = graph.stream() .flatMap(t -> violatesModelConstraints(t, model, domain).stream()); if (violatesCardinality(graph, model)) { final List<Triple> triples = new ArrayList<>(graph.stream().collect(toList())); final BlankNode bnode = rdf.createBlankNode(); triples.add(rdf.createTriple(bnode, RDFS.label, rdf.createLiteral("Invalid cardinality", EN))); triples.add(rdf.createTriple(bnode, RDFS.comment, rdf.createLiteral( "The supplied graph contains at least one property with an invalid cardinality " + "for the provided interaction model", EN))); final ConstraintViolation cardinalityViolation = new ConstraintViolation(Trellis.InvalidCardinality, triples); return concat(violations, Stream.of(cardinalityViolation)); } return violations; }  @Override Stream<ConstraintViolation> constrainedBy(final IRI identifier, final IRI model, final Graph graph,
            final String domain); }
LdpConstraintService implements ConstraintService { @Override public Stream<ConstraintViolation> constrainedBy(final IRI identifier, final IRI model, final Graph graph, final String domain) { final Stream<ConstraintViolation> violations = graph.stream() .flatMap(t -> violatesModelConstraints(t, model, domain).stream()); if (violatesCardinality(graph, model)) { final List<Triple> triples = new ArrayList<>(graph.stream().collect(toList())); final BlankNode bnode = rdf.createBlankNode(); triples.add(rdf.createTriple(bnode, RDFS.label, rdf.createLiteral("Invalid cardinality", EN))); triples.add(rdf.createTriple(bnode, RDFS.comment, rdf.createLiteral( "The supplied graph contains at least one property with an invalid cardinality " + "for the provided interaction model", EN))); final ConstraintViolation cardinalityViolation = new ConstraintViolation(Trellis.InvalidCardinality, triples); return concat(violations, Stream.of(cardinalityViolation)); } return violations; }  @Override Stream<ConstraintViolation> constrainedBy(final IRI identifier, final IRI model, final Graph graph,
            final String domain);  }