DATACMNS-1108 - Add repository configuration infrastructure.
Add config infrastructure for ReactiveQueryMethodEvaluationContextProvider. Original Pull Request: #454
This commit is contained in:
committed by
Christoph Strobl
parent
edcf1a0562
commit
0671862ed8
@@ -30,9 +30,9 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
*/
|
||||
class ExpressionDependenciesUnitTests {
|
||||
|
||||
SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
static final SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
|
||||
@Test
|
||||
@Test // DATACMNS-1108
|
||||
void shouldExtractDependencies() {
|
||||
|
||||
String expression = "hasRole('ROLE_ADMIN') ? '%' : principal.emailAddress";
|
||||
@@ -46,7 +46,7 @@ class ExpressionDependenciesUnitTests {
|
||||
"principal");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATACMNS-1108
|
||||
void shouldExtractDependenciesFromMethodCallArgs() {
|
||||
|
||||
String expression = "hasRole(principal.emailAddress)";
|
||||
@@ -60,7 +60,7 @@ class ExpressionDependenciesUnitTests {
|
||||
"principal");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATACMNS-1108
|
||||
void shouldExtractFirstMethodAsDependency() {
|
||||
|
||||
String expression = "hello().hasRole(principal.emailAddress, principal.somethingElse).somethingElse()";
|
||||
@@ -74,4 +74,13 @@ class ExpressionDependenciesUnitTests {
|
||||
"principal");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1108
|
||||
void shouldMergeDependencies() {
|
||||
|
||||
ExpressionDependencies left = ExpressionDependencies.discover(PARSER.parseExpression("hasRole('ROLE_ADMIN')"));
|
||||
ExpressionDependencies right = ExpressionDependencies.discover(PARSER.parseExpression("principal.somethingElse"));
|
||||
|
||||
assertThat(left.mergeWith(right)).extracting(ExpressionDependencies.ExpressionDependency::getSymbol)
|
||||
.containsOnly("hasRole", "principal");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class ReactiveExtensionAwareEvaluationContextProviderUnitTests {
|
||||
ReactiveExtensionAwareEvaluationContextProvider provider = new ReactiveExtensionAwareEvaluationContextProvider(
|
||||
Arrays.asList(SampleReactiveExtension.INSTANCE, GenericExtension.INSTANCE));
|
||||
|
||||
provider.getEvaluationContext(new Object[0], dependencies).map(expression::getValue) //
|
||||
provider.getEvaluationContextLater(new Object[0], dependencies).map(expression::getValue) //
|
||||
.as(StepVerifier::create) //
|
||||
.expectNext("Walter") //
|
||||
.verifyComplete();
|
||||
@@ -75,7 +75,7 @@ class ReactiveExtensionAwareEvaluationContextProviderUnitTests {
|
||||
ReactiveExtensionAwareEvaluationContextProvider provider = new ReactiveExtensionAwareEvaluationContextProvider(
|
||||
Arrays.asList(SampleReactiveExtension.INSTANCE, GenericExtension.INSTANCE));
|
||||
|
||||
provider.getEvaluationContext(new Object[0], dependencies).map(expression::getValue) //
|
||||
provider.getEvaluationContextLater(new Object[0], dependencies).map(expression::getValue) //
|
||||
.as(StepVerifier::create) //
|
||||
.expectNext(true) //
|
||||
.verifyComplete();
|
||||
@@ -93,7 +93,7 @@ class ReactiveExtensionAwareEvaluationContextProviderUnitTests {
|
||||
ReactiveExtensionAwareEvaluationContextProvider provider = new ReactiveExtensionAwareEvaluationContextProvider(
|
||||
Arrays.asList(SampleReactiveExtension.INSTANCE, GenericExtension.INSTANCE));
|
||||
|
||||
provider.getEvaluationContext(new Object[0], dependencies).map(expression::getValue) //
|
||||
provider.getEvaluationContextLater(new Object[0], dependencies).map(expression::getValue) //
|
||||
.as(StepVerifier::create) //
|
||||
.verifyError(SpelEvaluationException.class);
|
||||
|
||||
@@ -110,7 +110,7 @@ class ReactiveExtensionAwareEvaluationContextProviderUnitTests {
|
||||
ReactiveExtensionAwareEvaluationContextProvider provider = new ReactiveExtensionAwareEvaluationContextProvider(
|
||||
Collections.singletonList(GenericReactiveExtension.INSTANCE));
|
||||
|
||||
provider.getEvaluationContext(new Object[0], dependencies).map(expression::getValue) //
|
||||
provider.getEvaluationContextLater(new Object[0], dependencies).map(expression::getValue) //
|
||||
.as(StepVerifier::create) //
|
||||
.expectNext(2) //
|
||||
.verifyComplete();
|
||||
|
||||
Reference in New Issue
Block a user