use of io.servicecomb.core.provider.consumer.ConsumerOperationMeta in project java-chassis by ServiceComb.
the class TestConsumerSchemaFactory method testConnectToConsumerDiff.
@Test
public void testConnectToConsumerDiff() {
MicroserviceMeta microserviceMeta = consumerSchemaFactory.getOrCreateConsumer("ms", "latest");
SchemaMeta schemaMeta = microserviceMeta.ensureFindSchemaMeta("schema");
Map<String, ConsumerOperationMeta> consumerOperationMap = new HashMap<>();
consumerSchemaFactory.connectToConsumer(schemaMeta, Intf.class, consumerOperationMap);
Assert.assertEquals(1, consumerOperationMap.size());
ConsumerOperationMeta consumerOperationMeta = consumerOperationMap.get("add");
Assert.assertEquals(ConsumerArgumentToBodyField.class, consumerOperationMeta.getArgsMapper().getArgumentMapper(0).getClass());
Assert.assertEquals(ConsumerResponseSame.class, consumerOperationMeta.getResponseMapper().getClass());
}
use of io.servicecomb.core.provider.consumer.ConsumerOperationMeta in project java-chassis by ServiceComb.
the class Invoker method invoke.
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Invocation invocation = InvocationFactory.forConsumer(config, schemaMeta, method.getName(), null);
ConsumerOperationMeta consumerOperation = consumerOperationMap.get(method.getName());
consumerOperation.getArgsMapper().toInvocation(args, invocation);
Response response = InvokerUtils.innerSyncInvoke(invocation);
if (response.isSuccessed()) {
return consumerOperation.getResponseMapper().mapResponse(response);
}
throw ExceptionFactory.convertConsumerException((Throwable) response.getResult());
// return InvokerUtils.invoke(invocation);
}
use of io.servicecomb.core.provider.consumer.ConsumerOperationMeta in project java-chassis by ServiceComb.
the class TestConsumerSchemaFactory method testConnectToConsumerSame.
@Test
public void testConnectToConsumerSame() {
MicroserviceMeta microserviceMeta = consumerSchemaFactory.getOrCreateConsumer("ms", "latest");
SchemaMeta schemaMeta = microserviceMeta.ensureFindSchemaMeta("schema");
Map<String, ConsumerOperationMeta> consumerOperationMap = new HashMap<>();
consumerSchemaFactory.connectToConsumer(schemaMeta, null, consumerOperationMap);
Assert.assertEquals(1, consumerOperationMap.size());
ConsumerOperationMeta consumerOperationMeta = consumerOperationMap.get("add");
Assert.assertEquals(ConsumerArgumentSame.class, consumerOperationMeta.getArgsMapper().getArgumentMapper(0).getClass());
Assert.assertEquals(ConsumerResponseSame.class, consumerOperationMeta.getResponseMapper().getClass());
}
use of io.servicecomb.core.provider.consumer.ConsumerOperationMeta in project java-chassis by ServiceComb.
the class ConsumerSchemaFactory method createOperation.
protected void createOperation(ConsumerSchemaContext context, OperationMeta operationMeta, ConsumerArgumentsMapper argsMapper) {
if (context.getConsumerOperationMap() == null) {
return;
}
Method method = ReflectUtils.findMethod(context.getProviderClass(), operationMeta.getMethod().getName());
ConsumerResponseMapper responseMapper = responseMapperFactory.createResponseMapper(method.getReturnType());
ConsumerOperationMeta consumerOperationMeta = new ConsumerOperationMeta(operationMeta, argsMapper, responseMapper);
context.getConsumerOperationMap().put(operationMeta.getMethod().getName(), consumerOperationMeta);
}
Aggregations