From 0504e7076c3a94945e168d72e06ef3d15a98a0dc Mon Sep 17 00:00:00 2001 From: Kusal Kithul-Godage Date: Wed, 15 Nov 2023 16:06:24 +1100 Subject: [PATCH] WW-5363 Remove redundant method from VelocityManager --- .../views/velocity/StrutsVelocityContext.java | 9 +-------- .../views/velocity/StrutsVelocityContextTest.java | 15 --------------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java index 99be98b156..4241f6ead4 100644 --- a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java +++ b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java @@ -77,7 +77,7 @@ public Object internalGet(String key) { } protected List> contextGetterList() { - return Arrays.asList(this::superGet, this::chainedContextGet, this::stackGet, this::stackContextGet); + return Arrays.asList(this::superGet, this::chainedContextGet, this::stackGet); } protected Object superGet(String key) { @@ -91,13 +91,6 @@ protected Object stackGet(String key) { return stack.findValue(key); } - protected Object stackContextGet(String key) { - if (stack == null) { - return null; - } - return stack.getContext().get(key); - } - protected Object chainedContextGet(String key) { if (chainedContexts == null) { return null; diff --git a/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/StrutsVelocityContextTest.java b/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/StrutsVelocityContextTest.java index 1405637b35..6cd38c8aa6 100644 --- a/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/StrutsVelocityContextTest.java +++ b/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/StrutsVelocityContextTest.java @@ -27,9 +27,7 @@ import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; -import java.util.HashMap; import java.util.List; -import java.util.Map; import static java.util.Collections.singletonList; import static org.junit.Assert.assertEquals; @@ -49,12 +47,8 @@ public class StrutsVelocityContextTest { @Mock private ValueStack stack; - private Map stackContext; - @Before public void setUp() throws Exception { - stackContext = new HashMap<>(); - when(stack.getContext()).thenReturn(stackContext); strutsVelocityContext = new StrutsVelocityContext(singletonList(chainedContext), stack); } @@ -70,12 +64,6 @@ public void getStackValue() { assertEquals("bar", strutsVelocityContext.internalGet("foo")); } - @Test - public void getStackContextValue() { - stackContext.put("foo", "bar"); - assertEquals("bar", strutsVelocityContext.internalGet("foo")); - } - @Test public void getSuperValue() { strutsVelocityContext.put("foo", "bar"); @@ -84,9 +72,6 @@ public void getSuperValue() { @Test public void getValuePrecedence() { - stackContext.put("foo", "quux"); - assertEquals("quux", strutsVelocityContext.internalGet("foo")); - when(stack.findValue("foo")).thenReturn("qux"); assertEquals("qux", strutsVelocityContext.internalGet("foo"));