use of io.swagger.models.parameters.QueryParameter in project incubator-servicecomb-java-chassis by apache.
the class TestQueryProcessorCreator method testCreateNullAsEmpty.
@SuppressWarnings("UnusedAssignment")
@Test
public void testCreateNullAsEmpty() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
ArchaiusUtils.setProperty("servicecomb.rest.parameter.query.emptyAsNull", "true");
ParamValueProcessorCreator creator = ParamValueProcessorCreatorManager.INSTANCE.findValue(QueryProcessorCreator.PARAMTYPE);
Parameter parameter = new QueryParameter();
parameter.setName("query");
ParamValueProcessor processor = creator.create(parameter, String.class);
Assert.assertEquals(QueryProcessor.class, processor.getClass());
Mockito.when(request.getParameter("query")).thenReturn("Hello");
String result = (String) processor.getValue(request);
Assert.assertEquals("Hello", result);
Mockito.when(request.getParameter("query")).thenReturn("");
result = (String) processor.getValue(request);
Assert.assertEquals(null, result);
Mockito.when(request.getParameter("query")).thenReturn(null);
result = (String) processor.convertValue(null, TypeFactory.defaultInstance().constructType(String.class));
result = (String) processor.getValue(request);
Assert.assertEquals(null, result);
}
use of io.swagger.models.parameters.QueryParameter in project incubator-servicecomb-java-chassis by apache.
the class QueryVarParamWriterTest method beforeClass.
@BeforeClass
public static void beforeClass() {
QueryParameter parameter = new QueryParameter();
parameter.setName("q");
parameter.setCollectionFormat("csv");
queryVarParamWriterCsv = new QueryVarParamWriter(new RestParam(parameter, String[].class));
parameter = new QueryParameter();
parameter.setName("q");
parameter.setCollectionFormat("multi");
queryVarParamWriterMulti = new QueryVarParamWriter(new RestParam(parameter, String[].class));
parameter = new QueryParameter();
parameter.setName("q");
queryVarParamWriterDefault = new QueryVarParamWriter(new RestParam(parameter, String[].class));
}
Aggregations