use of io.servicecomb.common.rest.definition.path.URLPathBuilder in project java-chassis by ServiceComb.
the class TestVertxHttpMethod method testSetCseContext.
@Test
public void testSetCseContext() {
boolean status = false;
try {
Invocation invocation = Mockito.mock(Invocation.class);
HttpClientResponse httpResponse = Mockito.mock(HttpClientResponse.class);
OperationMeta operationMeta = Mockito.mock(OperationMeta.class);
RestOperationMeta swaggerRestOperation = Mockito.mock(RestOperationMeta.class);
HttpClientRequest request = Mockito.mock(HttpClientRequest.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);
String contentType = httpResponse.getHeader("Content-Type");
ProduceProcessor produceProcessor = Mockito.mock(ProduceProcessor.class);
Mockito.when(swaggerRestOperation.findProduceProcessor(contentType)).thenReturn(produceProcessor);
this.setCseContext(invocation, request);
} catch (Exception ex) {
status = true;
}
Assert.assertFalse(status);
}
use of io.servicecomb.common.rest.definition.path.URLPathBuilder in project java-chassis by ServiceComb.
the class TestVertxHttpMethod method testHandleResponse.
@Test
public void testHandleResponse() {
boolean status = false;
try {
Invocation invocation = Mockito.mock(Invocation.class);
AsyncResponse asyncResp = Mockito.mock(AsyncResponse.class);
HttpClientResponse httpResponse = Mockito.mock(HttpClientResponse.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);
String contentType = httpResponse.getHeader("Content-Type");
ProduceProcessor produceProcessor = Mockito.mock(ProduceProcessor.class);
Mockito.when(swaggerRestOperation.findProduceProcessor(contentType)).thenReturn(produceProcessor);
this.handleResponse(invocation, httpResponse, swaggerRestOperation, asyncResp);
} catch (Exception ex) {
status = true;
}
Assert.assertFalse(status);
}
Aggregations