@Test void testLdpType() { assertFalse(models.stream().map(ldpType -> svc.constrainedBy(identifier, ldpType, asGraph("/withLdpType.ttl", domain + "foo"), domain).anyMatch(v -> Trellis.InvalidType.equals(v.getConstraint()))) .reduce(false, (acc, x) -> acc || x), "Unexpected 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);  }