Bump version dependencies and return 200 for conditional delete with no matches

This commit is contained in:
jamesagnew 2016-07-25 08:46:02 -04:00
parent fd4979f56a
commit 41b58108f2
15 changed files with 174 additions and 128 deletions

1
.gitignore vendored
View File

@ -123,6 +123,7 @@ tmp/
*~.nib *~.nib
local.properties local.properties
.loadpath .loadpath
*.hprof
# External tool builders # External tool builders
.externalToolBuilders/ .externalToolBuilders/

View File

@ -3,6 +3,7 @@ package example;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
@ -234,7 +235,7 @@ public class GenericClientExample {
} }
{ {
// START SNIPPET: delete // START SNIPPET: delete
BaseOperationOutcome resp = client.delete().resourceById(new IdDt("Patient", "1234")).execute(); IBaseOperationOutcome resp = client.delete().resourceById(new IdDt("Patient", "1234")).execute();
// outcome may be null if the server didn't return one // outcome may be null if the server didn't return one
if (resp != null) { if (resp != null) {

View File

@ -901,7 +901,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
} }
private class DeleteInternal extends BaseClientExecutable<IDeleteTyped, BaseOperationOutcome> implements IDelete, IDeleteTyped, IDeleteWithQuery, IDeleteWithQueryTyped { private class DeleteInternal extends BaseClientExecutable<IDeleteTyped, IBaseOperationOutcome> implements IDelete, IDeleteTyped, IDeleteWithQuery, IDeleteWithQueryTyped {
private CriterionList myCriterionList; private CriterionList myCriterionList;
private IIdType myId; private IIdType myId;
@ -915,7 +915,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
} }
@Override @Override
public BaseOperationOutcome execute() { public IBaseOperationOutcome execute() {
HttpDeleteClientInvocation invocation; HttpDeleteClientInvocation invocation;
if (myId != null) { if (myId != null) {
invocation = DeleteMethodBinding.createDeleteInvocation(getFhirContext(), myId); invocation = DeleteMethodBinding.createDeleteInvocation(getFhirContext(), myId);
@ -1627,19 +1627,19 @@ public class GenericClient extends BaseClient implements IGenericClient {
} }
private final class OperationOutcomeResponseHandler implements IClientResponseHandler<BaseOperationOutcome> { private final class OperationOutcomeResponseHandler implements IClientResponseHandler<IBaseOperationOutcome> {
@Override @Override
public BaseOperationOutcome invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws BaseServerResponseException { public IBaseOperationOutcome invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws BaseServerResponseException {
EncodingEnum respType = EncodingEnum.forContentType(theResponseMimeType); EncodingEnum respType = EncodingEnum.forContentType(theResponseMimeType);
if (respType == null) { if (respType == null) {
return null; return null;
} }
IParser parser = respType.newParser(myContext); IParser parser = respType.newParser(myContext);
BaseOperationOutcome retVal; IBaseOperationOutcome retVal;
try { try {
// TODO: handle if something else than OO comes back // TODO: handle if something else than OO comes back
retVal = (BaseOperationOutcome) parser.parseResource(theResponseReader); retVal = (IBaseOperationOutcome) parser.parseResource(theResponseReader);
} catch (DataFormatException e) { } catch (DataFormatException e) {
ourLog.warn("Failed to parse OperationOutcome response", e); ourLog.warn("Failed to parse OperationOutcome response", e);
return null; return null;

View File

@ -1,28 +1,8 @@
package ca.uhn.fhir.rest.gclient; package ca.uhn.fhir.rest.gclient;
/* import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2016 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome; public interface IDeleteTyped extends IClientExecutable<IDeleteTyped, IBaseOperationOutcome> {
public interface IDeleteTyped extends IClientExecutable<IDeleteTyped, BaseOperationOutcome> {
// nothing for now // nothing for now

View File

@ -77,6 +77,7 @@ ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.multipleParamsWithSameNameOneIsMissi
ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.unableToDeleteNotFound=Unable to find resource matching URL "{0}". Deletion failed. ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.unableToDeleteNotFound=Unable to find resource matching URL "{0}". Deletion failed.
ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.successfulCreate=Successfully created resource "{0}" in {1}ms ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.successfulCreate=Successfully created resource "{0}" in {1}ms
ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.successfulUpdate=Successfully updated resource "{0}" in {1}ms ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.successfulUpdate=Successfully updated resource "{0}" in {1}ms
ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.successfulDeletes=Successfully deleted {0} resource(s) in {1}ms
ca.uhn.fhir.jpa.dao.SearchBuilder.invalidQuantityPrefix=Unable to handle quantity prefix "{0}" for value: {1} ca.uhn.fhir.jpa.dao.SearchBuilder.invalidQuantityPrefix=Unable to handle quantity prefix "{0}" for value: {1}
ca.uhn.fhir.jpa.dao.SearchBuilder.invalidNumberPrefix=Unable to handle number prefix "{0}" for value: {1} ca.uhn.fhir.jpa.dao.SearchBuilder.invalidNumberPrefix=Unable to handle number prefix "{0}" for value: {1}

View File

@ -32,6 +32,7 @@ import org.hl7.fhir.dstu3.model.Parameters;
import org.hl7.fhir.dstu3.model.Patient; import org.hl7.fhir.dstu3.model.Patient;
import org.hl7.fhir.dstu3.model.Resource; import org.hl7.fhir.dstu3.model.Resource;
import org.hl7.fhir.dstu3.model.StringType; import org.hl7.fhir.dstu3.model.StringType;
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
@ -190,7 +191,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
@Test @Test
public void testDeletePatient() { public void testDeletePatient() {
when(mock.delete(idCaptor.capture(), conditionalCaptor.capture())).thenReturn(new MethodOutcome()); when(mock.delete(idCaptor.capture(), conditionalCaptor.capture())).thenReturn(new MethodOutcome());
final BaseOperationOutcome results = client.delete().resourceById("Patient", "1").execute(); final IBaseOperationOutcome results = client.delete().resourceById("Patient", "1").execute();
assertEquals("1", idCaptor.getValue().getIdPart()); assertEquals("1", idCaptor.getValue().getIdPart());
} }

View File

@ -22,6 +22,7 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.hamcrest.BaseMatcher; import org.hamcrest.BaseMatcher;
import org.hamcrest.Description; import org.hamcrest.Description;
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@ -189,7 +190,7 @@ public class AbstractJaxRsResourceProviderTest {
@Test @Test
public void testDeletePatient() { public void testDeletePatient() {
when(mock.delete(idCaptor.capture(), conditionalCaptor.capture())).thenReturn(new MethodOutcome()); when(mock.delete(idCaptor.capture(), conditionalCaptor.capture())).thenReturn(new MethodOutcome());
final BaseOperationOutcome results = client.delete().resourceById("Patient", "1").execute(); final IBaseOperationOutcome results = client.delete().resourceById("Patient", "1").execute();
assertEquals("1", idCaptor.getValue().getIdPart()); assertEquals("1", idCaptor.getValue().getIdPart());
} }

View File

@ -88,6 +88,7 @@ import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails; import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
import ca.uhn.fhir.util.FhirTerser; import ca.uhn.fhir.util.FhirTerser;
import ca.uhn.fhir.util.ObjectUtil; import ca.uhn.fhir.util.ObjectUtil;
import ca.uhn.fhir.util.OperationOutcomeUtil;
import ca.uhn.fhir.util.ResourceReferenceInfo; import ca.uhn.fhir.util.ResourceReferenceInfo;
@Transactional(propagation = Propagation.REQUIRED) @Transactional(propagation = Propagation.REQUIRED)
@ -291,12 +292,26 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
validateDeleteConflictsEmptyOrThrowException(deleteConflicts); validateDeleteConflictsEmptyOrThrowException(deleteConflicts);
IBaseOperationOutcome oo;
if (deletedResources.isEmpty()) { if (deletedResources.isEmpty()) {
throw new ResourceNotFoundException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "unableToDeleteNotFound", theUrl)); oo = OperationOutcomeUtil.newInstance(getContext());
String message = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "unableToDeleteNotFound", theUrl);
String severity = "warning";
String code = "not-found";
OperationOutcomeUtil.addIssue(getContext(), oo, severity, message, null, code);
} else {
oo = OperationOutcomeUtil.newInstance(getContext());
String message = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "successfulDeletes", theUrl, deletedResources.size(), w.getMillis());
String severity = "information";
String code = "informational";
OperationOutcomeUtil.addIssue(getContext(), oo, severity, message, null, code);
} }
ourLog.info("Processed delete on {} (matched {} resource(s)) in {}ms", new Object[] { theUrl, deletedResources.size(), w.getMillisAndRestart() }); ourLog.info("Processed delete on {} (matched {} resource(s)) in {}ms", new Object[] { theUrl, deletedResources.size(), w.getMillis() });
return new DaoMethodOutcome(); DaoMethodOutcome retVal = new DaoMethodOutcome();
retVal.setOperationOutcome(oo);
return retVal;
} }
@PostConstruct @PostConstruct

View File

@ -414,7 +414,7 @@ public class FhirSystemDaoDstu3 extends BaseHapiFhirSystemDao<Bundle, Meta> {
deletedResources.add(deleted.getIdDt().toUnqualifiedVersionless().getValueAsString()); deletedResources.add(deleted.getIdDt().toUnqualifiedVersionless().getValueAsString());
} }
if (allDeleted.isEmpty()) { if (allDeleted.isEmpty()) {
status = Constants.STATUS_HTTP_404_NOT_FOUND; status = Constants.STATUS_HTTP_204_NO_CONTENT;
} }
} }

View File

@ -21,6 +21,7 @@ import static org.mockito.Mockito.verify;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
@ -86,7 +87,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
*/ */
@Test @Test
public void testContainedArePreservedForBug410() throws IOException { public void testContainedArePreservedForBug410() throws IOException {
String input = IOUtils.toString(getClass().getResourceAsStream("/bug-410-bundle.xml")); String input = IOUtils.toString(getClass().getResourceAsStream("/bug-410-bundle.xml"), StandardCharsets.UTF_8);
Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input);
Bundle output = mySystemDao.transaction(mySrd, bundle); Bundle output = mySystemDao.transaction(mySrd, bundle);
@ -100,7 +101,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
@Test @Test
public void testTransactionFromBundle2() throws Exception { public void testTransactionFromBundle2() throws Exception {
String input = IOUtils.toString(getClass().getResourceAsStream("/transaction-bundle.xml")); String input = IOUtils.toString(getClass().getResourceAsStream("/transaction-bundle.xml"), StandardCharsets.UTF_8);
Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input);
Bundle response = mySystemDao.transaction(mySrd, bundle); Bundle response = mySystemDao.transaction(mySrd, bundle);
@ -384,7 +385,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
patient.addIdentifier().setSystem("http://www.ghh.org/identifiers").setValue("condreftestpatid1"); patient.addIdentifier().setSystem("http://www.ghh.org/identifiers").setValue("condreftestpatid1");
myPatientDao.create(patient, mySrd); myPatientDao.create(patient, mySrd);
String input = IOUtils.toString(getClass().getResourceAsStream("/simone-conditional-url.xml")); String input = IOUtils.toString(getClass().getResourceAsStream("/simone-conditional-url.xml"), StandardCharsets.UTF_8);
Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input);
Bundle response = mySystemDao.transaction(mySrd, bundle); Bundle response = mySystemDao.transaction(mySrd, bundle);
@ -404,7 +405,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
patient.addIdentifier().setSystem("http://www.ghh.org/identifiers").setValue("condreftestpatid1"); patient.addIdentifier().setSystem("http://www.ghh.org/identifiers").setValue("condreftestpatid1");
myPatientDao.create(patient, mySrd); myPatientDao.create(patient, mySrd);
String input = IOUtils.toString(getClass().getResourceAsStream("/simone-conditional-url.xml")); String input = IOUtils.toString(getClass().getResourceAsStream("/simone-conditional-url.xml"), StandardCharsets.UTF_8);
Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input);
try { try {
@ -420,7 +421,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
public void testTransactionWithInlineMatchUrlNoMatches() throws Exception { public void testTransactionWithInlineMatchUrlNoMatches() throws Exception {
myDaoConfig.setAllowInlineMatchUrlReferences(true); myDaoConfig.setAllowInlineMatchUrlReferences(true);
String input = IOUtils.toString(getClass().getResourceAsStream("/simone-conditional-url.xml")); String input = IOUtils.toString(getClass().getResourceAsStream("/simone-conditional-url.xml"), StandardCharsets.UTF_8);
Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input);
try { try {
@ -803,7 +804,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
@Test @Test
public void testTransactionCreateWithPutUsingUrl2() throws Exception { public void testTransactionCreateWithPutUsingUrl2() throws Exception {
String req = IOUtils.toString(FhirSystemDaoDstu3Test.class.getResourceAsStream("/bundle-dstu3.xml")); String req = IOUtils.toString(FhirSystemDaoDstu3Test.class.getResourceAsStream("/bundle-dstu3.xml"), StandardCharsets.UTF_8);
Bundle request = myFhirCtx.newXmlParser().parseResource(Bundle.class, req); Bundle request = myFhirCtx.newXmlParser().parseResource(Bundle.class, req);
mySystemDao.transaction(mySrd, request); mySystemDao.transaction(mySrd, request);
} }
@ -1128,7 +1129,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
// try { // try {
Bundle resp = mySystemDao.transaction(mySrd, request); Bundle resp = mySystemDao.transaction(mySrd, request);
assertEquals(1, resp.getEntry().size()); assertEquals(1, resp.getEntry().size());
assertEquals("404 Not Found", resp.getEntry().get(0).getResponse().getStatus()); assertEquals("204 No Content", resp.getEntry().get(0).getResponse().getStatus());
// fail(); // fail();
// } catch (ResourceNotFoundException e) { // } catch (ResourceNotFoundException e) {
@ -1183,7 +1184,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
public void testTransactionFromBundle() throws Exception { public void testTransactionFromBundle() throws Exception {
InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/transaction_link_patient_eve.xml"); InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/transaction_link_patient_eve.xml");
String bundleStr = IOUtils.toString(bundleRes); String bundleStr = IOUtils.toString(bundleRes, StandardCharsets.UTF_8);
Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, bundleStr); Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, bundleStr);
Bundle resp = mySystemDao.transaction(mySrd, bundle); Bundle resp = mySystemDao.transaction(mySrd, bundle);
@ -1206,7 +1207,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
public void testTransactionWithBundledValidationSourceAndTarget() throws Exception { public void testTransactionWithBundledValidationSourceAndTarget() throws Exception {
InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/questionnaire-sdc-profile-example-ussg-fht.xml"); InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/questionnaire-sdc-profile-example-ussg-fht.xml");
String bundleStr = IOUtils.toString(bundleRes); String bundleStr = IOUtils.toString(bundleRes, StandardCharsets.UTF_8);
Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, bundleStr); Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, bundleStr);
Bundle resp = mySystemDao.transaction(mySrd, bundle); Bundle resp = mySystemDao.transaction(mySrd, bundle);
@ -1242,7 +1243,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
@Test @Test
public void testTransactionFromBundle6() throws Exception { public void testTransactionFromBundle6() throws Exception {
InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/simone_bundle3.xml"); InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/simone_bundle3.xml");
String bundle = IOUtils.toString(bundleRes); String bundle = IOUtils.toString(bundleRes, StandardCharsets.UTF_8);
Bundle output = mySystemDao.transaction(mySrd, myFhirCtx.newXmlParser().parseResource(Bundle.class, bundle)); Bundle output = mySystemDao.transaction(mySrd, myFhirCtx.newXmlParser().parseResource(Bundle.class, bundle));
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output));
} }
@ -1251,7 +1252,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
public void testTransactionFromBundleJosh() throws Exception { public void testTransactionFromBundleJosh() throws Exception {
InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/josh-bundle.json"); InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/josh-bundle.json");
String bundleStr = IOUtils.toString(bundleRes); String bundleStr = IOUtils.toString(bundleRes, StandardCharsets.UTF_8);
Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, bundleStr); Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, bundleStr);
Bundle resp = mySystemDao.transaction(mySrd, bundle); Bundle resp = mySystemDao.transaction(mySrd, bundle);
@ -1313,7 +1314,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
assertEquals("201 Created", resp.getEntry().get(2).getResponse().getStatus()); assertEquals("201 Created", resp.getEntry().get(2).getResponse().getStatus());
assertThat(resp.getEntry().get(2).getResponse().getLocation(), startsWith("Patient/")); assertThat(resp.getEntry().get(2).getResponse().getLocation(), startsWith("Patient/"));
if (pass == 0) { if (pass == 0) {
assertEquals("404 Not Found", resp.getEntry().get(3).getResponse().getStatus()); assertEquals("204 No Content", resp.getEntry().get(3).getResponse().getStatus());
} else { } else {
assertEquals("204 No Content", resp.getEntry().get(3).getResponse().getStatus()); assertEquals("204 No Content", resp.getEntry().get(3).getResponse().getStatus());
} }

View File

@ -24,6 +24,7 @@ import java.io.InputStreamReader;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.Socket; import java.net.Socket;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -195,7 +196,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
public void testBundleCreate() throws Exception { public void testBundleCreate() throws Exception {
IGenericClient client = ourClient; IGenericClient client = ourClient;
String resBody = IOUtils.toString(ResourceProviderDstu2Test.class.getResource("/document-father.json")); String resBody = IOUtils.toString(ResourceProviderDstu2Test.class.getResource("/document-father.json"), StandardCharsets.UTF_8);
IIdType id = client.create().resource(resBody).execute().getId(); IIdType id = client.create().resource(resBody).execute().getId();
ourLog.info("Created: {}", id); ourLog.info("Created: {}", id);
@ -209,7 +210,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
public void testBundleCreateWithTypeTransaction() throws Exception { public void testBundleCreateWithTypeTransaction() throws Exception {
IGenericClient client = ourClient; IGenericClient client = ourClient;
String resBody = IOUtils.toString(ResourceProviderDstu2Test.class.getResource("/document-father.json")); String resBody = IOUtils.toString(ResourceProviderDstu2Test.class.getResource("/document-father.json"), StandardCharsets.UTF_8);
resBody = resBody.replace("\"type\": \"document\"", "\"type\": \"transaction\""); resBody = resBody.replace("\"type\": \"document\"", "\"type\": \"transaction\"");
try { try {
client.create().resource(resBody).execute().getId(); client.create().resource(resBody).execute().getId();
@ -477,7 +478,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
assertEquals(201, response.getStatusLine().getStatusCode()); assertEquals(201, response.getStatusLine().getStatusCode());
String respString = IOUtils.toString(response.getEntity().getContent()); String respString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(response.toString()); ourLog.info(response.toString());
ourLog.info(respString); ourLog.info(respString);
assertThat(respString, containsString("<OperationOutcome xmlns=\"http://hl7.org/fhir\">")); assertThat(respString, containsString("<OperationOutcome xmlns=\"http://hl7.org/fhir\">"));
@ -496,7 +497,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String responseString = IOUtils.toString(response.getEntity().getContent()); String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(responseString); ourLog.info(responseString);
assertEquals(400, response.getStatusLine().getStatusCode()); assertEquals(400, response.getStatusLine().getStatusCode());
OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString); OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString);
@ -617,7 +618,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
HttpDelete delete = new HttpDelete(ourServerBase + "/Patient"); HttpDelete delete = new HttpDelete(ourServerBase + "/Patient");
CloseableHttpResponse response = ourHttpClient.execute(delete); CloseableHttpResponse response = ourHttpClient.execute(delete);
try { try {
String responseString = IOUtils.toString(response.getEntity().getContent()); String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(responseString); ourLog.info(responseString);
assertEquals(400, response.getStatusLine().getStatusCode()); assertEquals(400, response.getStatusLine().getStatusCode());
assertThat(responseString, containsString("Can not perform delete, no ID provided")); assertThat(responseString, containsString("Can not perform delete, no ID provided"));
@ -650,7 +651,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
HttpDelete delete = new HttpDelete(ourServerBase + "/Patient?name=" + methodName); HttpDelete delete = new HttpDelete(ourServerBase + "/Patient?name=" + methodName);
response = ourHttpClient.execute(delete); response = ourHttpClient.execute(delete);
try { try {
assertEquals(204, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
} finally { } finally {
response.close(); response.close();
} }
@ -765,7 +766,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
int initialSize = client.search().forResource(DocumentManifest.class).execute().size(); int initialSize = client.search().forResource(DocumentManifest.class).execute().size();
String resBody = IOUtils.toString(ResourceProviderDstu2Test.class.getResource("/documentmanifest.json")); String resBody = IOUtils.toString(ResourceProviderDstu2Test.class.getResource("/documentmanifest.json"), StandardCharsets.UTF_8);
client.create().resource(resBody).execute(); client.create().resource(resBody).execute();
int newSize = client.search().forResource(DocumentManifest.class).execute().size(); int newSize = client.search().forResource(DocumentManifest.class).execute().size();
@ -1157,7 +1158,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
CloseableHttpResponse response = ourHttpClient.execute(get); CloseableHttpResponse response = ourHttpClient.execute(get);
try { try {
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
String output = IOUtils.toString(response.getEntity().getContent()); String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
IOUtils.closeQuietly(response.getEntity().getContent()); IOUtils.closeQuietly(response.getEntity().getContent());
ourLog.info(output); ourLog.info(output);
List<IdDt> ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseBundle(output)); List<IdDt> ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseBundle(output));
@ -1171,7 +1172,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
response = ourHttpClient.execute(get); response = ourHttpClient.execute(get);
try { try {
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
String output = IOUtils.toString(response.getEntity().getContent()); String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
IOUtils.closeQuietly(response.getEntity().getContent()); IOUtils.closeQuietly(response.getEntity().getContent());
ourLog.info(output); ourLog.info(output);
List<IdDt> ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseBundle(output)); List<IdDt> ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseBundle(output));
@ -1185,7 +1186,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
response = ourHttpClient.execute(get); response = ourHttpClient.execute(get);
try { try {
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
String output = IOUtils.toString(response.getEntity().getContent()); String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
IOUtils.closeQuietly(response.getEntity().getContent()); IOUtils.closeQuietly(response.getEntity().getContent());
ourLog.info(output); ourLog.info(output);
List<IdDt> ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseBundle(output)); List<IdDt> ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseBundle(output));
@ -1199,7 +1200,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
response = ourHttpClient.execute(get); response = ourHttpClient.execute(get);
try { try {
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
String output = IOUtils.toString(response.getEntity().getContent()); String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
IOUtils.closeQuietly(response.getEntity().getContent()); IOUtils.closeQuietly(response.getEntity().getContent());
ourLog.info(output); ourLog.info(output);
List<IdDt> ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseBundle(output)); List<IdDt> ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseBundle(output));
@ -1223,7 +1224,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
CloseableHttpResponse response = ourHttpClient.execute(get); CloseableHttpResponse response = ourHttpClient.execute(get);
try { try {
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
String output = IOUtils.toString(response.getEntity().getContent()); String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
IOUtils.closeQuietly(response.getEntity().getContent()); IOUtils.closeQuietly(response.getEntity().getContent());
ourLog.info(output); ourLog.info(output);
assertThat(output, containsString("<parameter><name value=\"Patient\"/><valueInteger value=\"")); assertThat(output, containsString("<parameter><name value=\"Patient\"/><valueInteger value=\""));
@ -1265,7 +1266,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
int initialSize = client.search().forResource(ImagingStudy.class).execute().size(); int initialSize = client.search().forResource(ImagingStudy.class).execute().size();
String resBody = IOUtils.toString(ResourceProviderDstu2Test.class.getResource("/imagingstudy.json")); String resBody = IOUtils.toString(ResourceProviderDstu2Test.class.getResource("/imagingstudy.json"), StandardCharsets.UTF_8);
client.create().resource(resBody).execute(); client.create().resource(resBody).execute();
int newSize = client.search().forResource(ImagingStudy.class).execute().size(); int newSize = client.search().forResource(ImagingStudy.class).execute().size();
@ -1279,7 +1280,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
HttpGet get = new HttpGet(ourServerBase + "/metadata"); HttpGet get = new HttpGet(ourServerBase + "/metadata");
CloseableHttpResponse response = ourHttpClient.execute(get); CloseableHttpResponse response = ourHttpClient.execute(get);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
assertThat(resp, stringContainsInOrder("THIS IS THE DESC")); assertThat(resp, stringContainsInOrder("THIS IS THE DESC"));
@ -1334,7 +1335,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
post.setEntity(new StringEntity(input, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); post.setEntity(new StringEntity(input, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String output = IOUtils.toString(response.getEntity().getContent()); String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(output); ourLog.info(output);
assertEquals(400, response.getStatusLine().getStatusCode()); assertEquals(400, response.getStatusLine().getStatusCode());
assertThat(output, containsString("Input contains no parameter with name 'meta'")); assertThat(output, containsString("Input contains no parameter with name 'meta'"));
@ -1346,7 +1347,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
post.setEntity(new StringEntity(input, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); post.setEntity(new StringEntity(input, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
response = ourHttpClient.execute(post); response = ourHttpClient.execute(post);
try { try {
String output = IOUtils.toString(response.getEntity().getContent()); String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(output); ourLog.info(output);
assertEquals(400, response.getStatusLine().getStatusCode()); assertEquals(400, response.getStatusLine().getStatusCode());
assertThat(output, containsString("Input contains no parameter with name 'meta'")); assertThat(output, containsString("Input contains no parameter with name 'meta'"));
@ -1445,7 +1446,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
HttpGet read = new HttpGet(ourServerBase + "/Patient?_format=json"); HttpGet read = new HttpGet(ourServerBase + "/Patient?_format=json");
CloseableHttpResponse response = ourHttpClient.execute(read); CloseableHttpResponse response = ourHttpClient.execute(read);
try { try {
String text = IOUtils.toString(response.getEntity().getContent()); String text = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(text); ourLog.info(text);
assertEquals(Constants.STATUS_HTTP_200_OK, response.getStatusLine().getStatusCode()); assertEquals(Constants.STATUS_HTTP_200_OK, response.getStatusLine().getStatusCode());
assertThat(text, not(containsString("\"text\",\"type\""))); assertThat(text, not(containsString("\"text\",\"type\"")));
@ -1658,7 +1659,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
int matches; int matches;
HttpGet get = new HttpGet(ourServerBase + search); HttpGet get = new HttpGet(ourServerBase + search);
CloseableHttpResponse response = ourHttpClient.execute(get); CloseableHttpResponse response = ourHttpClient.execute(get);
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
IOUtils.closeQuietly(response.getEntity().getContent()); IOUtils.closeQuietly(response.getEntity().getContent());
ourLog.info(resp); ourLog.info(resp);
ca.uhn.fhir.model.dstu2.resource.Bundle bundle = myFhirCtx.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, resp); ca.uhn.fhir.model.dstu2.resource.Bundle bundle = myFhirCtx.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, resp);
@ -2031,7 +2032,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String responseString = IOUtils.toString(response.getEntity().getContent()); String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(responseString); ourLog.info(responseString);
assertEquals(400, response.getStatusLine().getStatusCode()); assertEquals(400, response.getStatusLine().getStatusCode());
OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString); OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString);
@ -2135,7 +2136,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
response = ourHttpClient.execute(put); response = ourHttpClient.execute(put);
try { try {
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
String responseString = IOUtils.toString(response.getEntity().getContent()); String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
IOUtils.closeQuietly(response.getEntity().getContent()); IOUtils.closeQuietly(response.getEntity().getContent());
Patient respPt = myFhirCtx.newXmlParser().parseResource(Patient.class, responseString); Patient respPt = myFhirCtx.newXmlParser().parseResource(Patient.class, responseString);
@ -2184,7 +2185,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
assertThat(resp, not(containsString("Resource has no id"))); assertThat(resp, not(containsString("Resource has no id")));
@ -2211,7 +2212,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
post.setEntity(new StringEntity(contents, ContentType.create(Constants.CT_FHIR_JSON, "UTF-8"))); post.setEntity(new StringEntity(contents, ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(201, response.getStatusLine().getStatusCode()); assertEquals(201, response.getStatusLine().getStatusCode());
} finally { } finally {
@ -2230,7 +2231,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
response = ourHttpClient.execute(post); response = ourHttpClient.execute(post);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
assertThat(resp, not(containsString("Resource has no id"))); assertThat(resp, not(containsString("Resource has no id")));
@ -2260,7 +2261,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
} finally { } finally {
@ -2287,7 +2288,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
} finally { } finally {
@ -2305,7 +2306,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
HttpGet get = new HttpGet(ourServerBase + "/ValueSet/" + vsid.getIdPart() + "/$expand"); HttpGet get = new HttpGet(ourServerBase + "/ValueSet/" + vsid.getIdPart() + "/$expand");
CloseableHttpResponse response = ourHttpClient.execute(get); CloseableHttpResponse response = ourHttpClient.execute(get);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
// @formatter:off // @formatter:off
@ -2337,7 +2338,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
get = new HttpGet(ourServerBase + "/ValueSet/" + vsid.getIdPart() + "/$expand?filter=systolic"); get = new HttpGet(ourServerBase + "/ValueSet/" + vsid.getIdPart() + "/$expand?filter=systolic");
response = ourHttpClient.execute(get); response = ourHttpClient.execute(get);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
//@formatter:off //@formatter:off
@ -2357,7 +2358,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
get = new HttpGet(ourServerBase + "/ValueSet/" + vsid.getIdPart() + "/$expand?filter=11378"); get = new HttpGet(ourServerBase + "/ValueSet/" + vsid.getIdPart() + "/$expand?filter=11378");
response = ourHttpClient.execute(get); response = ourHttpClient.execute(get);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
//@formatter:off //@formatter:off

View File

@ -33,8 +33,6 @@ import ca.uhn.fhir.util.TestUtil;
public class AuthorizationInterceptorResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { public class AuthorizationInterceptorResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(AuthorizationInterceptorResourceProviderDstu3Test.class);
@AfterClass @AfterClass
public static void afterClassClearContext() { public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest(); TestUtil.clearAllStaticFieldsForUnitTest();
@ -160,7 +158,7 @@ public class AuthorizationInterceptorResourceProviderDstu3Test extends BaseResou
HttpDelete delete = new HttpDelete(ourServerBase + "/Patient?name=" + methodName); HttpDelete delete = new HttpDelete(ourServerBase + "/Patient?name=" + methodName);
response = ourHttpClient.execute(delete); response = ourHttpClient.execute(delete);
try { try {
assertEquals(204, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
} finally { } finally {
response.close(); response.close();
} }

View File

@ -26,6 +26,7 @@ import java.net.InetSocketAddress;
import java.net.Socket; import java.net.Socket;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -88,6 +89,7 @@ import org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus;
import org.hl7.fhir.dstu3.model.TemporalPrecisionEnum; import org.hl7.fhir.dstu3.model.TemporalPrecisionEnum;
import org.hl7.fhir.dstu3.model.UnsignedIntType; import org.hl7.fhir.dstu3.model.UnsignedIntType;
import org.hl7.fhir.dstu3.model.ValueSet; import org.hl7.fhir.dstu3.model.ValueSet;
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.AfterClass; import org.junit.AfterClass;
@ -214,7 +216,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
HttpGet get = new HttpGet(ourServerBase + "/AllergyIntolerance?_has=Provenance:target:userID=12345"); HttpGet get = new HttpGet(ourServerBase + "/AllergyIntolerance?_has=Provenance:target:userID=12345");
CloseableHttpResponse response = ourHttpClient.execute(get); CloseableHttpResponse response = ourHttpClient.execute(get);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertThat(resp, containsString("Invalid _has parameter syntax: _has")); assertThat(resp, containsString("Invalid _has parameter syntax: _has"));
} finally { } finally {
@ -229,7 +231,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
CloseableHttpResponse response = ourHttpClient.execute(get); CloseableHttpResponse response = ourHttpClient.execute(get);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp); Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp);
ids = toUnqualifiedVersionlessIdValues(bundle); ids = toUnqualifiedVersionlessIdValues(bundle);
@ -245,7 +247,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
CloseableHttpResponse response = ourHttpClient.execute(get); CloseableHttpResponse response = ourHttpClient.execute(get);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp); Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp);
ids = toUnqualifiedIdValues(bundle); ids = toUnqualifiedIdValues(bundle);
@ -260,7 +262,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
*/ */
@Test @Test
public void testCreateBundle() throws IOException { public void testCreateBundle() throws IOException {
String input = IOUtils.toString(getClass().getResourceAsStream("/bryn-bundle.json")); String input = IOUtils.toString(getClass().getResourceAsStream("/bryn-bundle.json"), StandardCharsets.UTF_8);
Validate.notNull(input); Validate.notNull(input);
ourClient.create().resource(input).execute().getResource(); ourClient.create().resource(input).execute().getResource();
} }
@ -280,7 +282,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
CloseableHttpResponse resp = ourHttpClient.execute(get); CloseableHttpResponse resp = ourHttpClient.execute(get);
try { try {
assertEquals(200, resp.getStatusLine().getStatusCode()); assertEquals(200, resp.getStatusLine().getStatusCode());
String output = IOUtils.toString(resp.getEntity().getContent()); String output = IOUtils.toString(resp.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(output); ourLog.info(output);
Bundle b = myFhirCtx.newXmlParser().parseResource(Bundle.class, output); Bundle b = myFhirCtx.newXmlParser().parseResource(Bundle.class, output);
@ -327,7 +329,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
public void testBundleCreate() throws Exception { public void testBundleCreate() throws Exception {
IGenericClient client = ourClient; IGenericClient client = ourClient;
String resBody = IOUtils.toString(ResourceProviderDstu3Test.class.getResource("/document-father-dstu3.json")); String resBody = IOUtils.toString(ResourceProviderDstu3Test.class.getResource("/document-father-dstu3.json"), StandardCharsets.UTF_8);
IIdType id = client.create().resource(resBody).execute().getId(); IIdType id = client.create().resource(resBody).execute().getId();
ourLog.info("Created: {}", id); ourLog.info("Created: {}", id);
@ -341,7 +343,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
public void testBundleCreateWithTypeTransaction() throws Exception { public void testBundleCreateWithTypeTransaction() throws Exception {
IGenericClient client = ourClient; IGenericClient client = ourClient;
String resBody = IOUtils.toString(ResourceProviderDstu3Test.class.getResource("/document-father-dstu3.json")); String resBody = IOUtils.toString(ResourceProviderDstu3Test.class.getResource("/document-father-dstu3.json"), StandardCharsets.UTF_8);
resBody = resBody.replace("\"type\": \"document\"", "\"type\": \"transaction\""); resBody = resBody.replace("\"type\": \"document\"", "\"type\": \"transaction\"");
try { try {
client.create().resource(resBody).execute().getId(); client.create().resource(resBody).execute().getId();
@ -619,7 +621,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
assertEquals(201, response.getStatusLine().getStatusCode()); assertEquals(201, response.getStatusLine().getStatusCode());
String respString = IOUtils.toString(response.getEntity().getContent()); String respString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(response.toString()); ourLog.info(response.toString());
ourLog.info(respString); ourLog.info(respString);
assertThat(respString, containsString("<OperationOutcome xmlns=\"http://hl7.org/fhir\">")); assertThat(respString, containsString("<OperationOutcome xmlns=\"http://hl7.org/fhir\">"));
@ -638,7 +640,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String responseString = IOUtils.toString(response.getEntity().getContent()); String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(responseString); ourLog.info(responseString);
assertEquals(400, response.getStatusLine().getStatusCode()); assertEquals(400, response.getStatusLine().getStatusCode());
OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString); OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString);
@ -736,13 +738,16 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
myDaoConfig.setAllowMultipleDelete(true); myDaoConfig.setAllowMultipleDelete(true);
//@formatter:off //@formatter:off
ourClient IBaseOperationOutcome response = ourClient
.delete() .delete()
.resourceConditionalByType(Patient.class) .resourceConditionalByType(Patient.class)
.where(Patient.IDENTIFIER.exactly().code(methodName)) .where(Patient.IDENTIFIER.exactly().code(methodName))
.execute(); .execute();
//@formatter:on //@formatter:on
String encoded = myFhirCtx.newXmlParser().encodeResourceToString(response);
ourLog.info(encoded);
assertThat(encoded, containsString("<issue><severity value=\"information\"/><code value=\"informational\"/><diagnostics value=\"Successfully deleted Patient?identifier=testDeleteConditionalMultiple resource(s) in 2ms\"/></issue>"));
try { try {
ourClient.read().resource("Patient").withId(id1).execute(); ourClient.read().resource("Patient").withId(id1).execute();
fail(); fail();
@ -757,12 +762,30 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
} }
} }
@Test
public void testDeleteConditionalNoMatches() throws Exception {
String methodName = "testDeleteConditionalNoMatches";
HttpDelete delete = new HttpDelete(ourServerBase + "/Patient?identifier=" + methodName);
CloseableHttpResponse resp = ourHttpClient.execute(delete);
try {
ourLog.info(resp.toString());
String response = IOUtils.toString(resp.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(response);
assertEquals(200, resp.getStatusLine().getStatusCode());
assertThat(response, containsString("<issue><severity value=\"warning\"/><code value=\"not-found\"/><diagnostics value=\"Unable to find resource matching URL &quot;Patient?identifier=testDeleteConditionalNoMatches&quot;. Deletion failed.\"/></issue>"));
} finally {
IOUtils.closeQuietly(resp);
}
}
@Test @Test
public void testDeleteInvalidReference() throws IOException { public void testDeleteInvalidReference() throws IOException {
HttpDelete delete = new HttpDelete(ourServerBase + "/Patient"); HttpDelete delete = new HttpDelete(ourServerBase + "/Patient");
CloseableHttpResponse response = ourHttpClient.execute(delete); CloseableHttpResponse response = ourHttpClient.execute(delete);
try { try {
String responseString = IOUtils.toString(response.getEntity().getContent()); String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(responseString); ourLog.info(responseString);
assertEquals(400, response.getStatusLine().getStatusCode()); assertEquals(400, response.getStatusLine().getStatusCode());
assertThat(responseString, containsString("Can not perform delete, no ID provided")); assertThat(responseString, containsString("Can not perform delete, no ID provided"));
@ -816,7 +839,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
HttpDelete delete = new HttpDelete(ourServerBase + "/Patient?name=" + methodName); HttpDelete delete = new HttpDelete(ourServerBase + "/Patient?name=" + methodName);
response = ourHttpClient.execute(delete); response = ourHttpClient.execute(delete);
try { try {
assertEquals(204, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
} finally { } finally {
response.close(); response.close();
} }
@ -930,7 +953,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
int initialSize = client.search().forResource(DocumentManifest.class).returnBundle(Bundle.class).execute().getEntry().size(); int initialSize = client.search().forResource(DocumentManifest.class).returnBundle(Bundle.class).execute().getEntry().size();
String resBody = IOUtils.toString(ResourceProviderDstu3Test.class.getResource("/documentmanifest.json")); String resBody = IOUtils.toString(ResourceProviderDstu3Test.class.getResource("/documentmanifest.json"), StandardCharsets.UTF_8);
client.create().resource(resBody).execute(); client.create().resource(resBody).execute();
int newSize = client.search().forResource(DocumentManifest.class).returnBundle(Bundle.class).execute().getEntry().size(); int newSize = client.search().forResource(DocumentManifest.class).returnBundle(Bundle.class).execute().getEntry().size();
@ -948,7 +971,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
int initialSize = client.search().forResource(DocumentReference.class).returnBundle(Bundle.class).execute().getEntry().size(); int initialSize = client.search().forResource(DocumentReference.class).returnBundle(Bundle.class).execute().getEntry().size();
String resBody = IOUtils.toString(ResourceProviderDstu3Test.class.getResource("/documentreference.json")); String resBody = IOUtils.toString(ResourceProviderDstu3Test.class.getResource("/documentreference.json"), StandardCharsets.UTF_8);
client.create().resource(resBody).execute(); client.create().resource(resBody).execute();
int newSize = client.search().forResource(DocumentReference.class).returnBundle(Bundle.class).execute().getEntry().size(); int newSize = client.search().forResource(DocumentReference.class).returnBundle(Bundle.class).execute().getEntry().size();
@ -1382,7 +1405,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
CloseableHttpResponse response = ourHttpClient.execute(get); CloseableHttpResponse response = ourHttpClient.execute(get);
try { try {
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
String output = IOUtils.toString(response.getEntity().getContent()); String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
IOUtils.closeQuietly(response.getEntity().getContent()); IOUtils.closeQuietly(response.getEntity().getContent());
ourLog.info(output); ourLog.info(output);
List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
@ -1397,7 +1420,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
response = ourHttpClient.execute(get); response = ourHttpClient.execute(get);
try { try {
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
String output = IOUtils.toString(response.getEntity().getContent()); String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
IOUtils.closeQuietly(response.getEntity().getContent()); IOUtils.closeQuietly(response.getEntity().getContent());
ourLog.info(output); ourLog.info(output);
List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
@ -1411,7 +1434,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
response = ourHttpClient.execute(get); response = ourHttpClient.execute(get);
try { try {
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
String output = IOUtils.toString(response.getEntity().getContent()); String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
IOUtils.closeQuietly(response.getEntity().getContent()); IOUtils.closeQuietly(response.getEntity().getContent());
ourLog.info(output); ourLog.info(output);
List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
@ -1425,7 +1448,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
response = ourHttpClient.execute(get); response = ourHttpClient.execute(get);
try { try {
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
String output = IOUtils.toString(response.getEntity().getContent()); String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
IOUtils.closeQuietly(response.getEntity().getContent()); IOUtils.closeQuietly(response.getEntity().getContent());
ourLog.info(output); ourLog.info(output);
List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
@ -1449,7 +1472,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
CloseableHttpResponse response = ourHttpClient.execute(get); CloseableHttpResponse response = ourHttpClient.execute(get);
try { try {
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
String output = IOUtils.toString(response.getEntity().getContent()); String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
IOUtils.closeQuietly(response.getEntity().getContent()); IOUtils.closeQuietly(response.getEntity().getContent());
ourLog.info(output); ourLog.info(output);
assertThat(output, containsString("<parameter><name value=\"Patient\"/><valueInteger value=\"")); assertThat(output, containsString("<parameter><name value=\"Patient\"/><valueInteger value=\""));
@ -1491,7 +1514,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
int initialSize = client.search().forResource(ImagingStudy.class).returnBundle(Bundle.class).execute().getEntry().size(); int initialSize = client.search().forResource(ImagingStudy.class).returnBundle(Bundle.class).execute().getEntry().size();
String resBody = IOUtils.toString(ResourceProviderDstu3Test.class.getResource("/imagingstudy.json")); String resBody = IOUtils.toString(ResourceProviderDstu3Test.class.getResource("/imagingstudy.json"), StandardCharsets.UTF_8);
client.create().resource(resBody).execute(); client.create().resource(resBody).execute();
int newSize = client.search().forResource(ImagingStudy.class).returnBundle(Bundle.class).execute().getEntry().size(); int newSize = client.search().forResource(ImagingStudy.class).returnBundle(Bundle.class).execute().getEntry().size();
@ -1505,7 +1528,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
HttpGet get = new HttpGet(ourServerBase + "/metadata"); HttpGet get = new HttpGet(ourServerBase + "/metadata");
CloseableHttpResponse response = ourHttpClient.execute(get); CloseableHttpResponse response = ourHttpClient.execute(get);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
assertThat(resp, stringContainsInOrder("THIS IS THE DESC")); assertThat(resp, stringContainsInOrder("THIS IS THE DESC"));
@ -1560,7 +1583,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
post.setEntity(new StringEntity(input, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); post.setEntity(new StringEntity(input, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String output = IOUtils.toString(response.getEntity().getContent()); String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(output); ourLog.info(output);
assertEquals(400, response.getStatusLine().getStatusCode()); assertEquals(400, response.getStatusLine().getStatusCode());
assertThat(output, containsString("Input contains no parameter with name 'meta'")); assertThat(output, containsString("Input contains no parameter with name 'meta'"));
@ -1572,7 +1595,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
post.setEntity(new StringEntity(input, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); post.setEntity(new StringEntity(input, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
response = ourHttpClient.execute(post); response = ourHttpClient.execute(post);
try { try {
String output = IOUtils.toString(response.getEntity().getContent()); String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(output); ourLog.info(output);
assertEquals(400, response.getStatusLine().getStatusCode()); assertEquals(400, response.getStatusLine().getStatusCode());
assertThat(output, containsString("Input contains no parameter with name 'meta'")); assertThat(output, containsString("Input contains no parameter with name 'meta'"));
@ -1679,7 +1702,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
HttpGet read = new HttpGet(ourServerBase + "/Patient?_format=json"); HttpGet read = new HttpGet(ourServerBase + "/Patient?_format=json");
CloseableHttpResponse response = ourHttpClient.execute(read); CloseableHttpResponse response = ourHttpClient.execute(read);
try { try {
String text = IOUtils.toString(response.getEntity().getContent()); String text = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(text); ourLog.info(text);
assertEquals(Constants.STATUS_HTTP_200_OK, response.getStatusLine().getStatusCode()); assertEquals(Constants.STATUS_HTTP_200_OK, response.getStatusLine().getStatusCode());
assertThat(text, not(containsString("\"text\",\"type\""))); assertThat(text, not(containsString("\"text\",\"type\"")));
@ -1903,7 +1926,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
int matches; int matches;
HttpGet get = new HttpGet(ourServerBase + search); HttpGet get = new HttpGet(ourServerBase + search);
CloseableHttpResponse response = ourHttpClient.execute(get); CloseableHttpResponse response = ourHttpClient.execute(get);
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
IOUtils.closeQuietly(response.getEntity().getContent()); IOUtils.closeQuietly(response.getEntity().getContent());
ourLog.info(resp); ourLog.info(resp);
Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp); Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp);
@ -2352,7 +2375,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
CloseableHttpResponse resp = ourHttpClient.execute(post); CloseableHttpResponse resp = ourHttpClient.execute(post);
try { try {
assertEquals(200, resp.getStatusLine().getStatusCode()); assertEquals(200, resp.getStatusLine().getStatusCode());
String output= IOUtils.toString(resp.getEntity().getContent()); String output= IOUtils.toString(resp.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(output); ourLog.info(output);
} finally { } finally {
resp.close(); resp.close();
@ -2387,7 +2410,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String responseString = IOUtils.toString(response.getEntity().getContent()); String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(responseString); ourLog.info(responseString);
assertEquals(400, response.getStatusLine().getStatusCode()); assertEquals(400, response.getStatusLine().getStatusCode());
OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString); OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString);
@ -2410,7 +2433,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String responseString = IOUtils.toString(response.getEntity().getContent()); String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(responseString); ourLog.info(responseString);
assertThat(responseString, containsString("Can not update resource, request URL must contain an ID element for update (PUT) operation (it must be of the form [base]/[resource type]/[id])")); assertThat(responseString, containsString("Can not update resource, request URL must contain an ID element for update (PUT) operation (it must be of the form [base]/[resource type]/[id])"));
assertThat(responseString, containsString("<OperationOutcome")); assertThat(responseString, containsString("<OperationOutcome"));
@ -2436,7 +2459,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String responseString = IOUtils.toString(response.getEntity().getContent()); String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(responseString); ourLog.info(responseString);
assertThat(responseString, containsString("Can not update resource, request URL must contain an ID element for update (PUT) operation (it must be of the form [base]/[resource type]/[id])")); assertThat(responseString, containsString("Can not update resource, request URL must contain an ID element for update (PUT) operation (it must be of the form [base]/[resource type]/[id])"));
assertThat(responseString, containsString("<OperationOutcome")); assertThat(responseString, containsString("<OperationOutcome"));
@ -2644,7 +2667,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
response = ourHttpClient.execute(put); response = ourHttpClient.execute(put);
try { try {
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
String responseString = IOUtils.toString(response.getEntity().getContent()); String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
IOUtils.closeQuietly(response.getEntity().getContent()); IOUtils.closeQuietly(response.getEntity().getContent());
Patient respPt = myFhirCtx.newXmlParser().parseResource(Patient.class, responseString); Patient respPt = myFhirCtx.newXmlParser().parseResource(Patient.class, responseString);
@ -2699,7 +2722,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String responseString = IOUtils.toString(response.getEntity().getContent()); String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(responseString); ourLog.info(responseString);
assertEquals(400, response.getStatusLine().getStatusCode()); assertEquals(400, response.getStatusLine().getStatusCode());
OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString); OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString);
@ -2724,7 +2747,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(412, response.getStatusLine().getStatusCode()); assertEquals(412, response.getStatusLine().getStatusCode());
assertThat(resp, not(containsString("Resource has no id"))); assertThat(resp, not(containsString("Resource has no id")));
@ -2750,7 +2773,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
HttpGet get = new HttpGet(ourServerBase + "/Patient/" + id.getIdPart() + "/$validate"); HttpGet get = new HttpGet(ourServerBase + "/Patient/" + id.getIdPart() + "/$validate");
CloseableHttpResponse response = ourHttpClient.execute(get); CloseableHttpResponse response = ourHttpClient.execute(get);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(412, response.getStatusLine().getStatusCode()); assertEquals(412, response.getStatusLine().getStatusCode());
assertThat(resp, containsString("SHALL at least contain a contact's details or a reference to an organization")); assertThat(resp, containsString("SHALL at least contain a contact's details or a reference to an organization"));
@ -2780,7 +2803,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
} finally { } finally {
@ -2803,7 +2826,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertThat(resp, containsString("No resource supplied for $validate operation (resource is required unless mode is &quot;delete&quot;)")); assertThat(resp, containsString("No resource supplied for $validate operation (resource is required unless mode is &quot;delete&quot;)"));
assertEquals(400, response.getStatusLine().getStatusCode()); assertEquals(400, response.getStatusLine().getStatusCode());
@ -2819,7 +2842,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
HttpGet get = new HttpGet(ourServerBase + "/Patient/$validate?mode=create"); HttpGet get = new HttpGet(ourServerBase + "/Patient/$validate?mode=create");
CloseableHttpResponse response = ourHttpClient.execute(get); CloseableHttpResponse response = ourHttpClient.execute(get);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertThat(resp, containsString("No resource supplied for $validate operation (resource is required unless mode is &quot;delete&quot;)")); assertThat(resp, containsString("No resource supplied for $validate operation (resource is required unless mode is &quot;delete&quot;)"));
assertEquals(400, response.getStatusLine().getStatusCode()); assertEquals(400, response.getStatusLine().getStatusCode());
@ -2849,7 +2872,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
} finally { } finally {
@ -2875,7 +2898,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
assertThat(resp, not(containsString("Resource has no id"))); assertThat(resp, not(containsString("Resource has no id")));
@ -2901,7 +2924,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
CloseableHttpResponse response = ourHttpClient.execute(post); CloseableHttpResponse response = ourHttpClient.execute(post);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
assertThat(resp, not(containsString("Resource has no id"))); assertThat(resp, not(containsString("Resource has no id")));
@ -2925,7 +2948,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
HttpGet get = new HttpGet(ourServerBase + "/ValueSet/" + vsid.getIdPart() + "/$expand"); HttpGet get = new HttpGet(ourServerBase + "/ValueSet/" + vsid.getIdPart() + "/$expand");
CloseableHttpResponse response = ourHttpClient.execute(get); CloseableHttpResponse response = ourHttpClient.execute(get);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
assertThat(resp, containsString("<ValueSet xmlns=\"http://hl7.org/fhir\">")); assertThat(resp, containsString("<ValueSet xmlns=\"http://hl7.org/fhir\">"));
@ -2953,7 +2976,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
get = new HttpGet(ourServerBase + "/ValueSet/" + vsid.getIdPart() + "/$expand?filter=systolic"); get = new HttpGet(ourServerBase + "/ValueSet/" + vsid.getIdPart() + "/$expand?filter=systolic");
response = ourHttpClient.execute(get); response = ourHttpClient.execute(get);
try { try {
String resp = IOUtils.toString(response.getEntity().getContent()); String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(resp); ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals(200, response.getStatusLine().getStatusCode());
//@formatter:off //@formatter:off

18
pom.xml
View File

@ -260,7 +260,7 @@
<!-- Dependency Versions --> <!-- Dependency Versions -->
<derby_version>10.12.1.1</derby_version> <derby_version>10.12.1.1</derby_version>
<jersey_version>2.22.2</jersey_version> <jersey_version>2.23.1</jersey_version>
<jetty_version>9.3.10.v20160621</jetty_version> <jetty_version>9.3.10.v20160621</jetty_version>
<!-- Note on Hibernate versions: Hibernate 4.3+ uses JPA 2.1, which is too new for a number of platforms including JBoss EAP 6.x and Glassfish 3.0. Upgrade this version with caution! Also note that if <!-- Note on Hibernate versions: Hibernate 4.3+ uses JPA 2.1, which is too new for a number of platforms including JBoss EAP 6.x and Glassfish 3.0. Upgrade this version with caution! Also note that if
you change this, you may get a failure in hibernate4-maven-plugin. See the note in hapi-fhir-jpaserver-base/pom.xml's configuration for that plugin... --> you change this, you may get a failure in hibernate4-maven-plugin. See the note in hapi-fhir-jpaserver-base/pom.xml's configuration for that plugin... -->
@ -271,8 +271,8 @@
<maven_license_plugin_version>1.8</maven_license_plugin_version> <maven_license_plugin_version>1.8</maven_license_plugin_version>
<maven_source_plugin_version>2.4</maven_source_plugin_version> <maven_source_plugin_version>2.4</maven_source_plugin_version>
<phloc_schematron_version>2.7.1</phloc_schematron_version> <phloc_schematron_version>2.7.1</phloc_schematron_version>
<phloc_commons_version>4.4.4</phloc_commons_version> <phloc_commons_version>4.4.5</phloc_commons_version>
<spring_version>4.3.0.RELEASE</spring_version> <spring_version>4.3.1.RELEASE</spring_version>
<thymeleaf-version>2.1.4.RELEASE</thymeleaf-version> <thymeleaf-version>2.1.4.RELEASE</thymeleaf-version>
<ebay_cors_filter_version>1.0.1</ebay_cors_filter_version> <ebay_cors_filter_version>1.0.1</ebay_cors_filter_version>
<xmlunit_version>1.6</xmlunit_version> <xmlunit_version>1.6</xmlunit_version>
@ -293,7 +293,7 @@
<dependency> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
<version>1.1.5</version> <version>1.1.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
@ -323,7 +323,7 @@
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>2.4</version> <version>2.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>directory-naming</groupId> <groupId>directory-naming</groupId>
@ -428,7 +428,7 @@
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
<version>4.5.1</version> <version>4.5.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
@ -438,7 +438,7 @@
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId> <artifactId>httpcore</artifactId>
<version>4.4.4</version> <version>4.4.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.lucene</groupId> <groupId>org.apache.lucene</groupId>
@ -543,7 +543,7 @@
<dependency> <dependency>
<groupId>org.fusesource.jansi</groupId> <groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId> <artifactId>jansi</artifactId>
<version>1.11</version> <version>1.13</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.glassfish</groupId> <groupId>org.glassfish</groupId>
@ -603,7 +603,7 @@
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId> <artifactId>hibernate-search-orm</artifactId>
<version>5.5.3.Final</version> <version>5.5.4.Final</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.javassist</groupId> <groupId>org.javassist</groupId>

View File

@ -46,6 +46,24 @@
contains a Content-Type header but no Accept header, the response will prefer the contains a Content-Type header but no Accept header, the response will prefer the
encoding specified by the Content-Type header. encoding specified by the Content-Type header.
</action> </action>
<action type="add">
Bump the version of a few dependencies to the
latest versions (dependent HAPI modules listed in brackets):
<![CDATA[
<ul>
<li>Logback (used in sample projects): 1.1.5 -&gt; 1.1.7</li>
<li>Phloc Commons (used by schematron validator): 4.4.4 -&gt; 4.4.5</li>
<li>Commons-IO: 2.4 -&gt; 2.5</li>
<li>Apache HTTPClient: 4.5.1 -&gt; 4.5.2</li>
<li>Apache HTTPCore: 4.4.4 -&gt; 4.4.5</li>
<li>Jersey (JAX-RS tests): 2.22.2 -&gt; 2.23.1</li>
<li>Spring (JPA, Web Tester): 4.3.0 -&gt; 4.3.1</li>
<!--<li>Hibernate ORM (JPA): 5.1.0 -&gt; 5.2.1</li>-->
<li>Hibernate Search (JPA): 5.5.2 -&gt; 5.5.4</li>
</ul>
]]>
</action>
<action type="fix"> <action type="fix">
Fix issue in DSTU1 Bundle parsing where unexpected elements in the bundle resulted in a failure Fix issue in DSTU1 Bundle parsing where unexpected elements in the bundle resulted in a failure
to parse. to parse.
@ -100,6 +118,11 @@
bundles, resulting in invalid content being saved. Thanks to Mirjam bundles, resulting in invalid content being saved. Thanks to Mirjam
Baltus for reporting! Baltus for reporting!
</action> </action>
<action type="fix">
JPA server now returns HTTP 200 instead of HTTP 404 for
conditional deletes which did not find any matches,
per FHIR-I decision.
</action>
</release> </release>
<release version="1.6" date="2016-07-07"> <release version="1.6" date="2016-07-07">
<action type="fix"> <action type="fix">