Merge pull request #538 from CarthageKing/feature-parameterutil-fix
Ensure ParameterUtil.splitParameterString correctly parses consecutive unescaped delimiter
This commit is contained in:
commit
788792e004
|
@ -108,8 +108,10 @@ public class ParameterUtil {
|
||||||
} else {
|
} else {
|
||||||
if (b.length() > 0) {
|
if (b.length() > 0) {
|
||||||
retVal.add(b.toString());
|
retVal.add(b.toString());
|
||||||
b.setLength(0);
|
} else {
|
||||||
|
retVal.add(null);
|
||||||
}
|
}
|
||||||
|
b.setLength(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -59,6 +59,30 @@ public class QuantityParamTest {
|
||||||
assertEquals("5.4||", p.getValueAsQueryToken(ourCtx));
|
assertEquals("5.4||", p.getValueAsQueryToken(ourCtx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNoSystem() {
|
||||||
|
// http://hl7.org/fhir/2017Jan/search.html#quantity
|
||||||
|
// sample url: [baseurl]/Observation?value-quantity=5.5||mg
|
||||||
|
String query = "5.5||mg";
|
||||||
|
QuantityParam param = new QuantityParam();
|
||||||
|
param.setValueAsQueryToken(null, "value-quantity", null, query);
|
||||||
|
// Check parts. The 'mg' part should be put in the units not the system
|
||||||
|
// System.out.println(param);
|
||||||
|
assertEquals(null, param.getPrefix());
|
||||||
|
assertEquals("5.5", param.getValue().toPlainString());
|
||||||
|
assertEquals(null, param.getSystem());
|
||||||
|
assertEquals("mg", param.getUnits());
|
||||||
|
|
||||||
|
// Make sure we don't break on this one...
|
||||||
|
query = "5.5| |mg";
|
||||||
|
param = new QuantityParam();
|
||||||
|
param.setValueAsQueryToken(null, "value-quantity", null, query);
|
||||||
|
// System.out.println(param);
|
||||||
|
assertEquals(null, param.getPrefix());
|
||||||
|
assertEquals("5.5", param.getValue().toPlainString());
|
||||||
|
assertEquals(null, param.getSystem());
|
||||||
|
assertEquals("mg", param.getUnits());
|
||||||
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterClassClearContext() {
|
public static void afterClassClearContext() {
|
||||||
|
|
Loading…
Reference in New Issue