Skip to content

Commit

Permalink
Merge pull request apache#793 from apache/WW-5363-velocity-order-2
Browse files Browse the repository at this point in the history
WW-5363 Remove redundant method from VelocityManager
  • Loading branch information
kusalk authored Nov 15, 2023
2 parents 9f45983 + 0504e70 commit 63b0da3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public Object internalGet(String key) {
}

protected List<Function<String, Object>> 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) {
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -49,12 +47,8 @@ public class StrutsVelocityContextTest {
@Mock
private ValueStack stack;

private Map<String, Object> stackContext;

@Before
public void setUp() throws Exception {
stackContext = new HashMap<>();
when(stack.getContext()).thenReturn(stackContext);
strutsVelocityContext = new StrutsVelocityContext(singletonList(chainedContext), stack);
}

Expand All @@ -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");
Expand All @@ -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"));

Expand Down

0 comments on commit 63b0da3

Please sign in to comment.