Search in sources :

Example 41 with SchemaMeta

use of org.apache.servicecomb.core.definition.SchemaMeta in project incubator-servicecomb-java-chassis by apache.

the class SchemaListenerManager method notifySchemaListener.

public void notifySchemaListener(MicroserviceMeta... microserviceMetas) {
    List<SchemaMeta> schemaMetaList = new ArrayList<>();
    for (MicroserviceMeta microserviceMeta : microserviceMetas) {
        schemaMetaList.addAll(microserviceMeta.getSchemaMetas());
    }
    notifySchemaListener(schemaMetaList.toArray(new SchemaMeta[schemaMetaList.size()]));
}
Also used : SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) ArrayList(java.util.ArrayList) MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta)

Example 42 with SchemaMeta

use of org.apache.servicecomb.core.definition.SchemaMeta in project incubator-servicecomb-java-chassis by apache.

the class MockUtil method mockRequestMeta.

public void mockRequestMeta() {
    new MockUp<RequestMeta>() {

        @Mock
        public OperationMeta getOperationMeta() throws Exception {
            OperationMeta om = new OperationMeta();
            om.init(new SchemaMeta(null, new MicroserviceMeta("test"), null), this.getClass().getMethods()[0], "path", "get", null);
            return om;
        }
    };
}
Also used : SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta) MockUp(mockit.MockUp) OperationMeta(org.apache.servicecomb.core.definition.OperationMeta) RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta)

Example 43 with SchemaMeta

use of org.apache.servicecomb.core.definition.SchemaMeta in project incubator-servicecomb-java-chassis by apache.

the class QpsControllerManagerTest method getMockOperationMeta.

public static OperationMeta getMockOperationMeta(String microserviceName, String schemaId, String operationId) {
    OperationMeta operationMeta = Mockito.mock(OperationMeta.class);
    SchemaMeta schemaMeta = Mockito.mock(SchemaMeta.class);
    Mockito.when(operationMeta.getSchemaMeta()).thenReturn(schemaMeta);
    Mockito.when(operationMeta.getSchemaQualifiedName()).thenReturn(schemaId + QpsControllerManager.SEPARATOR + operationId);
    Mockito.when(operationMeta.getMicroserviceQualifiedName()).thenReturn(microserviceName + QpsControllerManager.SEPARATOR + schemaId + QpsControllerManager.SEPARATOR + operationId);
    Mockito.when(operationMeta.getMicroserviceName()).thenReturn(microserviceName);
    Mockito.when(schemaMeta.getSchemaId()).thenReturn(schemaId);
    return operationMeta;
}
Also used : SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) OperationMeta(org.apache.servicecomb.core.definition.OperationMeta)

Example 44 with SchemaMeta

use of org.apache.servicecomb.core.definition.SchemaMeta in project incubator-servicecomb-java-chassis by apache.

the class QpsControllerManagerTest method testMock.

@Test
public void testMock() {
    Invocation invocation = getMockInvocation("service", "schema", "oper");
    OperationMeta operationMeta = invocation.getOperationMeta();
    SchemaMeta schemaMeta = operationMeta.getSchemaMeta();
    Assert.assertEquals("service", operationMeta.getMicroserviceName());
    Assert.assertEquals("service.schema.oper", operationMeta.getMicroserviceQualifiedName());
    Assert.assertEquals("schema.oper", operationMeta.getSchemaQualifiedName());
    Assert.assertEquals("schema", schemaMeta.getSchemaId());
}
Also used : Invocation(org.apache.servicecomb.core.Invocation) SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) OperationMeta(org.apache.servicecomb.core.definition.OperationMeta) Test(org.junit.Test)

Example 45 with SchemaMeta

use of org.apache.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.

the class TestApiParam method pojoSimple.

@Test
public void pojoSimple() {
    SchemaMeta schemaMeta = microserviceMeta.findSchemaMeta("apiParamPojo");
    OperationMeta operationMeta = schemaMeta.findOperation("simple");
    parameter = operationMeta.getSwaggerOperation().getParameters().get(0);
    ModelImpl model = SwaggerUtils.getModelImpl(schemaMeta.getSwagger(), (BodyParameter) parameter);
    Assert.assertEquals("desc of simple param", model.getProperties().get("input").getDescription());
}
Also used : SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) OperationMeta(org.apache.servicecomb.core.definition.OperationMeta) ModelImpl(io.swagger.models.ModelImpl) Test(org.junit.Test)

Aggregations

SchemaMeta (org.apache.servicecomb.core.definition.SchemaMeta)58 OperationMeta (org.apache.servicecomb.core.definition.OperationMeta)28 MicroserviceMeta (org.apache.servicecomb.core.definition.MicroserviceMeta)25 Test (org.junit.Test)24 Invocation (org.apache.servicecomb.core.Invocation)13 Swagger (io.swagger.models.Swagger)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)6 Executor (java.util.concurrent.Executor)5 InvocationRuntimeType (org.apache.servicecomb.core.definition.InvocationRuntimeType)5 ReferenceConfig (org.apache.servicecomb.core.provider.consumer.ReferenceConfig)5 MicroserviceInstance (org.apache.servicecomb.registry.api.registry.MicroserviceInstance)5 SwaggerProducerOperation (org.apache.servicecomb.swagger.engine.SwaggerProducerOperation)5 MockUp (mockit.MockUp)4 NonSwaggerInvocation (org.apache.servicecomb.core.NonSwaggerInvocation)4 Transport (org.apache.servicecomb.core.Transport)4 TransportManager (org.apache.servicecomb.core.transport.TransportManager)4 InstanceCacheManager (org.apache.servicecomb.registry.cache.InstanceCacheManager)4 DiscoveryTreeNode (org.apache.servicecomb.registry.discovery.DiscoveryTreeNode)4 ServiceRegistry (org.apache.servicecomb.serviceregistry.ServiceRegistry)4