protected void assertCacheInvocationParameter(CacheInvocationParameter actual, Class<?> targetType, Object value, int position) { assertEquals("wrong parameter type for " + actual, targetType, actual.getRawType()); assertEquals("wrong parameter value for " + actual, value, actual.getValue()); assertEquals("wrong parameter position for " + actual, position, actual.getParameterPosition()); }
private Object toValue(final CacheInvocationParameter it) { final Object value = it.getValue(); // placeholder provider, replace it by actual values to keep the cache consistent (lang etc) if (it.getRawType() == Function.class) { return fnToKey(Function.class.cast(it.getValue())); } if (RequestContext.class.isInstance(value)) { final RequestContext ctx = RequestContext.class.cast(value); return Stream .concat(Stream.of(ofNullable(fnToKey(ctx::findPlaceholder)).orElse(EMPTY_ARRAY)), Stream.of(ctx.language())) .toArray(); } return value; }