use of io.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestVertxHttpMethod method testDoMethod.
@Test
public void testDoMethod(@Mocked HttpClient httpClient) throws Exception {
Context context = new MockUp<Context>() {
@Mock
public void runOnContext(Handler<Void> action) {
action.handle(null);
}
}.getMockInstance();
HttpClientWithContext httpClientWithContext = new HttpClientWithContext(httpClient, context);
Invocation invocation = Mockito.mock(Invocation.class);
AsyncResponse asyncResp = Mockito.mock(AsyncResponse.class);
OperationMeta operationMeta = Mockito.mock(OperationMeta.class);
RestOperationMeta swaggerRestOperation = Mockito.mock(RestOperationMeta.class);
Endpoint endpoint = Mockito.mock(Endpoint.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(operationMeta);
URLPathBuilder urlPathBuilder = Mockito.mock(URLPathBuilder.class);
Mockito.when(swaggerRestOperation.getPathBuilder()).thenReturn(urlPathBuilder);
operationMeta.getExtData(RestConst.SWAGGER_REST_OPERATION);
Mockito.when(operationMeta.getExtData(RestConst.SWAGGER_REST_OPERATION)).thenReturn(swaggerRestOperation);
Mockito.when(invocation.getEndpoint()).thenReturn(endpoint);
Mockito.when(request.exceptionHandler(Mockito.any())).then(answer -> null);
this.doMethod(httpClientWithContext, invocation, asyncResp);
Assert.assertTrue(true);
}
use of io.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestVertxHttpMethod method testCreateRequestPath.
@Test
public void testCreateRequestPath() throws Exception {
Invocation invocation = Mockito.mock(Invocation.class);
RestOperationMeta restOperationMeta = Mockito.mock(RestOperationMeta.class);
URLPathBuilder urlPathBuilder = Mockito.mock(URLPathBuilder.class);
Mockito.when(restOperationMeta.getPathBuilder()).thenReturn(urlPathBuilder);
String pathUrl = this.createRequestPath(invocation, restOperationMeta);
Assert.assertNull(pathUrl);
}
use of io.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestVertxPutMethod method testVertxPutMethod.
@Test
public void testVertxPutMethod() {
HttpClient client = Mockito.mock(HttpClient.class);
Invocation invocation = Mockito.mock(Invocation.class);
IpPort ipPort = Mockito.mock(IpPort.class);
RestOperationMeta operation = Mockito.mock(RestOperationMeta.class);
AsyncResponse asyncResp = Mockito.mock(AsyncResponse.class);
Mockito.when(ipPort.getHostOrIp()).thenReturn("test");
assertNotNull("test", ipPort.getHostOrIp());
Mockito.when(ipPort.getPort()).thenReturn(13);
assertEquals(13, ipPort.getPort());
HttpClientRequest obj = VertxPutMethod.INSTANCE.createRequest(client, invocation, ipPort, "testCall", operation, asyncResp);
Assert.assertNull(obj);
}
use of io.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestGrpcCodec method testDecodeResponse.
@Test
public void testDecodeResponse() {
boolean status = false;
try {
RoutingContext routingContext = Mockito.mock(RoutingContext.class);
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);
Buffer bodyBuffer = Mockito.mock(Buffer.class);
Mockito.when(routingContext.getBody()).thenReturn(bodyBuffer);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
Mockito.when(routingContext.request()).thenReturn(request);
Mockito.when(request.getHeader(Const.CSE_CONTEXT)).thenReturn("{\"name\":\"test\"}");
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(operationProtobuf.getResponseSchema()).thenReturn(Mockito.mock(WrapSchema.class));
HttpClientResponse httpResponse = Mockito.mock(HttpClientResponse.class);
Buffer buffer = Mockito.mock(Buffer.class);
GrpcCodec.decodeResponse(invocation, operationProtobuf, httpResponse, buffer);
} catch (Exception e) {
status = true;
}
Assert.assertFalse(status);
}
use of io.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class HighwayServerInvoke method doRunInExecutor.
private void doRunInExecutor() throws Exception {
Invocation invocation = HighwayCodec.decodeRequest(header, operationProtobuf, bodyBuffer);
invocation.next(response -> {
sendResponse(invocation.getContext(), response);
});
}
Aggregations