use of org.apache.servicecomb.swagger.engine.SwaggerConsumer in project incubator-servicecomb-java-chassis by apache.
the class TestInvoker method testConsumerInterfaceAsSchemaId.
@Test
public void testConsumerInterfaceAsSchemaId(@Injectable ConsumerProviderManager manager, @Injectable ReferenceConfig config, @Injectable MicroserviceMeta microserviceMeta, @Injectable ConsumerSchemaFactory factory) {
new Expectations() {
{
manager.getReferenceConfig("test");
result = config;
config.getMicroserviceMeta();
result = microserviceMeta;
microserviceMeta.findSchemaMeta(IPerson.class);
result = null;
microserviceMeta.ensureFindSchemaMeta(IPerson.class.getName());
}
};
CseContext.getInstance().setConsumerProviderManager(manager);
CseContext.getInstance().setConsumerSchemaFactory(factory);
CseContext.getInstance().setSwaggerEnvironment(new BootstrapNormal().boot());
Invoker invoker = new Invoker("test", null, IPerson.class);
invoker.prepare();
SwaggerConsumer swaggerConsumer = Deencapsulation.getField(invoker, "swaggerConsumer");
Assert.assertEquals(IPerson.class, swaggerConsumer.getConsumerIntf());
}
use of org.apache.servicecomb.swagger.engine.SwaggerConsumer in project incubator-servicecomb-java-chassis by apache.
the class TestInvoker method testNormalSchemaId.
@Test
public void testNormalSchemaId(@Injectable ConsumerProviderManager manager, @Injectable ReferenceConfig config, @Injectable MicroserviceMeta microserviceMeta, @Injectable ConsumerSchemaFactory factory) {
new Expectations() {
{
manager.getReferenceConfig("test");
result = config;
config.getMicroserviceMeta();
result = microserviceMeta;
microserviceMeta.ensureFindSchemaMeta("schemaId");
}
};
CseContext.getInstance().setConsumerProviderManager(manager);
CseContext.getInstance().setConsumerSchemaFactory(factory);
CseContext.getInstance().setSwaggerEnvironment(new BootstrapNormal().boot());
Invoker invoker = new Invoker("test", "schemaId", IPerson.class);
invoker.prepare();
SwaggerConsumer swaggerConsumer = Deencapsulation.getField(invoker, "swaggerConsumer");
Assert.assertEquals(IPerson.class, swaggerConsumer.getConsumerIntf());
}
use of org.apache.servicecomb.swagger.engine.SwaggerConsumer in project incubator-servicecomb-java-chassis by apache.
the class TestInvoker method testFindSchemaByConsumerInterface.
@Test
public void testFindSchemaByConsumerInterface(@Injectable ConsumerProviderManager manager, @Injectable ReferenceConfig config, @Injectable MicroserviceMeta microserviceMeta, @Injectable ConsumerSchemaFactory factory) {
new Expectations() {
{
manager.getReferenceConfig("test");
result = config;
config.getMicroserviceMeta();
result = microserviceMeta;
microserviceMeta.findSchemaMeta(IPerson.class);
}
};
CseContext.getInstance().setConsumerProviderManager(manager);
CseContext.getInstance().setConsumerSchemaFactory(factory);
CseContext.getInstance().setSwaggerEnvironment(new BootstrapNormal().boot());
Invoker invoker = new Invoker("test", null, IPerson.class);
invoker.prepare();
SwaggerConsumer swaggerConsumer = Deencapsulation.getField(invoker, "swaggerConsumer");
Assert.assertEquals(IPerson.class, swaggerConsumer.getConsumerIntf());
}
Aggregations