use of org.apache.servicecomb.common.rest.locator.OperationLocator in project incubator-servicecomb-java-chassis by apache.
the class CseClientHttpRequest method createRequestMeta.
private RequestMeta createRequestMeta(String httpMetod, URI uri) {
String microserviceName = uri.getAuthority();
ReferenceConfig referenceConfig = ReferenceConfigUtils.getForInvoke(microserviceName);
MicroserviceMeta microserviceMeta = referenceConfig.getMicroserviceMeta();
ServicePathManager servicePathManager = ServicePathManager.getServicePathManager(microserviceMeta);
if (servicePathManager == null) {
throw new Error(String.format("no schema defined for %s:%s", microserviceMeta.getAppId(), microserviceMeta.getName()));
}
OperationLocator locator = servicePathManager.consumerLocateOperation(path, httpMetod);
RestOperationMeta swaggerRestOperation = locator.getOperation();
Map<String, String> pathParams = locator.getPathVarMap();
return new RequestMeta(referenceConfig, swaggerRestOperation, pathParams);
}
use of org.apache.servicecomb.common.rest.locator.OperationLocator in project incubator-servicecomb-java-chassis by apache.
the class TestAbstractRestInvocation method findRestOperationNormal.
@Test
public void findRestOperationNormal(@Mocked MicroserviceMeta microserviceMeta, @Mocked ServicePathManager servicePathManager, @Mocked OperationLocator locator) {
restInvocation = new AbstractRestInvocationForTest() {
@Override
protected OperationLocator locateOperation(ServicePathManager servicePathManager) {
return locator;
}
};
requestEx = new AbstractHttpServletRequest() {
};
restInvocation.requestEx = requestEx;
Map<String, String> pathVars = new HashMap<>();
new Expectations(ServicePathManager.class) {
{
ServicePathManager.getServicePathManager(microserviceMeta);
result = servicePathManager;
locator.getPathVarMap();
result = pathVars;
locator.getOperation();
result = restOperation;
}
};
restInvocation.findRestOperation(microserviceMeta);
Assert.assertSame(restOperation, restInvocation.restOperationMeta);
Assert.assertSame(pathVars, requestEx.getAttribute(RestConst.PATH_PARAMETERS));
}
use of org.apache.servicecomb.common.rest.locator.OperationLocator in project incubator-servicecomb-java-chassis by apache.
the class AbstractRestInvocation method findRestOperation.
protected void findRestOperation(MicroserviceMeta microserviceMeta) {
ServicePathManager servicePathManager = ServicePathManager.getServicePathManager(microserviceMeta);
if (servicePathManager == null) {
LOGGER.error("No schema defined for {}:{}.", microserviceMeta.getAppId(), microserviceMeta.getName());
throw new InvocationException(Status.NOT_FOUND, Status.NOT_FOUND.getReasonPhrase());
}
OperationLocator locator = locateOperation(servicePathManager);
requestEx.setAttribute(RestConst.PATH_PARAMETERS, locator.getPathVarMap());
this.restOperationMeta = locator.getOperation();
}
Aggregations