@Test public void map_withPredicateMappers_callsEachPredicateMapper() throws Exception { SimpleValueFactory f = SimpleValueFactory.getInstance(); IRI subjectIRI = f.createIRI("http: Set<PredicateMapper> predicateMappers = ImmutableSet.of( mock(PredicateMapper.class), mock(PredicateMapper.class), mock(PredicateMapper.class), mock(PredicateMapper.class) ); Model model = new ModelBuilder().build(); EvaluateExpression evaluator = null; PredicateObjectMapper testSubject = new PredicateObjectMapper(ImmutableSet.of(), predicateMappers); testSubject.map(model, evaluator, subjectIRI, ImmutableSet.of()); predicateMappers.forEach(mapper -> verify(mapper).map(model, evaluator, subjectIRI)); }
void map(Model model, EvaluateExpression evaluate, Resource subject, Set<IRI> subjectGraphs) { Resource[] contexts = Stream .concat( subjectGraphs.stream(), graphGenerators.stream() .map(g -> g.apply(evaluate)) .filter(l -> !l.isEmpty()) .map(l -> l.get(0)) ) .distinct() .filter(g -> !g.equals(Rr.defaultGraph)) .toArray(Resource[]::new); predicateMappers.forEach(p -> p.map(model, evaluate, subject, contexts)); }
PredicateObjectMapper { void map(Model model, EvaluateExpression evaluate, Resource subject, Set<IRI> subjectGraphs) { Resource[] contexts = Stream .concat( subjectGraphs.stream(), graphGenerators.stream() .map(g -> g.apply(evaluate)) .filter(l -> !l.isEmpty()) .map(l -> l.get(0)) ) .distinct() .filter(g -> !g.equals(Rr.defaultGraph)) .toArray(Resource[]::new); predicateMappers.forEach(p -> p.map(model, evaluate, subject, contexts)); } }
PredicateObjectMapper { void map(Model model, EvaluateExpression evaluate, Resource subject, Set<IRI> subjectGraphs) { Resource[] contexts = Stream .concat( subjectGraphs.stream(), graphGenerators.stream() .map(g -> g.apply(evaluate)) .filter(l -> !l.isEmpty()) .map(l -> l.get(0)) ) .distinct() .filter(g -> !g.equals(Rr.defaultGraph)) .toArray(Resource[]::new); predicateMappers.forEach(p -> p.map(model, evaluate, subject, contexts)); } PredicateObjectMapper(
		Set<TermGenerator<IRI>> graphGenerators,
		Set<PredicateMapper> predicateMappers
	); }
PredicateObjectMapper { void map(Model model, EvaluateExpression evaluate, Resource subject, Set<IRI> subjectGraphs) { Resource[] contexts = Stream .concat( subjectGraphs.stream(), graphGenerators.stream() .map(g -> g.apply(evaluate)) .filter(l -> !l.isEmpty()) .map(l -> l.get(0)) ) .distinct() .filter(g -> !g.equals(Rr.defaultGraph)) .toArray(Resource[]::new); predicateMappers.forEach(p -> p.map(model, evaluate, subject, contexts)); } PredicateObjectMapper(
		Set<TermGenerator<IRI>> graphGenerators,
		Set<PredicateMapper> predicateMappers
	);  }
PredicateObjectMapper { void map(Model model, EvaluateExpression evaluate, Resource subject, Set<IRI> subjectGraphs) { Resource[] contexts = Stream .concat( subjectGraphs.stream(), graphGenerators.stream() .map(g -> g.apply(evaluate)) .filter(l -> !l.isEmpty()) .map(l -> l.get(0)) ) .distinct() .filter(g -> !g.equals(Rr.defaultGraph)) .toArray(Resource[]::new); predicateMappers.forEach(p -> p.map(model, evaluate, subject, contexts)); } PredicateObjectMapper(
		Set<TermGenerator<IRI>> graphGenerators,
		Set<PredicateMapper> predicateMappers
	);   }