use of org.apache.servicecomb.common.rest.definition.RestOperationMeta in project incubator-servicecomb-java-chassis by apache.
the class ServicePathManager method addSchema.
public void addSchema(SchemaMeta schemaMeta) {
if (isSchemaExists(schemaMeta.getSchemaId())) {
return;
}
schemaIdSet.add(schemaMeta.getSchemaId());
for (OperationMeta operationMeta : schemaMeta.getOperations()) {
RestOperationMeta restOperationMeta = new RestOperationMeta();
restOperationMeta.init(operationMeta);
operationMeta.putExtData(RestConst.SWAGGER_REST_OPERATION, restOperationMeta);
addResource(restOperationMeta);
}
LOGGER.info("add schema to service paths. {}:{}:{}.", schemaMeta.getMicroserviceMeta().getAppId(), schemaMeta.getMicroserviceName(), schemaMeta.getSchemaId());
}
use of org.apache.servicecomb.common.rest.definition.RestOperationMeta in project incubator-servicecomb-java-chassis by apache.
the class TestMicroservicePaths method testAddResourceDynamic.
@Test
public void testAddResourceDynamic() {
RestOperationMeta dynamicRes = UnitTestRestUtils.createRestOperationMeta("POST", "/dynamic/{id}");
MicroservicePaths paths = new MicroservicePaths();
paths.addResource(dynamicRes);
Assert.assertSame(dynamicRes, paths.getDynamicPathOperationList().get(0));
}
use of org.apache.servicecomb.common.rest.definition.RestOperationMeta in project incubator-servicecomb-java-chassis by apache.
the class TestMicroservicePaths method testAddResourceStaticDuplicatedHttpMethod.
@Test
public void testAddResourceStaticDuplicatedHttpMethod() {
RestOperationMeta staticResPost = UnitTestRestUtils.createRestOperationMeta("POST", "/static");
MicroservicePaths paths = new MicroservicePaths();
paths.addResource(staticResPost);
try {
paths.addResource(staticResPost);
Assert.fail("must throw exception");
} catch (ServiceCombException e) {
Assert.assertEquals("operation with url /static, method POST is duplicated.", e.getMessage());
}
}
use of org.apache.servicecomb.common.rest.definition.RestOperationMeta in project incubator-servicecomb-java-chassis by apache.
the class TestMicroservicePaths method testSortPath.
@Test
public void testSortPath() {
// only test base rule
// completely rule test by TestRestOperationComparator
RestOperationMeta dynamicResLessStatic = UnitTestRestUtils.createRestOperationMeta("POST", "/a/{id}");
RestOperationMeta dynamicResMoreStatic = UnitTestRestUtils.createRestOperationMeta("POST", "/abc/{id}");
MicroservicePaths paths = new MicroservicePaths();
paths.addResource(dynamicResLessStatic);
paths.addResource(dynamicResMoreStatic);
paths.sortPath();
Assert.assertSame(dynamicResMoreStatic, paths.getDynamicPathOperationList().get(0));
Assert.assertSame(dynamicResLessStatic, paths.getDynamicPathOperationList().get(1));
}
use of org.apache.servicecomb.common.rest.definition.RestOperationMeta in project incubator-servicecomb-java-chassis by apache.
the class TestMicroservicePaths method testAddResourceStaticAddToGroup.
@Test
public void testAddResourceStaticAddToGroup() {
RestOperationMeta staticResPost = UnitTestRestUtils.createRestOperationMeta("POST", "/static");
RestOperationMeta staticResGet = UnitTestRestUtils.createRestOperationMeta("GET", "/static");
MicroservicePaths paths = new MicroservicePaths();
paths.addResource(staticResPost);
paths.addResource(staticResGet);
Assert.assertSame(staticResPost, paths.getStaticPathOperationMap().get("/static").findValue("POST"));
Assert.assertSame(staticResGet, paths.getStaticPathOperationMap().get("/static").findValue("GET"));
}
Aggregations