WW-5363 Fix super#internalGet

This commit is contained in:
Kusal Kithul-Godage
2023-11-14 02:10:16 +11:00
parent cf9e53573e
commit 6c98663f84
2 changed files with 19 additions and 6 deletions
@@ -77,7 +77,11 @@ public class StrutsVelocityContext extends VelocityContext {
}
protected List<Function<String, Object>> contextGetterList() {
return Arrays.asList(super::internalGet, this::chainedContextGet, this::stackGet, this::stackContextGet);
return Arrays.asList(this::superGet, this::chainedContextGet, this::stackGet, this::stackContextGet);
}
protected Object superGet(String key) {
return super.internalGet(key);
}
protected Object stackGet(String key) {
@@ -74,15 +74,24 @@ public class StrutsVelocityContextTest {
assertEquals("bar", strutsVelocityContext.internalGet("foo"));
}
@Test
public void getSuperValue() {
strutsVelocityContext.put("foo", "bar");
assertEquals("bar", strutsVelocityContext.internalGet("foo"));
}
@Test
public void getValuePrecedence() {
when(chainedContext.internalGet("foo")).thenReturn("bar");
assertEquals("bar", strutsVelocityContext.internalGet("foo"));
stackContext.put("foo", "quux");
assertEquals("quux", strutsVelocityContext.internalGet("foo"));
when(stack.findValue("foo")).thenReturn("baz");
assertEquals("bar", strutsVelocityContext.internalGet("foo"));
when(stack.findValue("foo")).thenReturn("qux");
assertEquals("qux", strutsVelocityContext.internalGet("foo"));
stackContext.put("foo", "qux");
when(chainedContext.internalGet("foo")).thenReturn("baz");
assertEquals("baz", strutsVelocityContext.internalGet("foo"));
strutsVelocityContext.put("foo", "bar");
assertEquals("bar", strutsVelocityContext.internalGet("foo"));
}
}