-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an option to merge placeholder contexts
- Loading branch information
shitzuu
committed
Aug 27, 2024
1 parent
ac504e1
commit 1eb19c3
Showing
2 changed files
with
46 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
37 changes: 37 additions & 0 deletions
37
honey-common/test/dev/shiza/honey/placeholder/evaluator/PlaceholderContextTests.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,37 @@ | ||
package dev.shiza.honey.placeholder.evaluator; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class PlaceholderContextTests { | ||
|
||
@Test | ||
void mergeContexts() { | ||
final PlaceholderContext one = | ||
PlaceholderContext.create().withValue("hello", "world").withPromisedValue("hello", "world"); | ||
final PlaceholderContext two = | ||
PlaceholderContext.create().withValue("world", "hello").withPromisedValue("world", "hello"); | ||
final PlaceholderContext mergedContext = one.merge(two); | ||
assertThat(mergedContext.getValues()).hasSize(2); | ||
assertThat(mergedContext.getPromisedValues()).hasSize(2); | ||
} | ||
|
||
@Test | ||
void mergeContextsWithDuplicates() { | ||
final PlaceholderContext one = PlaceholderContext.create().withValue("hello", "world"); | ||
final PlaceholderContext two = PlaceholderContext.create().withValue("hello", "world2"); | ||
final PlaceholderContext mergedContext = one.merge(two); | ||
assertThat(mergedContext.getValues()).hasSize(1); | ||
assertThat(mergedContext.getPromisedValues()).isEmpty(); | ||
} | ||
|
||
@Test | ||
void mergeEmptyContexts() { | ||
final PlaceholderContext one = PlaceholderContext.create(); | ||
final PlaceholderContext two = PlaceholderContext.create(); | ||
final PlaceholderContext mergedContext = one.merge(two); | ||
assertThat(mergedContext.getValues()).isEmpty(); | ||
assertThat(mergedContext.getPromisedValues()).isEmpty(); | ||
} | ||
} |