One more fix to interceptor
This commit is contained in:
parent
8759cdae00
commit
4eb9508e28
|
@ -122,5 +122,52 @@ public class SearchPreferHandlingInterceptorJpaTest extends BaseResourceProvider
|
||||||
assertEquals(ourServerBase + "/Patient?_format=json&_pretty=true&identifier=BLAH", outcome.getLink(Constants.LINK_SELF).getUrl());
|
assertEquals(ourServerBase + "/Patient?_format=json&_pretty=true&identifier=BLAH", outcome.getLink(Constants.LINK_SELF).getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchWithChain_Invalid() {
|
||||||
|
try {
|
||||||
|
myClient
|
||||||
|
.search()
|
||||||
|
.forResource(Patient.class)
|
||||||
|
.where(new StringClientParam("foo.bar").matches().value("bar"))
|
||||||
|
.withAdditionalHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_HANDLING + "=" + Constants.HEADER_PREFER_HANDLING_STRICT)
|
||||||
|
.prettyPrint()
|
||||||
|
.returnBundle(Bundle.class)
|
||||||
|
.encodedJson()
|
||||||
|
.execute();
|
||||||
|
fail();
|
||||||
|
} catch (InvalidRequestException e) {
|
||||||
|
assertThat(e.getMessage(), containsString("Unknown search parameter \"foo\" for resource type \"Patient\". Valid search parameters for this search are: [_id, _language, active, address, address-city, address-country, address-postalcode, address-state, address-use, birthdate, death-date, deceased, email, family, gender, general-practitioner, given, identifier, language, link, name, organization, phone, phonetic, telecom]"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchWithChain_Valid() {
|
||||||
|
Bundle outcome = myClient
|
||||||
|
.search()
|
||||||
|
.forResource(Patient.class)
|
||||||
|
.where(new StringClientParam("organization.name").matches().value("bar"))
|
||||||
|
.withAdditionalHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_HANDLING + "=" + Constants.HEADER_PREFER_HANDLING_STRICT)
|
||||||
|
.prettyPrint()
|
||||||
|
.returnBundle(Bundle.class)
|
||||||
|
.encodedJson()
|
||||||
|
.execute();
|
||||||
|
assertEquals(0, outcome.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchWithModifier_Valid() {
|
||||||
|
Bundle outcome = myClient
|
||||||
|
.search()
|
||||||
|
.forResource(Patient.class)
|
||||||
|
.where(new StringClientParam("name").matchesExactly().value("bar"))
|
||||||
|
.withAdditionalHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_HANDLING + "=" + Constants.HEADER_PREFER_HANDLING_STRICT)
|
||||||
|
.prettyPrint()
|
||||||
|
.returnBundle(Bundle.class)
|
||||||
|
.encodedJson()
|
||||||
|
.execute();
|
||||||
|
assertEquals(0, outcome.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,15 @@ public class SearchPreferHandlingInterceptor {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Strip modifiers and chains
|
||||||
|
for (int i = 0; i < paramName.length(); i++) {
|
||||||
|
char nextChar = paramName.charAt(i);
|
||||||
|
if (nextChar == '.' || nextChar == ':') {
|
||||||
|
paramName = paramName.substring(0, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RuntimeSearchParam activeSearchParam = searchParamRetriever.getActiveSearchParam(resourceName, paramName);
|
RuntimeSearchParam activeSearchParam = searchParamRetriever.getActiveSearchParam(resourceName, paramName);
|
||||||
if (activeSearchParam == null) {
|
if (activeSearchParam == null) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue