Merge pull request #538 from CarthageKing/feature-parameterutil-fix

Ensure ParameterUtil.splitParameterString correctly parses consecutive unescaped delimiter
This commit is contained in:
James Agnew 2017-01-29 17:53:39 -05:00 committed by GitHub
commit 788792e004
2 changed files with 27 additions and 1 deletions

View File

@ -108,8 +108,10 @@ public class ParameterUtil {
} else {
if (b.length() > 0) {
retVal.add(b.toString());
b.setLength(0);
} else {
retVal.add(null);
}
b.setLength(0);
}
}
} else {

View File

@ -59,6 +59,30 @@ public class QuantityParamTest {
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
public static void afterClassClearContext() {