Search in sources :

Example 1 with PojoOneArg

use of org.apache.servicecomb.swagger.invocation.schemas.PojoOneArg in project java-chassis by ServiceComb.

the class TestPojoOneArg method should_mapper_swagger_wrapped_body_field_to_producer_enum.

@Test
public void should_mapper_swagger_wrapped_body_field_to_producer_enum() {
    SwaggerProducer swaggerProducer = new SwaggerEnvironment().createProducer(new PojoOneArg(), null);
    SwaggerProducerOperation swaggerProducerOperation = swaggerProducer.findOperation("enumBody");
    Assert.assertEquals("color", swaggerProducerOperation.getSwaggerOperation().getOperation().getParameters().get(0).getName());
    ProducerArgumentsMapper mapper = swaggerProducerOperation.getArgumentsMapper();
    SwaggerInvocation invocation = new SwaggerInvocation();
    Map<String, Object> swaggerArguments = new HashMap<>();
    Map<String, Object> arguments = new HashMap<>();
    arguments.put("color", "BLUE");
    swaggerArguments.put("color", arguments);
    Map<String, Object> result = mapper.swaggerArgumentToInvocationArguments(invocation, swaggerArguments);
    Assert.assertEquals(1, result.size());
    Assert.assertSame(Color.BLUE, result.get("color"));
}
Also used : SwaggerInvocation(org.apache.servicecomb.swagger.invocation.SwaggerInvocation) SwaggerProducer(org.apache.servicecomb.swagger.engine.SwaggerProducer) HashMap(java.util.HashMap) SwaggerProducerOperation(org.apache.servicecomb.swagger.engine.SwaggerProducerOperation) SwaggerEnvironment(org.apache.servicecomb.swagger.engine.SwaggerEnvironment) PojoOneArg(org.apache.servicecomb.swagger.invocation.schemas.PojoOneArg) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 SwaggerEnvironment (org.apache.servicecomb.swagger.engine.SwaggerEnvironment)1 SwaggerProducer (org.apache.servicecomb.swagger.engine.SwaggerProducer)1 SwaggerProducerOperation (org.apache.servicecomb.swagger.engine.SwaggerProducerOperation)1 SwaggerInvocation (org.apache.servicecomb.swagger.invocation.SwaggerInvocation)1 PojoOneArg (org.apache.servicecomb.swagger.invocation.schemas.PojoOneArg)1 Test (org.junit.Test)1