-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to retrieve all variable names of a Scope (#496)
* Add a test file to test GetKeys of the Scope class * Add a GetKeys method * Change method name to camelCase * Fix test
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
pebble/src/test/java/com/mitchellbosecke/pebble/ScopeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.mitchellbosecke.pebble; | ||
|
||
import com.mitchellbosecke.pebble.template.Scope; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class ScopeTest { | ||
|
||
@Test | ||
void testGetKeys() { | ||
Map<String, Object> map = new HashMap<>(); | ||
map.putIfAbsent("key1", new String("value1")); | ||
map.putIfAbsent("key2", new String("value2")); | ||
|
||
Scope scope = new Scope(map, false); | ||
Set<String> expected = new HashSet<>(); | ||
expected.add("key1"); | ||
expected.add("key2"); | ||
|
||
assertEquals(expected, scope.getKeys()); | ||
} | ||
} |