use of io.servicecomb.common.rest.definition.path.QueryVarParamWriter in project java-chassis by ServiceComb.
the class TestPath method testQueryVarParamWriter.
@Test
public void testQueryVarParamWriter() throws Exception {
boolean status = true;
new MockUp<RestParam>() {
@Mock
public String getParamName() {
return "queryVar";
}
};
new MockUp<QueryVarParamWriter>() {
@Mock
protected Object getParamValue(Object[] args) {
return args[0];
}
};
Parameter parameter = new QueryParameter();
QueryVarParamWriter writer = new QueryVarParamWriter('&', new RestParam(0, parameter, String.class));
try {
verify(writer, "T", "&queryVar=T");
verify(writer, null, "&");
verify(writer, new String[] { "a", "b" }, "&queryVar=a&queryVar=b");
verify(writer, new String[] { "a", null, "b" }, "&queryVar=a&queryVar=&queryVar=b");
verify(writer, Arrays.asList("Lars", "Simon"), "&queryVar=Lars&queryVar=Simon");
verify(writer, "测试", "&queryVar=%E6%B5%8B%E8%AF%95");
verify(writer, "a b", "&queryVar=a+b");
verify(writer, "a+b", "&queryVar=a%2Bb");
} catch (Exception e) {
status = false;
}
Assert.assertTrue(status);
}
Aggregations