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"));
}
use of org.apache.servicecomb.common.rest.definition.RestOperationMeta in project incubator-servicecomb-java-chassis by apache.
the class TestOperationLocator method testLocateDynamicFound.
@Test
public void testLocateDynamicFound() {
RestOperationMeta rom = addRestOperationMeta("GET", "/dynamic/{id}");
locator.locate("ms", "/dynamic/1/", "GET", paths);
Assert.assertSame(rom, locator.getOperation());
Assert.assertEquals("1", locator.getPathVarMap().get("id"));
}
Aggregations