@Test public void getTemplateValue_givenValidInputAndFindingValue_performsAsExpected() { when(evaluateExpression.apply("xyz")).thenReturn(Optional.of("evaluated")); when(createNaturalRdfLexicalForm.apply("evaluated")).thenReturn("natural"); when(transformValue.apply("natural")).thenReturn("transformed"); Template template = TemplateParser.build().parse("abc{xyz}"); GetTemplateValue getTemplateValue = new GetTemplateValue( template, template.getExpressions(), transformValue, createNaturalRdfLexicalForm ); Optional<Object> templateValue = getTemplateValue.apply(evaluateExpression); String result = unpackTemplateValue(templateValue); assertThat(result, is("abctransformed")); }
@Override public Optional<Object> apply(EvaluateExpression evaluateExpression) { if (LOG.isTraceEnabled()) { LOG.trace("Processing template: {}", template.toTemplateString()); } Template.Builder templateBuilder = template.newBuilder(); expressions.forEach(e -> bindTemplateExpression(e, evaluateExpression, templateBuilder)); return templateBuilder.create(); }
GetTemplateValue implements Function<EvaluateExpression, Optional<Object>> { @Override public Optional<Object> apply(EvaluateExpression evaluateExpression) { if (LOG.isTraceEnabled()) { LOG.trace("Processing template: {}", template.toTemplateString()); } Template.Builder templateBuilder = template.newBuilder(); expressions.forEach(e -> bindTemplateExpression(e, evaluateExpression, templateBuilder)); return templateBuilder.create(); } }
GetTemplateValue implements Function<EvaluateExpression, Optional<Object>> { @Override public Optional<Object> apply(EvaluateExpression evaluateExpression) { if (LOG.isTraceEnabled()) { LOG.trace("Processing template: {}", template.toTemplateString()); } Template.Builder templateBuilder = template.newBuilder(); expressions.forEach(e -> bindTemplateExpression(e, evaluateExpression, templateBuilder)); return templateBuilder.create(); } GetTemplateValue(
		Template template,
		Set<Expression> expressions,
		Function<String, String> transformValue,
		Function<Object, String> createNaturalRdfLexicalForm
	); }
GetTemplateValue implements Function<EvaluateExpression, Optional<Object>> { @Override public Optional<Object> apply(EvaluateExpression evaluateExpression) { if (LOG.isTraceEnabled()) { LOG.trace("Processing template: {}", template.toTemplateString()); } Template.Builder templateBuilder = template.newBuilder(); expressions.forEach(e -> bindTemplateExpression(e, evaluateExpression, templateBuilder)); return templateBuilder.create(); } GetTemplateValue(
		Template template,
		Set<Expression> expressions,
		Function<String, String> transformValue,
		Function<Object, String> createNaturalRdfLexicalForm
	); @Override Optional<Object> apply(EvaluateExpression evaluateExpression); }
GetTemplateValue implements Function<EvaluateExpression, Optional<Object>> { @Override public Optional<Object> apply(EvaluateExpression evaluateExpression) { if (LOG.isTraceEnabled()) { LOG.trace("Processing template: {}", template.toTemplateString()); } Template.Builder templateBuilder = template.newBuilder(); expressions.forEach(e -> bindTemplateExpression(e, evaluateExpression, templateBuilder)); return templateBuilder.create(); } GetTemplateValue(
		Template template,
		Set<Expression> expressions,
		Function<String, String> transformValue,
		Function<Object, String> createNaturalRdfLexicalForm
	); @Override Optional<Object> apply(EvaluateExpression evaluateExpression);  }