use of io.servicecomb.core.definition.SchemaMeta 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.SchemaMeta in project java-chassis by ServiceComb.
the class ClientVerticle method send.
protected void send(Long event) {
User user = new User();
TestRequest request = new TestRequest();
request.setUser(user);
request.setIndex(idx);
request.setData(PojoClient.buffer);
SchemaMeta schemaMeta = config.getMicroserviceMeta().ensureFindSchemaMeta("server");
Object[] args = new Object[] { request };
Invocation invocation = InvocationFactory.forConsumer(config, schemaMeta, "wrapParam", args);
InvokerUtils.reactiveInvoke(invocation, ar -> {
if (ar.isSuccessed()) {
User result = ar.getResult();
if (result.getIndex() != idx) {
System.out.printf("error result:%s, expect idx %d\n", result, idx);
}
} else {
CommonExceptionData data = (CommonExceptionData) ((InvocationException) ar.getResult()).getErrorData();
System.out.println(data.getMessage());
}
send(null);
});
}
use of io.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class TestDynamicSchemaLoader method testRegisterSchemas.
@Test
public void testRegisterSchemas() {
DynamicSchemaLoader.INSTANCE.registerSchemas("classpath*:test/test/schema.yaml");
SchemaMeta schemaMeta = microserviceMetaManager.ensureFindSchemaMeta("ms", "schema");
Assert.assertEquals("cse.gen.app.ms.schema", schemaMeta.getPackageName());
}
use of io.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class MockUtil method mockMicroserviceMeta.
public void mockMicroserviceMeta() {
new MockUp<MicroserviceMeta>() {
@Mock
public SchemaMeta ensureFindSchemaMeta(String schemaId) {
SchemaMeta lSchemaMeta = Mockito.mock(SchemaMeta.class);
Mockito.when(lSchemaMeta.getSwaggerIntf()).thenAnswer(new Answer<Class<? extends TestPojoConsumerProvider>>() {
@Override
public Class<? extends TestPojoConsumerProvider> answer(InvocationOnMock invocation) throws Throwable {
return TestPojoConsumerProvider.class;
}
});
return lSchemaMeta;
}
@Mock
public SchemaMeta ensureFindSchemaMeta(Class<?> schemaIntf) {
return Mockito.mock(SchemaMeta.class);
}
};
}
use of io.servicecomb.core.definition.SchemaMeta 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