@Test public void map_withGraphsAndClasses_appliesAllGraphsToEveryPredicateObjectMapper() throws Exception { SimpleValueFactory f = SimpleValueFactory.getInstance(); IRI subjectIRI = f.createIRI("http: EvaluateExpression evaluator = null; Set<IRI> graphs = ImmutableSet.of( f.createIRI("http: f.createIRI("http: f.createIRI("http: f.createIRI("http: ); Set<TermGenerator<IRI>> graphGenerators = graphs.stream() .map(graphIri -> { @SuppressWarnings("unchecked") TermGenerator<IRI> generator = (TermGenerator<IRI>) mock(TermGenerator.class); when(generator.apply(evaluator)).thenReturn(ImmutableList.of(graphIri)); return generator; }) .collect(ImmutableCollectors.toImmutableSet()); when(subjectGenerator.apply(evaluator)) .thenReturn(ImmutableList.of(subjectIRI)); PredicateObjectMapper mockMapper1 = mock(PredicateObjectMapper.class); PredicateObjectMapper mockMapper2 = mock(PredicateObjectMapper.class); PredicateObjectMapper mockMapper3 = mock(PredicateObjectMapper.class); PredicateObjectMapper mockMapper4 = mock(PredicateObjectMapper.class); Set<PredicateObjectMapper> predObjMappers = ImmutableSet.of(mockMapper1, mockMapper2, mockMapper3, mockMapper4); Model m = new ModelBuilder().build(); SubjectMapper s = new SubjectMapper(subjectGenerator, graphGenerators, ImmutableSet.of(), predObjMappers); s.map(m, evaluator); predObjMappers.forEach(mapper -> verify(mapper).map(m, evaluator, subjectIRI, graphs)); }
Optional<Resource> map(Model model, EvaluateExpression evaluate) { LOG.debug("Determining subjects ..."); List<Resource> subject = generator.apply(evaluate); LOG.debug("Determined subjects {}", subject); return subject.stream().findFirst().map(s -> mapSubject(s, model, evaluate)); }
SubjectMapper { Optional<Resource> map(Model model, EvaluateExpression evaluate) { LOG.debug("Determining subjects ..."); List<Resource> subject = generator.apply(evaluate); LOG.debug("Determined subjects {}", subject); return subject.stream().findFirst().map(s -> mapSubject(s, model, evaluate)); } }
SubjectMapper { Optional<Resource> map(Model model, EvaluateExpression evaluate) { LOG.debug("Determining subjects ..."); List<Resource> subject = generator.apply(evaluate); LOG.debug("Determined subjects {}", subject); return subject.stream().findFirst().map(s -> mapSubject(s, model, evaluate)); } SubjectMapper(
		TermGenerator<Resource> generator,
		Set<TermGenerator<IRI>> graphGenerators,
		Set<IRI> classes,
		Set<PredicateObjectMapper> predicateObjectMappers
	); }
SubjectMapper { Optional<Resource> map(Model model, EvaluateExpression evaluate) { LOG.debug("Determining subjects ..."); List<Resource> subject = generator.apply(evaluate); LOG.debug("Determined subjects {}", subject); return subject.stream().findFirst().map(s -> mapSubject(s, model, evaluate)); } SubjectMapper(
		TermGenerator<Resource> generator,
		Set<TermGenerator<IRI>> graphGenerators,
		Set<IRI> classes,
		Set<PredicateObjectMapper> predicateObjectMappers
	);  }
SubjectMapper { Optional<Resource> map(Model model, EvaluateExpression evaluate) { LOG.debug("Determining subjects ..."); List<Resource> subject = generator.apply(evaluate); LOG.debug("Determined subjects {}", subject); return subject.stream().findFirst().map(s -> mapSubject(s, model, evaluate)); } SubjectMapper(
		TermGenerator<Resource> generator,
		Set<TermGenerator<IRI>> graphGenerators,
		Set<IRI> classes,
		Set<PredicateObjectMapper> predicateObjectMappers
	);   }