use of io.servicecomb.core.definition.MicroserviceMeta in project java-chassis by ServiceComb.
the class TestConsumerSchemaFactory method testGetOrCreateConsumer.
@Test
public void testGetOrCreateConsumer() {
MicroserviceMeta microserviceMeta = consumerSchemaFactory.getOrCreateConsumer("ms", "latest");
OperationMeta operationMeta = microserviceMeta.ensureFindOperation("schema.add");
Assert.assertEquals("add", operationMeta.getOperationId());
}
use of io.servicecomb.core.definition.MicroserviceMeta 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.definition.MicroserviceMeta in project java-chassis by ServiceComb.
the class TestDefinition method testMicroServiceMeta.
@Test
public void testMicroServiceMeta() {
MicroserviceMeta oMicroMeta = new MicroserviceMeta("micro1");
Assert.assertEquals(0, oMicroMeta.getSchemaMetas().size());
Assert.assertEquals(0, oMicroMeta.getOperations().size());
Assert.assertEquals("micro1", oMicroMeta.getName());
try {
oMicroMeta.putExtData("key1", new String("value1"));
Assert.assertNotEquals(null, oMicroMeta.getExtData("key1"));
} catch (Exception e) {
Assert.assertNotNull(e);
}
}
use of io.servicecomb.core.definition.MicroserviceMeta in project java-chassis by ServiceComb.
the class PojoReferenceMeta method prepare.
private void prepare() {
referenceConfig = CseContext.getInstance().getConsumerProviderManager().getReferenceConfig(microserviceName);
MicroserviceMeta microserviceMeta = referenceConfig.getMicroserviceMeta();
if (StringUtils.isEmpty(schemaId)) {
// 未指定schemaId,看看consumer接口是否等于契约接口
schemaMeta = microserviceMeta.findSchemaMeta(consumerIntf);
if (schemaMeta == null) {
// 尝试用consumer接口名作为schemaId
schemaId = consumerIntf.getName();
schemaMeta = microserviceMeta.ensureFindSchemaMeta(schemaId);
}
} else {
schemaMeta = microserviceMeta.ensureFindSchemaMeta(schemaId);
}
if (consumerIntf == null) {
consumerIntf = schemaMeta.getSwaggerIntf();
}
CseContext.getInstance().getConsumerSchemaFactory().connectToConsumer(schemaMeta, consumerIntf, consumerOperationMap);
}
use of io.servicecomb.core.definition.MicroserviceMeta in project java-chassis by ServiceComb.
the class GrpcServerInvoke method doInit.
private void doInit(RoutingContext routingContext) throws Exception {
String schemaId = routingContext.pathParam("schema");
String operationName = routingContext.pathParam("operation");
MicroserviceMeta microserviceMeta = microserviceMetaManager.ensureFindValue(routingContext.request().getHeader(Const.DEST_MICROSERVICE));
SchemaMeta schemaMeta = microserviceMeta.ensureFindSchemaMeta(schemaId);
this.routingContext = routingContext;
this.operationMeta = schemaMeta.ensureFindOperation(operationName);
this.operationProtobuf = ProtobufManager.getOrCreateOperation(operationMeta);
}
Aggregations