Search in sources :

Example 16 with RestOperationMeta

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());
}
Also used : RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) OperationMeta(org.apache.servicecomb.core.definition.OperationMeta) RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta)

Example 17 with RestOperationMeta

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));
}
Also used : RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) Test(org.junit.Test)

Example 18 with RestOperationMeta

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());
    }
}
Also used : RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) ServiceCombException(org.apache.servicecomb.foundation.common.exceptions.ServiceCombException) Test(org.junit.Test)

Example 19 with RestOperationMeta

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));
}
Also used : RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) Test(org.junit.Test)

Example 20 with RestOperationMeta

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"));
}
Also used : RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) Test(org.junit.Test)

Aggregations

RestOperationMeta (org.apache.servicecomb.common.rest.definition.RestOperationMeta)24 Test (org.junit.Test)14 OperationMeta (org.apache.servicecomb.core.definition.OperationMeta)11 Endpoint (org.apache.servicecomb.core.Endpoint)4 Invocation (org.apache.servicecomb.core.Invocation)4 HttpClientRequest (io.vertx.core.http.HttpClientRequest)3 ProduceProcessor (org.apache.servicecomb.common.rest.codec.produce.ProduceProcessor)3 URLPathBuilder (org.apache.servicecomb.common.rest.definition.path.URLPathBuilder)3 AsyncResponse (org.apache.servicecomb.swagger.invocation.AsyncResponse)3 HttpClientResponse (io.vertx.core.http.HttpClientResponse)2 RestClientRequestImpl (org.apache.servicecomb.common.rest.codec.param.RestClientRequestImpl)2 IpPort (org.apache.servicecomb.foundation.common.net.IpPort)2 URIEndpointObject (org.apache.servicecomb.foundation.common.net.URIEndpointObject)2 Context (io.vertx.core.Context)1 Buffer (io.vertx.core.buffer.Buffer)1 HttpClient (io.vertx.core.http.HttpClient)1 HttpMethod (io.vertx.core.http.HttpMethod)1 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 ArrayList (java.util.ArrayList)1