Search in sources :

Example 1 with FilterNode

use of org.apache.servicecomb.core.filter.FilterNode in project java-chassis by ServiceComb.

the class ProducerInvocationFlowTest method mockInvocationFailed.

private void mockInvocationFailed() {
    filterNode = new FilterNode((_invocation, _node) -> {
        throw new RuntimeExceptionWithoutStackTrace();
    });
    mockFilterChain();
}
Also used : RuntimeExceptionWithoutStackTrace(org.apache.servicecomb.foundation.test.scaffolding.exception.RuntimeExceptionWithoutStackTrace) FilterNode(org.apache.servicecomb.core.filter.FilterNode) Expectations(mockit.Expectations) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta) Invocation(org.apache.servicecomb.core.Invocation) HttpServletRequestEx(org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx) Exceptions(org.apache.servicecomb.core.exception.Exceptions) Injectable(mockit.Injectable) Response(org.apache.servicecomb.swagger.invocation.Response) Mocked(mockit.Mocked) Verifications(mockit.Verifications) RuntimeExceptionWithoutStackTrace(org.apache.servicecomb.foundation.test.scaffolding.exception.RuntimeExceptionWithoutStackTrace) FilterNode(org.apache.servicecomb.core.filter.FilterNode)

Example 2 with FilterNode

use of org.apache.servicecomb.core.filter.FilterNode in project java-chassis by ServiceComb.

the class ProducerOperationFilter method onFilter.

@Override
public CompletableFuture<Response> onFilter(Invocation invocation, FilterNode nextNode) {
    invocation.onBusinessMethodStart();
    SwaggerProducerOperation producerOperation = invocation.getOperationMeta().getSwaggerProducerOperation();
    Object instance = producerOperation.getProducerInstance();
    Method method = producerOperation.getProducerMethod();
    Object[] args = invocation.toProducerArguments();
    return invoke(invocation, instance, method, args).thenApply(result -> convertResultToResponse(invocation, producerOperation, result)).whenComplete((response, throwable) -> processMetrics(invocation));
}
Also used : SwaggerProducerOperation(org.apache.servicecomb.swagger.engine.SwaggerProducerOperation) Component(org.springframework.stereotype.Component) ProducerFilter(org.apache.servicecomb.core.filter.ProducerFilter) FilterNode(org.apache.servicecomb.core.filter.FilterNode) AsyncUtils(org.apache.servicecomb.foundation.common.utils.AsyncUtils) CompletableFuture(java.util.concurrent.CompletableFuture) Exceptions(org.apache.servicecomb.core.exception.Exceptions) ContextUtils(org.apache.servicecomb.swagger.invocation.context.ContextUtils) Method(java.lang.reflect.Method) Nonnull(javax.annotation.Nonnull) Response(org.apache.servicecomb.swagger.invocation.Response) Invocation(org.apache.servicecomb.core.Invocation) SwaggerProducerOperation(org.apache.servicecomb.swagger.engine.SwaggerProducerOperation) Method(java.lang.reflect.Method)

Aggregations

Invocation (org.apache.servicecomb.core.Invocation)2 Exceptions (org.apache.servicecomb.core.exception.Exceptions)2 FilterNode (org.apache.servicecomb.core.filter.FilterNode)2 Response (org.apache.servicecomb.swagger.invocation.Response)2 Method (java.lang.reflect.Method)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)1 Nonnull (javax.annotation.Nonnull)1 Expectations (mockit.Expectations)1 Injectable (mockit.Injectable)1 Mocked (mockit.Mocked)1 Verifications (mockit.Verifications)1 MicroserviceMeta (org.apache.servicecomb.core.definition.MicroserviceMeta)1 ProducerFilter (org.apache.servicecomb.core.filter.ProducerFilter)1 AsyncUtils (org.apache.servicecomb.foundation.common.utils.AsyncUtils)1 RuntimeExceptionWithoutStackTrace (org.apache.servicecomb.foundation.test.scaffolding.exception.RuntimeExceptionWithoutStackTrace)1 HttpServletRequestEx (org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx)1 SwaggerProducerOperation (org.apache.servicecomb.swagger.engine.SwaggerProducerOperation)1 ContextUtils (org.apache.servicecomb.swagger.invocation.context.ContextUtils)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1