Search in sources :

Example 1 with QueryProcessor

use of org.apache.servicecomb.common.rest.codec.param.QueryProcessorCreator.QueryProcessor in project incubator-servicecomb-java-chassis by apache.

the class TestQueryProcessor method createProcessor.

private ParamValueProcessor createProcessor(String name, Class<?> type, String defaultValue, boolean required, String collectionFormat) {
    JavaType javaType = TypeFactory.defaultInstance().constructType(type);
    QueryParameter queryParameter = new QueryParameter();
    queryParameter.name(name).required(required).collectionFormat(collectionFormat).setDefaultValue(defaultValue);
    if (javaType.isContainerType()) {
        queryParameter.type(ArrayProperty.TYPE);
    }
    return new QueryProcessor(queryParameter, javaType);
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) QueryParameter(io.swagger.models.parameters.QueryParameter) QueryProcessor(org.apache.servicecomb.common.rest.codec.param.QueryProcessorCreator.QueryProcessor)

Example 2 with QueryProcessor

use of org.apache.servicecomb.common.rest.codec.param.QueryProcessorCreator.QueryProcessor in project java-chassis by ServiceComb.

the class TestQueryProcessor method createProcessor.

private ParamValueProcessor createProcessor(String name, Class<?> type, String defaultValue, boolean required, String collectionFormat) {
    JavaType javaType = TypeFactory.defaultInstance().constructType(type);
    QueryParameter queryParameter = new QueryParameter();
    queryParameter.name(name).required(required).collectionFormat(collectionFormat).setDefaultValue(defaultValue);
    if (javaType.isContainerType()) {
        queryParameter.type(ArrayProperty.TYPE);
    }
    return new QueryProcessor(queryParameter, javaType);
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) QueryParameter(io.swagger.models.parameters.QueryParameter) QueryProcessor(org.apache.servicecomb.common.rest.codec.param.QueryProcessorCreator.QueryProcessor)

Example 3 with QueryProcessor

use of org.apache.servicecomb.common.rest.codec.param.QueryProcessorCreator.QueryProcessor in project java-chassis by ServiceComb.

the class QueryCodecTestBase method should_decode.

private void should_decode(HttpServletRequest request, Object decodedValue) {
    Class<?> targetType = decodedValue == null ? Object.class : decodedValue.getClass();
    QueryParameter queryParameter = new QueryParameter();
    queryParameter.setCollectionFormat(codec.getCodecName());
    if (targetType.isArray()) {
        queryParameter.setType(ArrayProperty.TYPE);
    }
    QueryProcessor queryProcessor = new QueryProcessor(queryParameter, TypeFactory.defaultInstance().constructType(targetType));
    Object values = codec.decode(queryProcessor, request);
    assertThat(values).isEqualTo(decodedValue);
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) QueryProcessor(org.apache.servicecomb.common.rest.codec.param.QueryProcessorCreator.QueryProcessor)

Example 4 with QueryProcessor

use of org.apache.servicecomb.common.rest.codec.param.QueryProcessorCreator.QueryProcessor in project incubator-servicecomb-java-chassis by apache.

the class QueryCodecTestBase method should_decode.

private void should_decode(HttpServletRequest request, Object decodedValue) {
    Class<?> targetType = decodedValue == null ? Object.class : decodedValue.getClass();
    QueryParameter queryParameter = new QueryParameter();
    queryParameter.setCollectionFormat(codec.getCodecName());
    if (targetType.isArray()) {
        queryParameter.setType(ArrayProperty.TYPE);
    }
    QueryProcessor queryProcessor = new QueryProcessor(queryParameter, TypeFactory.defaultInstance().constructType(targetType));
    Object values = codec.decode(queryProcessor, request);
    assertThat(values).isEqualTo(decodedValue);
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) QueryProcessor(org.apache.servicecomb.common.rest.codec.param.QueryProcessorCreator.QueryProcessor)

Aggregations

QueryParameter (io.swagger.models.parameters.QueryParameter)4 QueryProcessor (org.apache.servicecomb.common.rest.codec.param.QueryProcessorCreator.QueryProcessor)4 JavaType (com.fasterxml.jackson.databind.JavaType)2