Some test fixes

This commit is contained in:
James Agnew 2019-09-24 15:28:14 -04:00
parent bd763d728b
commit 7b363c2c5c
2 changed files with 24 additions and 4 deletions

View File

@ -22,6 +22,7 @@ package ca.uhn.fhir.rest.param;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.util.CoverageIgnore; import ca.uhn.fhir.util.CoverageIgnore;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
@ -115,14 +116,21 @@ public class ReferenceParam extends BaseParam /*implements IQueryParameterType*/
if (nextIdx != -1) { if (nextIdx != -1) {
myChain = q.substring(nextIdx + 1); myChain = q.substring(nextIdx + 1);
myResourceType = q.substring(1, nextIdx); myResourceType = q.substring(1, nextIdx);
myValue = theValue;
myIdPart = theValue;
} else { } else {
myChain = null; myChain = null;
myResourceType = q.substring(1); myResourceType = q.substring(1);
myValue = theValue;
myIdPart = theValue;
} }
myValue = theValue;
myIdPart = theValue;
IdDt id = new IdDt(theValue);
if (!id.hasBaseUrl() && id.hasIdPart() && id.hasResourceType()) {
if (id.getResourceType().equals(myResourceType)) {
myIdPart = id.getIdPart();
}
}
} else if (q.startsWith(".")) { } else if (q.startsWith(".")) {
myChain = q.substring(1); myChain = q.substring(1);
myResourceType = null; myResourceType = null;

View File

@ -124,6 +124,18 @@ public class ReferenceParamTest {
} }
@Test
public void testDuplicatedTypeAndValueType() {
ReferenceParam rp = new ReferenceParam();
rp.setValueAsQueryToken(ourCtx, null, ":Patient", "Patient/123");
assertEquals("Patient", rp.getResourceType());
assertEquals("123", rp.getIdPart());
assertEquals("Patient/123", rp.getValue());
assertEquals(null, rp.getQueryParameterQualifier());
}
// TODO: verify this behavior is correct. Same case as testWithResourceTypeAsQualifier_RelativeUrl() // TODO: verify this behavior is correct. Same case as testWithResourceTypeAsQualifier_RelativeUrl()
@Test @Test
public void testWithResourceTypeAsQualifier_AbsoluteUrl() { public void testWithResourceTypeAsQualifier_AbsoluteUrl() {