use of org.springframework.boot.actuate.endpoint.InvocationContext in project spring-boot by spring-projects.
the class CachingOperationInvokerTests method cacheInTtlWithMonoResponse.
@Test
void cacheInTtlWithMonoResponse() {
MonoOperationInvoker.invocations = new AtomicInteger();
MonoOperationInvoker target = new MonoOperationInvoker();
InvocationContext context = new InvocationContext(mock(SecurityContext.class), Collections.emptyMap());
CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL);
Object response = ((Mono<?>) invoker.invoke(context)).block();
Object cachedResponse = ((Mono<?>) invoker.invoke(context)).block();
assertThat(MonoOperationInvoker.invocations).hasValue(1);
assertThat(response).isSameAs(cachedResponse);
}
use of org.springframework.boot.actuate.endpoint.InvocationContext in project spring-boot by spring-projects.
the class ReflectiveOperationInvokerTests method invokeShouldInvokeMethod.
@Test
void invokeShouldInvokeMethod() {
ReflectiveOperationInvoker invoker = new ReflectiveOperationInvoker(this.target, this.operationMethod, this.parameterValueMapper);
Object result = invoker.invoke(new InvocationContext(mock(SecurityContext.class), Collections.singletonMap("name", "boot")));
assertThat(result).isEqualTo("toob");
}
use of org.springframework.boot.actuate.endpoint.InvocationContext in project spring-boot by spring-projects.
the class ReflectiveOperationInvokerTests method invokeShouldResolveParameters.
@Test
void invokeShouldResolveParameters() {
ReflectiveOperationInvoker invoker = new ReflectiveOperationInvoker(this.target, this.operationMethod, this.parameterValueMapper);
Object result = invoker.invoke(new InvocationContext(mock(SecurityContext.class), Collections.singletonMap("name", 1234)));
assertThat(result).isEqualTo("4321");
}
use of org.springframework.boot.actuate.endpoint.InvocationContext in project spring-boot by spring-projects.
the class DiscoveredOperationsFactoryTests method createOperationShouldApplyAdvisors.
@Test
void createOperationShouldApplyAdvisors() {
TestOperationInvokerAdvisor advisor = new TestOperationInvokerAdvisor();
this.invokerAdvisors.add(advisor);
TestOperation operation = getFirst(this.factory.createOperations(EndpointId.of("test"), new ExampleRead()));
operation.invoke(new InvocationContext(mock(SecurityContext.class), Collections.emptyMap()));
assertThat(advisor.getEndpointId()).isEqualTo(EndpointId.of("test"));
assertThat(advisor.getOperationType()).isEqualTo(OperationType.READ);
assertThat(advisor.getParameters()).isEmpty();
}
use of org.springframework.boot.actuate.endpoint.InvocationContext in project spring-boot by spring-projects.
the class DiscoveredOperationsFactoryTests method createOperationsShouldProviderInvoker.
@Test
void createOperationsShouldProviderInvoker() {
TestOperation operation = getFirst(this.factory.createOperations(EndpointId.of("test"), new ExampleWithParams()));
Map<String, Object> params = Collections.singletonMap("name", 123);
Object result = operation.invoke(new InvocationContext(mock(SecurityContext.class), params));
assertThat(result).isEqualTo("123");
}
Aggregations