Search in sources :

Example 26 with SchemaMeta

use of io.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.

the class TestGrpcCodec method testDecodeResponseEx.

@Test
public void testDecodeResponseEx() {
    boolean status = false;
    OperationMeta operationMeta = Mockito.mock(OperationMeta.class);
    OperationProtobuf operationProtobuf = Mockito.mock(OperationProtobuf.class);
    WrapSchema schema = ProtobufSchemaUtils.getOrCreateSchema(int.class);
    Mockito.when(operationProtobuf.getRequestSchema()).thenReturn(schema);
    Mockito.when(operationMeta.getExtData("protobuf")).thenReturn(operationProtobuf);
    HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
    SchemaMeta schemaMeta = Mockito.mock(SchemaMeta.class);
    Mockito.when(operationMeta.getSchemaMeta()).thenReturn(schemaMeta);
    Mockito.when(request.getHeader(Const.CSE_CONTEXT)).thenReturn("{\"name\":\"test\"}");
    Invocation invocation = Mockito.mock(Invocation.class);
    Response response = Mockito.mock(Response.class);
    Mockito.when(response.getResult()).thenReturn("test");
    Mockito.when(operationProtobuf.getResponseSchema()).thenReturn(Mockito.mock(WrapSchema.class));
    HttpClientResponse httpResponse = Mockito.mock(HttpClientResponse.class);
    Buffer buffer = Mockito.mock(Buffer.class);
    Mockito.when(httpResponse.statusCode()).thenReturn(200);
    try {
        GrpcCodec.decodeResponse(invocation, operationProtobuf, httpResponse, buffer);
    } catch (Exception e) {
        status = true;
    }
    Assert.assertFalse(status);
}
Also used : HttpClientResponse(io.vertx.core.http.HttpClientResponse) Response(io.servicecomb.core.Response) Buffer(io.vertx.core.buffer.Buffer) Invocation(io.servicecomb.core.Invocation) OperationProtobuf(io.servicecomb.codec.protobuf.definition.OperationProtobuf) HttpServerRequest(io.vertx.core.http.HttpServerRequest) SchemaMeta(io.servicecomb.core.definition.SchemaMeta) HttpClientResponse(io.vertx.core.http.HttpClientResponse) OperationMeta(io.servicecomb.core.definition.OperationMeta) WrapSchema(io.servicecomb.codec.protobuf.utils.WrapSchema) Test(org.junit.Test)

Aggregations

SchemaMeta (io.servicecomb.core.definition.SchemaMeta)26 MicroserviceMeta (io.servicecomb.core.definition.MicroserviceMeta)11 Test (org.junit.Test)10 OperationMeta (io.servicecomb.core.definition.OperationMeta)8 ArrayList (java.util.ArrayList)4 OperationProtobuf (io.servicecomb.codec.protobuf.definition.OperationProtobuf)3 WrapSchema (io.servicecomb.codec.protobuf.utils.WrapSchema)3 Invocation (io.servicecomb.core.Invocation)3 HashMap (java.util.HashMap)3 MockUp (mockit.MockUp)3 RestOperationMeta (io.servicecomb.common.rest.definition.RestOperationMeta)2 ServicePathManager (io.servicecomb.common.rest.locator.ServicePathManager)2 MicroserviceMetaManager (io.servicecomb.core.definition.MicroserviceMetaManager)2 ConsumerOperationMeta (io.servicecomb.core.provider.consumer.ConsumerOperationMeta)2 UnitTestMeta (io.servicecomb.core.unittest.UnitTestMeta)2 Swagger (io.swagger.models.Swagger)2 Buffer (io.vertx.core.buffer.Buffer)2 HttpServerRequest (io.vertx.core.http.HttpServerRequest)2 Executor (java.util.concurrent.Executor)2 ArgsNotWrapSchema (io.servicecomb.codec.protobuf.utils.schema.ArgsNotWrapSchema)1