Place empty values when splitting a parameter with a certain char and
here are at least two unescaped and consecutive variants of the given char in the string. This ensures that for example a QuantityParam with a param value of "5.5||mg" the "mg" will not be treated as the 'system' but be treated correctly as the 'unit' of the parameter object.
This commit is contained in:
parent
fe24841350
commit
a6a1416888
|
@ -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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue