use of io.servicecomb.swagger.generator.core.CompositeSwaggerGeneratorContext in project java-chassis by ServiceComb.
the class TestProducerSchemaFactory method init.
@BeforeClass
public static void init() {
ProducerResponseMapperFactory responseMapperFactory = new ProducerResponseMapperFactory();
responseMapperFactory.setMapperList(Arrays.asList(new ProducerResponseSame()));
ProducerArgumentsMapperFactory producerArgsMapperFactory = new ProducerArgumentsMapperFactory();
MicroserviceMetaManager microserviceMetaManager = new MicroserviceMetaManager();
SchemaLoader schemaLoader = new SchemaLoader() {
@Override
public void putSelfBasePathIfAbsent(String microserviceName, String basePath) {
}
};
CompositeSwaggerGeneratorContext compositeSwaggerGeneratorContext = new CompositeSwaggerGeneratorContext();
ReflectUtils.setField(producerSchemaFactory, "producerArgsMapperFactory", producerArgsMapperFactory);
ReflectUtils.setField(producerSchemaFactory, "responseMapperFactory", responseMapperFactory);
ReflectUtils.setField(producerSchemaFactory, "microserviceMetaManager", microserviceMetaManager);
ReflectUtils.setField(producerSchemaFactory, "schemaLoader", schemaLoader);
ReflectUtils.setField(producerSchemaFactory, "compositeSwaggerGeneratorContext", compositeSwaggerGeneratorContext);
BeanUtils.setContext(Mockito.mock(ApplicationContext.class));
UnitTestMeta.init();
schemaMeta = producerSchemaFactory.getOrCreateProducerSchema("app:ms", "schema", TestProducerSchemaFactoryImpl.class, new TestProducerSchemaFactoryImpl());
}
use of io.servicecomb.swagger.generator.core.CompositeSwaggerGeneratorContext in project java-chassis by ServiceComb.
the class TestJaxrs method testComposite.
@Test
public void testComposite() {
CompositeSwaggerGeneratorContext composite = new CompositeSwaggerGeneratorContext();
SwaggerGeneratorContext context = composite.selectContext(Echo.class);
Assert.assertEquals(JaxrsSwaggerGeneratorContext.class, context.getClass());
}
use of io.servicecomb.swagger.generator.core.CompositeSwaggerGeneratorContext in project java-chassis by ServiceComb.
the class TestSpringmvc method testComposite.
@Test
public void testComposite() {
CompositeSwaggerGeneratorContext composite = new CompositeSwaggerGeneratorContext();
SwaggerGeneratorContext context = composite.selectContext(Echo.class);
Assert.assertEquals(SpringmvcSwaggerGeneratorContext.class, context.getClass());
}
use of io.servicecomb.swagger.generator.core.CompositeSwaggerGeneratorContext 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);
}
Aggregations