use of io.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestGrpcServerInvoke method testOnProviderResponseSuccess.
@Test
public void testOnProviderResponseSuccess() {
//boolean status = false;
try {
MockUtil.getInstance().mockMicroserviceMetaManager();
mockForExecutorManager();
mockForOperationMeta();
new MockUp<GrpcServerInvoke>() {
@Mock
private void sendFailResponse(Throwable throwable) {
// Nothing to do Just For mock
}
};
Invocation invocation = Mockito.mock(Invocation.class);
Response response = Mockito.mock(Response.class);
Mockito.when(response.isSuccessed()).thenReturn(true);
Mockito.when(response.getResult()).thenReturn("test");
Mockito.when(routingContext.response()).thenReturn(Mockito.mock(HttpServerResponse.class));
Deencapsulation.setField(lGrpcServerInvoke, "routingContext", routingContext);
Deencapsulation.invoke(lGrpcServerInvoke, "onProviderResponse", invocation, response);
} catch (Exception e) {
// status = true;
}
//Assert.assertTrue(status);
}
use of io.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestGrpcTransport method testSend.
@Test
public void testSend() {
boolean status = false;
Invocation invocation = Mockito.mock(Invocation.class);
AsyncResponse asyncResp = Mockito.mock(AsyncResponse.class);
OperationMeta operationMeta = Mockito.mock(OperationMeta.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(operationMeta);
OperationProtobuf operationProtobuf = Mockito.mock(OperationProtobuf.class);
Mockito.when(operationMeta.getExtData("protobuf")).thenReturn(operationProtobuf);
Endpoint lEndpoint = Mockito.mock(Endpoint.class);
Mockito.when(invocation.getEndpoint()).thenReturn(lEndpoint);
WrapSchema lWrapSchema = Mockito.mock(WrapSchema.class);
Mockito.when(operationProtobuf.getRequestSchema()).thenReturn(lWrapSchema);
IpPort ipPort = Mockito.mock(IpPort.class);
Mockito.when(lEndpoint.getAddress()).thenReturn(ipPort);
Mockito.when(ipPort.getHostOrIp()).thenReturn("127.0.0.1");
Mockito.when(ipPort.getPort()).thenReturn(80);
new MockUp<ClientPoolManager<HttpClientWithContext>>() {
@Mock
public HttpClientWithContext findThreadBindClientPool() {
return Mockito.mock(HttpClientWithContext.class);
}
};
try {
transport.send(invocation, asyncResp);
} catch (Exception e) {
status = true;
}
Assert.assertFalse(status);
}
use of io.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestVertxDeleteMethod method testCreateRequest.
@Test
public void testCreateRequest() {
HttpClient client = Mockito.mock(HttpClient.class);
IpPort ipPort = Mockito.mock(IpPort.class);
Mockito.when(ipPort.getPort()).thenReturn(23);
Mockito.when(ipPort.getHostOrIp()).thenReturn("test");
Invocation invocation = Mockito.mock(Invocation.class);
RestOperationMeta operation = Mockito.mock(RestOperationMeta.class);
AsyncResponse asyncResp = Mockito.mock(AsyncResponse.class);
HttpClientRequest obj = (HttpClientRequest) VertxDeleteMethod.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 InvocationFactory method forConsumer.
public static Invocation forConsumer(ReferenceConfig referenceConfig, OperationMeta operationMeta, Object[] swaggerArguments) {
Invocation invocation = new Invocation(referenceConfig, operationMeta, swaggerArguments);
invocation.addContext(Const.SRC_MICROSERVICE, microserviceName);
return invocation;
}
use of io.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class InvocationFactory method forConsumer.
public static Invocation forConsumer(ReferenceConfig referenceConfig, SchemaMeta schemaMeta, String operationName, Object[] swaggerArguments) {
OperationMeta operationMeta = schemaMeta.ensureFindOperation(operationName);
Invocation invocation = new Invocation(referenceConfig, operationMeta, swaggerArguments);
invocation.addContext(Const.SRC_MICROSERVICE, microserviceName);
return invocation;
}
Aggregations