Search in sources :

Example 1 with ConsumerResponseSame

use of io.servicecomb.swagger.invocation.response.consumer.ConsumerResponseSame in project java-chassis by ServiceComb.

the class TestConsumerSchemaFactory method init.

@BeforeClass
public static void init() {
    ReflectUtils.setField(RegistryClientFactory.class, null, "registryClient", registryClient);
    SchemaListenerManager schemaListenerManager = new SchemaListenerManager();
    schemaListenerManager.setSchemaListenerList(Arrays.asList(schemaListener));
    ConsumerResponseMapperFactory responseMapperFactory = new ConsumerResponseMapperFactory();
    responseMapperFactory.setMapperList(Arrays.asList(new ConsumerResponseSame()));
    ConsumerArgumentsMapperFactory consumerArgsMapperFactory = new ConsumerArgumentsMapperFactory();
    MicroserviceMetaManager microserviceMetaManager = new MicroserviceMetaManager();
    SchemaLoader schemaLoader = new SchemaLoader();
    CompositeSwaggerGeneratorContext compositeSwaggerGeneratorContext = new CompositeSwaggerGeneratorContext();
    ReflectUtils.setField(consumerSchemaFactory, "schemaListenerManager", schemaListenerManager);
    ReflectUtils.setField(consumerSchemaFactory, "consumerArgsMapperFactory", consumerArgsMapperFactory);
    ReflectUtils.setField(consumerSchemaFactory, "responseMapperFactory", responseMapperFactory);
    ReflectUtils.setField(consumerSchemaFactory, "microserviceMetaManager", microserviceMetaManager);
    ReflectUtils.setField(consumerSchemaFactory, "schemaLoader", schemaLoader);
    ReflectUtils.setField(consumerSchemaFactory, "compositeSwaggerGeneratorContext", compositeSwaggerGeneratorContext);
    SchemaMeta schemaMeta = new UnitTestMeta().getOrCreateSchemaMeta(TestConsumerSchemaFactoryImpl.class);
    String content = UnitTestSwaggerUtils.pretty(schemaMeta.getSwagger());
    Mockito.when(registryClient.getMicroserviceId("app", "ms", "latest")).thenReturn("0");
    Mockito.when(registryClient.getSchema("0", "schema")).thenReturn(content);
    Microservice microservice = new Microservice();
    microservice.setAppId("app");
    microservice.setServiceId("0");
    microservice.addSchema("schema", content);
    Mockito.when(registryClient.getMicroservice("0")).thenReturn(microservice);
}
Also used : ConsumerResponseSame(io.servicecomb.swagger.invocation.response.consumer.ConsumerResponseSame) MicroserviceMetaManager(io.servicecomb.core.definition.MicroserviceMetaManager) SchemaLoader(io.servicecomb.core.definition.loader.SchemaLoader) Microservice(io.servicecomb.serviceregistry.api.registry.Microservice) UnitTestMeta(io.servicecomb.core.unittest.UnitTestMeta) CompositeSwaggerGeneratorContext(io.servicecomb.swagger.generator.core.CompositeSwaggerGeneratorContext) SchemaMeta(io.servicecomb.core.definition.SchemaMeta) SchemaListenerManager(io.servicecomb.core.definition.loader.SchemaListenerManager) ConsumerResponseMapperFactory(io.servicecomb.swagger.invocation.response.consumer.ConsumerResponseMapperFactory) ConsumerArgumentsMapperFactory(io.servicecomb.swagger.invocation.arguments.consumer.ConsumerArgumentsMapperFactory) BeforeClass(org.junit.BeforeClass)

Aggregations

MicroserviceMetaManager (io.servicecomb.core.definition.MicroserviceMetaManager)1 SchemaMeta (io.servicecomb.core.definition.SchemaMeta)1 SchemaListenerManager (io.servicecomb.core.definition.loader.SchemaListenerManager)1 SchemaLoader (io.servicecomb.core.definition.loader.SchemaLoader)1 UnitTestMeta (io.servicecomb.core.unittest.UnitTestMeta)1 Microservice (io.servicecomb.serviceregistry.api.registry.Microservice)1 CompositeSwaggerGeneratorContext (io.servicecomb.swagger.generator.core.CompositeSwaggerGeneratorContext)1 ConsumerArgumentsMapperFactory (io.servicecomb.swagger.invocation.arguments.consumer.ConsumerArgumentsMapperFactory)1 ConsumerResponseMapperFactory (io.servicecomb.swagger.invocation.response.consumer.ConsumerResponseMapperFactory)1 ConsumerResponseSame (io.servicecomb.swagger.invocation.response.consumer.ConsumerResponseSame)1 BeforeClass (org.junit.BeforeClass)1