use of org.springframework.boot.actuate.endpoint.invoke.OperationInvoker in project spring-boot by spring-projects.
the class CachingOperationInvokerAdvisorTests method applyWhenOperationIsNotReadShouldNotAddAdvise.
@Test
void applyWhenOperationIsNotReadShouldNotAddAdvise() {
OperationParameters parameters = getParameters("get");
OperationInvoker advised = this.advisor.apply(EndpointId.of("foo"), OperationType.WRITE, parameters, this.invoker);
assertThat(advised).isSameAs(this.invoker);
}
use of org.springframework.boot.actuate.endpoint.invoke.OperationInvoker in project spring-boot by spring-projects.
the class CachingOperationInvokerAdvisorTests method assertAdviseIsApplied.
private void assertAdviseIsApplied(OperationParameters parameters) {
OperationInvoker advised = this.advisor.apply(EndpointId.of("foo"), OperationType.READ, parameters, this.invoker);
assertThat(advised).isInstanceOf(CachingOperationInvoker.class);
assertThat(advised).hasFieldOrPropertyWithValue("invoker", this.invoker);
assertThat(advised).hasFieldOrPropertyWithValue("timeToLive", 100L);
}
use of org.springframework.boot.actuate.endpoint.invoke.OperationInvoker in project spring-boot by spring-projects.
the class CachingOperationInvokerAdvisorTests method applyWhenHasAtLeaseOneMandatoryParameterShouldNotAddAdvise.
@Test
void applyWhenHasAtLeaseOneMandatoryParameterShouldNotAddAdvise() {
OperationParameters parameters = getParameters("getWithParameters", String.class, String.class);
OperationInvoker advised = this.advisor.apply(EndpointId.of("foo"), OperationType.READ, parameters, this.invoker);
assertThat(advised).isSameAs(this.invoker);
}
use of org.springframework.boot.actuate.endpoint.invoke.OperationInvoker in project spring-boot by spring-projects.
the class CachingOperationInvokerAdvisorTests method applyWithMandatoryCachedAndNonCachedShouldAddAdvise.
@Test
void applyWithMandatoryCachedAndNonCachedShouldAddAdvise() {
OperationParameters parameters = getParameters("getWithServerNamespaceAndOtherMandatory", WebServerNamespace.class, String.class);
OperationInvoker advised = this.advisor.apply(EndpointId.of("foo"), OperationType.READ, parameters, this.invoker);
assertThat(advised).isSameAs(this.invoker);
}
use of org.springframework.boot.actuate.endpoint.invoke.OperationInvoker in project spring-boot by spring-projects.
the class CachingOperationInvokerTests method targetAlwaysInvokedWithParameters.
@Test
void targetAlwaysInvokedWithParameters() {
OperationInvoker target = mock(OperationInvoker.class);
Map<String, Object> parameters = new HashMap<>();
parameters.put("test", "value");
parameters.put("something", null);
InvocationContext context = new InvocationContext(mock(SecurityContext.class), parameters);
given(target.invoke(context)).willReturn(new Object());
CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL);
invoker.invoke(context);
invoker.invoke(context);
invoker.invoke(context);
then(target).should(times(3)).invoke(context);
}
Aggregations