Add test case for invalid query parameters in read operation
This commit is contained in:
parent
0021561fb1
commit
ce012ff7cf
|
@ -4,6 +4,7 @@ import static org.hamcrest.Matchers.stringContainsInOrder;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -64,6 +65,131 @@ public class ReadDstu3Test {
|
|||
"</Patient>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidQueryParamsInRead() throws Exception {
|
||||
CloseableHttpResponse status;
|
||||
HttpGet httpGet;
|
||||
|
||||
httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/2?_contained=both&_format=xml&_pretty=true");
|
||||
status = ourClient.execute(httpGet);
|
||||
try (InputStream inputStream = status.getEntity().getContent()) {
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
|
||||
String responseContent = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
|
||||
assertThat(responseContent, stringContainsInOrder(
|
||||
"<OperationOutcome xmlns=\"http://hl7.org/fhir\">",
|
||||
" <issue>",
|
||||
" <severity value=\"error\"/>",
|
||||
" <code value=\"processing\"/>",
|
||||
" <diagnostics value=\"Invalid query parameter(s) for this request: "[_contained]"\"/>",
|
||||
" </issue>",
|
||||
"</OperationOutcome>"
|
||||
));
|
||||
}
|
||||
|
||||
httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/2?_containedType=contained&_format=xml&_pretty=true");
|
||||
status = ourClient.execute(httpGet);
|
||||
try (InputStream inputStream = status.getEntity().getContent()) {
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
|
||||
String responseContent = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
|
||||
assertThat(responseContent, stringContainsInOrder(
|
||||
"<OperationOutcome xmlns=\"http://hl7.org/fhir\">",
|
||||
" <issue>",
|
||||
" <severity value=\"error\"/>",
|
||||
" <code value=\"processing\"/>",
|
||||
" <diagnostics value=\"Invalid query parameter(s) for this request: "[_containedType]"\"/>",
|
||||
" </issue>",
|
||||
"</OperationOutcome>"
|
||||
));
|
||||
}
|
||||
|
||||
httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/2?_count=10&_format=xml&_pretty=true");
|
||||
status = ourClient.execute(httpGet);
|
||||
try (InputStream inputStream = status.getEntity().getContent()) {
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
|
||||
String responseContent = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
|
||||
assertThat(responseContent, stringContainsInOrder(
|
||||
"<OperationOutcome xmlns=\"http://hl7.org/fhir\">",
|
||||
" <issue>",
|
||||
" <severity value=\"error\"/>",
|
||||
" <code value=\"processing\"/>",
|
||||
" <diagnostics value=\"Invalid query parameter(s) for this request: "[_count]"\"/>",
|
||||
" </issue>",
|
||||
"</OperationOutcome>"
|
||||
));
|
||||
}
|
||||
|
||||
httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/2?_include=Patient:organization&_format=xml&_pretty=true");
|
||||
status = ourClient.execute(httpGet);
|
||||
try (InputStream inputStream = status.getEntity().getContent()) {
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
|
||||
String responseContent = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
|
||||
assertThat(responseContent, stringContainsInOrder(
|
||||
"<OperationOutcome xmlns=\"http://hl7.org/fhir\">",
|
||||
" <issue>",
|
||||
" <severity value=\"error\"/>",
|
||||
" <code value=\"processing\"/>",
|
||||
" <diagnostics value=\"Invalid query parameter(s) for this request: "[_include]"\"/>",
|
||||
" </issue>",
|
||||
"</OperationOutcome>"
|
||||
));
|
||||
}
|
||||
|
||||
httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/2?_revinclude=Provenance:target&_format=xml&_pretty=true");
|
||||
status = ourClient.execute(httpGet);
|
||||
try (InputStream inputStream = status.getEntity().getContent()) {
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
|
||||
String responseContent = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
|
||||
assertThat(responseContent, stringContainsInOrder(
|
||||
"<OperationOutcome xmlns=\"http://hl7.org/fhir\">",
|
||||
" <issue>",
|
||||
" <severity value=\"error\"/>",
|
||||
" <code value=\"processing\"/>",
|
||||
" <diagnostics value=\"Invalid query parameter(s) for this request: "[_revinclude]"\"/>",
|
||||
" </issue>",
|
||||
"</OperationOutcome>"
|
||||
));
|
||||
}
|
||||
|
||||
httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/2?_sort=family&_format=xml&_pretty=true");
|
||||
status = ourClient.execute(httpGet);
|
||||
try (InputStream inputStream = status.getEntity().getContent()) {
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
|
||||
String responseContent = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
|
||||
assertThat(responseContent, stringContainsInOrder(
|
||||
"<OperationOutcome xmlns=\"http://hl7.org/fhir\">",
|
||||
" <issue>",
|
||||
" <severity value=\"error\"/>",
|
||||
" <code value=\"processing\"/>",
|
||||
" <diagnostics value=\"Invalid query parameter(s) for this request: "[_sort]"\"/>",
|
||||
" </issue>",
|
||||
"</OperationOutcome>"
|
||||
));
|
||||
}
|
||||
|
||||
httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/2?_total=accurate&_format=xml&_pretty=true");
|
||||
status = ourClient.execute(httpGet);
|
||||
try (InputStream inputStream = status.getEntity().getContent()) {
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
|
||||
String responseContent = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
|
||||
assertThat(responseContent, stringContainsInOrder(
|
||||
"<OperationOutcome xmlns=\"http://hl7.org/fhir\">",
|
||||
" <issue>",
|
||||
" <severity value=\"error\"/>",
|
||||
" <code value=\"processing\"/>",
|
||||
" <diagnostics value=\"Invalid query parameter(s) for this request: "[_total]"\"/>",
|
||||
" </issue>",
|
||||
"</OperationOutcome>"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIfModifiedSince() throws Exception {
|
||||
|
||||
|
|
Loading…
Reference in New Issue