mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-02-10 23:14:51 +00:00
Work on porting DSTU1 tests
This commit is contained in:
parent
602857f1e2
commit
43c9003258
@ -67,8 +67,6 @@ public class Constants {
|
||||
public static final String HEADER_AUTHORIZATION = "Authorization";
|
||||
public static final String HEADER_AUTHORIZATION_VALPREFIX_BASIC = "Basic ";
|
||||
public static final String HEADER_AUTHORIZATION_VALPREFIX_BEARER = "Bearer ";
|
||||
public static final String HEADER_CATEGORY = "Category";
|
||||
public static final String HEADER_CATEGORY_LC = HEADER_CATEGORY.toLowerCase();
|
||||
public static final String HEADER_CONTENT_DISPOSITION = "Content-Disposition";
|
||||
public static final String HEADER_CONTENT_ENCODING = "Content-Encoding";
|
||||
public static final String HEADER_CONTENT_LOCATION = "Content-Location";
|
||||
|
@ -1,7 +1,5 @@
|
||||
package ca.uhn.fhir.rest.param;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
/*
|
||||
@ -32,8 +30,10 @@ import ca.uhn.fhir.context.*;
|
||||
import ca.uhn.fhir.model.api.*;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.IntegerDt;
|
||||
import ca.uhn.fhir.rest.annotation.*;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.TagListParam;
|
||||
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
||||
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
|
||||
import ca.uhn.fhir.rest.param.binder.QueryParameterAndBinder;
|
||||
import ca.uhn.fhir.util.ReflectionUtil;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
@ -44,7 +44,6 @@ public class ParameterUtil {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ParameterUtil.class);
|
||||
private static final String SCHEME = "scheme=\"";
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends IIdType> T convertIdToType(IIdType value, Class<T> theIdParamType) {
|
||||
if (value != null && !theIdParamType.isAssignableFrom(value.getClass())) {
|
||||
@ -111,8 +110,6 @@ public class ParameterUtil {
|
||||
return parseQueryParams(theContext, paramType, theUnqualifiedParamName, theParameters);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Escapes a string according to the rules for parameter escaping specified in the <a href="http://www.hl7.org/implement/standards/fhir/search.html#escaping">FHIR Specification Escaping
|
||||
* Section</a>
|
||||
@ -254,86 +251,6 @@ public class ParameterUtil {
|
||||
return eTagVersion;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void parseTagValue(TagList tagList, String nextTagComplete) {
|
||||
StringBuilder next = new StringBuilder(nextTagComplete);
|
||||
parseTagValue(tagList, nextTagComplete, next);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static void parseTagValue(TagList theTagList, String theCompleteHeaderValue, StringBuilder theBuffer) {
|
||||
int firstSemicolon = theBuffer.indexOf(";");
|
||||
int deleteTo;
|
||||
if (firstSemicolon == -1) {
|
||||
firstSemicolon = theBuffer.indexOf(",");
|
||||
if (firstSemicolon == -1) {
|
||||
firstSemicolon = theBuffer.length();
|
||||
deleteTo = theBuffer.length();
|
||||
} else {
|
||||
deleteTo = firstSemicolon;
|
||||
}
|
||||
} else {
|
||||
deleteTo = firstSemicolon + 1;
|
||||
}
|
||||
|
||||
String term = theBuffer.substring(0, firstSemicolon);
|
||||
String scheme = null;
|
||||
String label = null;
|
||||
if (isBlank(term)) {
|
||||
return;
|
||||
}
|
||||
|
||||
theBuffer.delete(0, deleteTo);
|
||||
while (theBuffer.length() > 0 && theBuffer.charAt(0) == ' ') {
|
||||
theBuffer.deleteCharAt(0);
|
||||
}
|
||||
|
||||
while (theBuffer.length() > 0) {
|
||||
boolean foundSomething = false;
|
||||
if (theBuffer.length() > SCHEME.length() && theBuffer.substring(0, SCHEME.length()).equals(SCHEME)) {
|
||||
int closeIdx = theBuffer.indexOf("\"", SCHEME.length());
|
||||
scheme = theBuffer.substring(SCHEME.length(), closeIdx);
|
||||
theBuffer.delete(0, closeIdx + 1);
|
||||
foundSomething = true;
|
||||
}
|
||||
if (theBuffer.length() > LABEL.length() && theBuffer.substring(0, LABEL.length()).equals(LABEL)) {
|
||||
int closeIdx = theBuffer.indexOf("\"", LABEL.length());
|
||||
label = theBuffer.substring(LABEL.length(), closeIdx);
|
||||
theBuffer.delete(0, closeIdx + 1);
|
||||
foundSomething = true;
|
||||
}
|
||||
// TODO: support enc2231-string as described in
|
||||
// http://tools.ietf.org/html/draft-johnston-http-category-header-02
|
||||
// TODO: support multiple tags in one header as described in
|
||||
// http://hl7.org/implement/standards/fhir/http.html#tags
|
||||
|
||||
while (theBuffer.length() > 0 && (theBuffer.charAt(0) == ' ' || theBuffer.charAt(0) == ';')) {
|
||||
theBuffer.deleteCharAt(0);
|
||||
}
|
||||
|
||||
if (!foundSomething) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (theBuffer.length() > 0 && theBuffer.charAt(0) == ',') {
|
||||
theBuffer.deleteCharAt(0);
|
||||
while (theBuffer.length() > 0 && theBuffer.charAt(0) == ' ') {
|
||||
theBuffer.deleteCharAt(0);
|
||||
}
|
||||
theTagList.add(new Tag(scheme, term, label));
|
||||
parseTagValue(theTagList, theCompleteHeaderValue, theBuffer);
|
||||
} else {
|
||||
theTagList.add(new Tag(scheme, term, label));
|
||||
}
|
||||
|
||||
if (theBuffer.length() > 0) {
|
||||
ourLog.warn("Ignoring extra text at the end of " + Constants.HEADER_CATEGORY + " tag '"
|
||||
+ theBuffer.toString() + "' - Complete tag value was: " + theCompleteHeaderValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static IQueryParameterOr<?> singleton(final IQueryParameterType theParam, final String theParamName) {
|
||||
return new IQueryParameterOr<IQueryParameterType>() {
|
||||
|
||||
|
@ -298,7 +298,7 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
|
||||
// return sm;
|
||||
}
|
||||
|
||||
private static boolean isResourceInterface(Class<?> theReturnTypeFromMethod) {
|
||||
public static boolean isResourceInterface(Class<?> theReturnTypeFromMethod) {
|
||||
return theReturnTypeFromMethod.equals(IBaseResource.class) || theReturnTypeFromMethod.equals(IResource.class) || theReturnTypeFromMethod.equals(IAnyResource.class);
|
||||
}
|
||||
|
||||
|
@ -2,30 +2,22 @@ package ca.uhn.fhir.rest.client.method;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.client.impl.BaseHttpClientInvocation;
|
||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
|
||||
abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<MethodOutcome> {
|
||||
static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseOutcomeReturningMethodBinding.class);
|
||||
|
||||
private static EnumSet<RestOperationTypeEnum> ourOperationsWhichAllowPreferHeader = EnumSet.of(RestOperationTypeEnum.CREATE, RestOperationTypeEnum.UPDATE);
|
||||
|
||||
private boolean myReturnVoid;
|
||||
|
||||
public BaseOutcomeReturningMethodBinding(Method theMethod, FhirContext theContext, Class<?> theMethodAnnotation, Object theProvider) {
|
||||
@ -47,7 +39,7 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<Metho
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract BaseHttpClientInvocation createClientInvocation(Object[] theArgs, IResource resource);
|
||||
protected abstract BaseHttpClientInvocation createClientInvocation(Object[] theArgs, IBaseResource resource);
|
||||
|
||||
/**
|
||||
* For servers, this method will match only incoming requests that match the given operation, or which have no
|
||||
@ -55,40 +47,6 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<Metho
|
||||
*/
|
||||
protected abstract String getMatchingOperation();
|
||||
|
||||
private int getOperationStatus(MethodOutcome response) {
|
||||
switch (getRestOperationType()) {
|
||||
case CREATE:
|
||||
if (response == null) {
|
||||
throw new InternalErrorException("Method " + getMethod().getName() + " in type " + getMethod().getDeclaringClass().getCanonicalName() + " returned null, which is not allowed for create operation");
|
||||
}
|
||||
if (response.getCreated() == null || Boolean.TRUE.equals(response.getCreated())) {
|
||||
return Constants.STATUS_HTTP_201_CREATED;
|
||||
}
|
||||
return Constants.STATUS_HTTP_200_OK;
|
||||
|
||||
case UPDATE:
|
||||
if (response == null || response.getCreated() == null || Boolean.FALSE.equals(response.getCreated())) {
|
||||
return Constants.STATUS_HTTP_200_OK;
|
||||
}
|
||||
return Constants.STATUS_HTTP_201_CREATED;
|
||||
|
||||
case VALIDATE:
|
||||
case DELETE:
|
||||
default:
|
||||
if (response == null) {
|
||||
if (isReturnVoid() == false) {
|
||||
throw new InternalErrorException("Method " + getMethod().getName() + " in type " + getMethod().getDeclaringClass().getCanonicalName() + " returned null");
|
||||
}
|
||||
return Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
}
|
||||
if (response.getOperationOutcome() == null) {
|
||||
return Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
}
|
||||
return Constants.STATUS_HTTP_200_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MethodOutcome invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws BaseServerResponseException {
|
||||
if (theResponseStatusCode >= 200 && theResponseStatusCode < 300) {
|
||||
|
@ -26,7 +26,6 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.rest.annotation.ResourceParam;
|
||||
import ca.uhn.fhir.rest.client.impl.BaseHttpClientInvocation;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
@ -76,7 +75,7 @@ abstract class BaseOutcomeReturningMethodBindingWithResourceParam extends BaseOu
|
||||
|
||||
@Override
|
||||
public BaseHttpClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException {
|
||||
IResource resource = (IResource) theArgs[myResourceParameterIndex]; // TODO: use IBaseResource
|
||||
IBaseResource resource = (IBaseResource) theArgs[myResourceParameterIndex];
|
||||
if (resource == null) {
|
||||
throw new NullPointerException("Resource can not be null");
|
||||
}
|
||||
|
@ -175,12 +175,12 @@ public abstract class BaseResourceReturningMethodBinding extends BaseMethodBindi
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Class<? extends IBaseResource>> createPreferTypesList() {
|
||||
List<Class<? extends IBaseResource>> preferTypes = null;
|
||||
if (myResourceListCollectionType != null && IBaseResource.class.isAssignableFrom(myResourceListCollectionType)) {
|
||||
if (myResourceType != null && !BaseMethodBinding.isResourceInterface(myResourceType)) {
|
||||
preferTypes = new ArrayList<Class<? extends IBaseResource>>(1);
|
||||
preferTypes.add((Class<? extends IBaseResource>) myResourceType);
|
||||
} else if (myResourceListCollectionType != null && IBaseResource.class.isAssignableFrom(myResourceListCollectionType) && !BaseMethodBinding.isResourceInterface(myResourceListCollectionType)) {
|
||||
preferTypes = new ArrayList<Class<? extends IBaseResource>>(1);
|
||||
preferTypes.add((Class<? extends IBaseResource>) myResourceListCollectionType);
|
||||
// } else if (myResourceType != null) {
|
||||
// preferTypes = new ArrayList<Class<? extends IBaseResource>>(1);
|
||||
// preferTypes.add((Class<? extends IBaseResource>) myResourceListCollectionType);
|
||||
}
|
||||
return preferTypes;
|
||||
}
|
||||
@ -218,7 +218,8 @@ public abstract class BaseResourceReturningMethodBinding extends BaseMethodBindi
|
||||
}
|
||||
|
||||
public enum ReturnTypeEnum {
|
||||
BUNDLE, RESOURCE
|
||||
BUNDLE,
|
||||
RESOURCE
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class CreateMethodBinding extends BaseOutcomeReturningMethodBindingWithRe
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseHttpClientInvocation createClientInvocation(Object[] theArgs, IResource theResource) {
|
||||
protected BaseHttpClientInvocation createClientInvocation(Object[] theArgs, IBaseResource theResource) {
|
||||
FhirContext context = getContext();
|
||||
|
||||
BaseHttpClientInvocation retVal = MethodUtil.createCreateInvocation(theResource, context);
|
||||
|
@ -21,15 +21,12 @@ package ca.uhn.fhir.rest.client.method;
|
||||
*/
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.rest.annotation.Delete;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
@ -54,7 +51,7 @@ public class DeleteMethodBinding extends BaseOutcomeReturningMethodBindingWithRe
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseHttpClientInvocation createClientInvocation(Object[] theArgs, IResource theResource) {
|
||||
protected BaseHttpClientInvocation createClientInvocation(Object[] theArgs, IBaseResource theResource) {
|
||||
StringBuilder urlExtension = new StringBuilder();
|
||||
urlExtension.append(getContext().getResourceDefinition(theResource).getName());
|
||||
|
||||
|
@ -26,12 +26,10 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Date;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.rest.annotation.History;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
@ -88,10 +86,10 @@ public class HistoryMethodBinding extends BaseResourceReturningMethodBinding {
|
||||
|
||||
@Override
|
||||
public BaseHttpClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException {
|
||||
IdDt id = null;
|
||||
IIdType id = null;
|
||||
String resourceName = myResourceName;
|
||||
if (myIdParamIndex != null) {
|
||||
id = (IdDt) theArgs[myIdParamIndex];
|
||||
id = (IIdType) theArgs[myIdParamIndex];
|
||||
if (id == null || isBlank(id.getValue())) {
|
||||
throw new NullPointerException("ID can not be null");
|
||||
}
|
||||
|
@ -494,21 +494,6 @@ public class MethodUtil {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> categoryHeaders = theHeaders.get(Constants.HEADER_CATEGORY_LC);
|
||||
if (categoryHeaders != null && categoryHeaders.size() > 0 && StringUtils.isNotBlank(categoryHeaders.get(0))) {
|
||||
TagList tagList = new TagList();
|
||||
for (String header : categoryHeaders) {
|
||||
ParameterUtil.parseTagValue(tagList, header);
|
||||
}
|
||||
if (resource instanceof IResource) {
|
||||
ResourceMetadataKeyEnum.TAG_LIST.put((IResource) resource, tagList);
|
||||
} else if (resource instanceof IAnyResource) {
|
||||
IBaseMetaType meta = ((IAnyResource) resource).getMeta();
|
||||
for (Tag next : tagList) {
|
||||
meta.addTag().setSystem(next.getScheme()).setCode(next.getTerm()).setDisplay(next.getLabel());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static MethodOutcome process2xxResponse(FhirContext theContext, int theResponseStatusCode,
|
||||
|
@ -24,11 +24,11 @@ import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.rest.annotation.Patch;
|
||||
import ca.uhn.fhir.rest.annotation.ResourceParam;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
@ -81,7 +81,7 @@ public class PatchMethodBinding extends BaseOutcomeReturningMethodBindingWithRes
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseHttpClientInvocation createClientInvocation(Object[] theArgs, IResource theResource) {
|
||||
protected BaseHttpClientInvocation createClientInvocation(Object[] theArgs, IBaseResource theResource) {
|
||||
StringBuilder urlExtension = new StringBuilder();
|
||||
urlExtension.append(getContext().getResourceDefinition(theResource).getName());
|
||||
|
||||
|
@ -10,7 +10,6 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.annotation.Update;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
@ -31,8 +30,8 @@ public class UpdateMethodBinding extends BaseOutcomeReturningMethodBindingWithRe
|
||||
|
||||
|
||||
@Override
|
||||
protected BaseHttpClientInvocation createClientInvocation(Object[] theArgs, IResource theResource) {
|
||||
IdDt idDt = (IdDt) theArgs[myIdParameterIndex];
|
||||
protected BaseHttpClientInvocation createClientInvocation(Object[] theArgs, IBaseResource theResource) {
|
||||
IIdType idDt = (IIdType) theArgs[myIdParameterIndex];
|
||||
if (idDt == null) {
|
||||
throw new NullPointerException("ID can not be null");
|
||||
}
|
||||
|
@ -50,7 +50,6 @@ public class ETagClientDstu2Test {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
|
||||
@ -95,7 +94,6 @@ public class ETagClientDstu2Test {
|
||||
Header[] headers = new Header[] {
|
||||
new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"),
|
||||
new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
|
||||
new BasicHeader(Constants.HEADER_CATEGORY, "http://foo/tagdefinition.html; scheme=\"http://hl7.org/fhir/tag\"; label=\"Some tag\""),
|
||||
new BasicHeader(Constants.HEADER_ETAG, "\"9999\"")
|
||||
};
|
||||
//@formatter:on
|
||||
@ -257,8 +255,10 @@ public class ETagClientDstu2Test {
|
||||
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||
Header[] headers = new Header[] { new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"), new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
|
||||
new BasicHeader(Constants.HEADER_CATEGORY, "http://foo/tagdefinition.html; scheme=\"http://hl7.org/fhir/tag\"; label=\"Some tag\"") };
|
||||
Header[] headers = new Header[] {
|
||||
new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"),
|
||||
new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
|
||||
};
|
||||
when(myHttpResponse.getAllHeaders()).thenReturn(headers);
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
|
||||
|
@ -237,8 +237,10 @@ public class ETagClientTest {
|
||||
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||
Header[] headers = new Header[] { new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"), new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
|
||||
new BasicHeader(Constants.HEADER_CATEGORY, "http://foo/tagdefinition.html; scheme=\"http://hl7.org/fhir/tag\"; label=\"Some tag\"") };
|
||||
Header[] headers = new Header[] {
|
||||
new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"),
|
||||
new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
|
||||
};
|
||||
when(myHttpResponse.getAllHeaders()).thenReturn(headers);
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
|
||||
|
@ -47,9 +47,13 @@ import ca.uhn.fhir.util.UrlUtil;
|
||||
|
||||
public class ClientR4Test {
|
||||
|
||||
private HttpClient myHttpClient;
|
||||
private HttpResponse myHttpResponse;
|
||||
private static FhirContext ourCtx = FhirContext.forR4();
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ClientR4Test.class);
|
||||
private HttpClient myHttpClient;
|
||||
|
||||
private HttpResponse myHttpResponse;
|
||||
|
||||
// atom-document-large.xml
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@ -61,8 +65,6 @@ public class ClientR4Test {
|
||||
myHttpResponse = mock(HttpResponse.class, new ReturnsDeepStubs());
|
||||
}
|
||||
|
||||
// atom-document-large.xml
|
||||
|
||||
public String getHistoryBundleWithTwoResults() {
|
||||
/*
|
||||
* //@formatter:off
|
||||
@ -115,45 +117,11 @@ public class ClientR4Test {
|
||||
|
||||
p.setId("http://foo.com/Patient/123/_history/2333");
|
||||
p.addName().setFamily("Kramer").addGiven("Doe");
|
||||
p.addIdentifier().setValue("PRP1660");
|
||||
String msg = EncodingEnum.XML.newParser(ourCtx).setPrettyPrint(true).encodeResourceToString(p);
|
||||
return msg;
|
||||
}
|
||||
|
||||
static String getPatientFeedWithOneResult() {
|
||||
|
||||
Bundle retVal = new Bundle();
|
||||
|
||||
Patient p = new Patient();
|
||||
p.addName().setFamily("Cardinal").addGiven("John");
|
||||
p.addIdentifier().setValue("PRP1660");
|
||||
retVal.addEntry().setResource(p);
|
||||
|
||||
return ourCtx.newXmlParser().encodeResourceToString(retVal);
|
||||
|
||||
// String msg = "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n" +
|
||||
// "<title/>\n" +
|
||||
// "<id>d039f91a-cc3c-4013-988e-af4d8d0614bd</id>\n" +
|
||||
// "<os:totalResults xmlns:os=\"http://a9.com/-/spec/opensearch/1.1/\">1</os:totalResults>\n" +
|
||||
// "<author>\n" +
|
||||
// "<name>ca.uhn.fhir.rest.server.DummyRestfulServer</name>\n" +
|
||||
// "</author>\n" +
|
||||
// "<entry>\n" +
|
||||
// "<content type=\"text/xml\">"
|
||||
// + "<Patient xmlns=\"http://hl7.org/fhir\">"
|
||||
// + "<text><status value=\"generated\" /><div xmlns=\"http://www.w3.org/1999/xhtml\">John Cardinal: 444333333 </div></text>"
|
||||
// + "<identifier><label value=\"SSN\" /><system value=\"http://orionhealth.com/mrn\" /><value value=\"PRP1660\" /></identifier>"
|
||||
// + "<name><use value=\"official\" /><family value=\"Cardinal\" /><given value=\"John\" /></name>"
|
||||
// + "<name><family value=\"Kramer\" /><given value=\"Doe\" /></name>"
|
||||
// + "<telecom><system value=\"phone\" /><value value=\"555-555-2004\" /><use value=\"work\" /></telecom>"
|
||||
// + "<gender><coding><system value=\"http://hl7.org/fhir/v3/AdministrativeGender\" /><code value=\"M\" /></coding></gender>"
|
||||
// + "<address><use value=\"home\" /><line value=\"2222 Home Street\" /></address><active value=\"true\" />"
|
||||
// + "</Patient>"
|
||||
// + "</content>\n"
|
||||
// + " </entry>\n"
|
||||
// + "</feed>";
|
||||
// return msg;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreate() throws Exception {
|
||||
|
||||
@ -270,7 +238,10 @@ public class ClientR4Test {
|
||||
@Test
|
||||
public void testGetConformance() throws Exception {
|
||||
|
||||
String msg = IOUtils.toString(ClientR4Test.class.getResourceAsStream("/example-metadata.xml"));
|
||||
CapabilityStatement cs = new CapabilityStatement();
|
||||
cs.getPublisherElement().setValue("Health Intersections");
|
||||
String msg = ourCtx.newXmlParser().encodeResourceToString(cs);
|
||||
|
||||
|
||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
||||
@ -418,12 +389,15 @@ public class ClientR4Test {
|
||||
|
||||
String msg = getPatient();
|
||||
|
||||
ourLog.info(msg);
|
||||
|
||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
||||
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
Header[] headers = new Header[] { new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"),
|
||||
new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
|
||||
new BasicHeader(Constants.HEADER_CATEGORY, "http://foo/tagdefinition.html; scheme=\"http://hl7.org/fhir/tag\"; label=\"Some tag\"") };
|
||||
Header[] headers = new Header[] {
|
||||
new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"),
|
||||
new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333")
|
||||
};
|
||||
|
||||
when(myHttpResponse.getAllHeaders()).thenReturn(headers);
|
||||
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
@ -443,6 +417,8 @@ public class ClientR4Test {
|
||||
lm.setTimeZoneZulu(true);
|
||||
assertEquals("1995-11-15T04:58:08.000Z", lm.getValueAsString());
|
||||
|
||||
ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response));
|
||||
|
||||
List<Coding> tags = response.getMeta().getTag();
|
||||
assertNotNull(tags);
|
||||
assertEquals(1, tags.size());
|
||||
@ -615,7 +591,7 @@ public class ClientR4Test {
|
||||
param.setUpperBound(new DateParam(ParamPrefixEnum.LESSTHAN_OR_EQUALS, "2021-01-01"));
|
||||
client.getPatientByDateRange(param);
|
||||
|
||||
assertEquals("http://foo/Patient?dateRange=ge2011-01-01&dateRange=%3C%3D2021-01-01", capt.getValue().getURI().toString());
|
||||
assertEquals("http://foo/Patient?dateRange=ge2011-01-01&dateRange=le2021-01-01", capt.getValue().getURI().toString());
|
||||
|
||||
}
|
||||
|
||||
@ -655,7 +631,7 @@ public class ClientR4Test {
|
||||
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||
Patient response = client.findPatientQuantity(new QuantityParam(ParamPrefixEnum.GREATERTHAN, 123L, "foo", "bar"));
|
||||
|
||||
assertEquals("http://foo/Patient?quantityParam=%3E123%7Cfoo%7Cbar", capt.getValue().getURI().toString());
|
||||
assertEquals("http://foo/Patient?quantityParam=gt123%7Cfoo%7Cbar", capt.getValue().getURI().toString());
|
||||
assertEquals("PRP1660", response.getIdentifier().get(0).getValueElement().getValue());
|
||||
|
||||
}
|
||||
@ -1080,7 +1056,7 @@ public class ClientR4Test {
|
||||
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 201, "OK"));
|
||||
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
||||
when(myHttpResponse.getAllHeaders()).thenReturn(toHeaderArray("Content-Location", "http://example.com/fhir/Patient/100/_history/200"));
|
||||
when(myHttpResponse.getAllHeaders()).thenReturn(toHeaderArray(Constants.HEADER_LOCATION, "http://example.com/fhir/Patient/100/_history/200"));
|
||||
|
||||
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||
client.updatePatient(new IdType("Patient/100/_history/200"), patient);
|
||||
@ -1089,7 +1065,7 @@ public class ClientR4Test {
|
||||
HttpPut post = (HttpPut) capt.getValue();
|
||||
assertEquals("http://foo/Patient/100", post.getURI().toASCIIString());
|
||||
|
||||
Header h = post.getFirstHeader("content-location");
|
||||
Header h = post.getFirstHeader(Constants.HEADER_LOCATION);
|
||||
assertEquals("Patient/100/_history/200", h.getValue());
|
||||
|
||||
}
|
||||
@ -1130,7 +1106,7 @@ public class ClientR4Test {
|
||||
HttpPut post = (HttpPut) capt.getValue();
|
||||
assertThat(post.getURI().toASCIIString(), StringEndsWith.endsWith("/Patient/100"));
|
||||
assertThat(IOUtils.toString(post.getEntity().getContent()), StringContains.containsString("<Patient"));
|
||||
assertThat(post.getFirstHeader("Content-Location").getValue(), StringEndsWith.endsWith("Patient/100/_history/200"));
|
||||
assertThat(post.getFirstHeader(Constants.HEADER_LOCATION).getValue(), StringEndsWith.endsWith("Patient/100/_history/200"));
|
||||
assertEquals("http://example.com/fhir/Patient/100/_history/200", response.getId().getValue());
|
||||
assertEquals("200", response.getId().getVersionIdPart());
|
||||
}
|
||||
@ -1214,6 +1190,45 @@ public class ClientR4Test {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
private static String getPatientFeedWithOneResult() {
|
||||
return getPatientFeedWithOneResult(ourCtx);
|
||||
}
|
||||
|
||||
static String getPatientFeedWithOneResult(FhirContext theCtx) {
|
||||
|
||||
Bundle retVal = new Bundle();
|
||||
|
||||
Patient p = new Patient();
|
||||
p.addName().setFamily("Cardinal").addGiven("John");
|
||||
p.addIdentifier().setValue("PRP1660");
|
||||
retVal.addEntry().setResource(p);
|
||||
|
||||
return theCtx.newXmlParser().encodeResourceToString(retVal);
|
||||
|
||||
// String msg = "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n" +
|
||||
// "<title/>\n" +
|
||||
// "<id>d039f91a-cc3c-4013-988e-af4d8d0614bd</id>\n" +
|
||||
// "<os:totalResults xmlns:os=\"http://a9.com/-/spec/opensearch/1.1/\">1</os:totalResults>\n" +
|
||||
// "<author>\n" +
|
||||
// "<name>ca.uhn.fhir.rest.server.DummyRestfulServer</name>\n" +
|
||||
// "</author>\n" +
|
||||
// "<entry>\n" +
|
||||
// "<content type=\"text/xml\">"
|
||||
// + "<Patient xmlns=\"http://hl7.org/fhir\">"
|
||||
// + "<text><status value=\"generated\" /><div xmlns=\"http://www.w3.org/1999/xhtml\">John Cardinal: 444333333 </div></text>"
|
||||
// + "<identifier><label value=\"SSN\" /><system value=\"http://orionhealth.com/mrn\" /><value value=\"PRP1660\" /></identifier>"
|
||||
// + "<name><use value=\"official\" /><family value=\"Cardinal\" /><given value=\"John\" /></name>"
|
||||
// + "<name><family value=\"Kramer\" /><given value=\"Doe\" /></name>"
|
||||
// + "<telecom><system value=\"phone\" /><value value=\"555-555-2004\" /><use value=\"work\" /></telecom>"
|
||||
// + "<gender><coding><system value=\"http://hl7.org/fhir/v3/AdministrativeGender\" /><code value=\"M\" /></coding></gender>"
|
||||
// + "<address><use value=\"home\" /><line value=\"2222 Home Street\" /></address><active value=\"true\" />"
|
||||
// + "</Patient>"
|
||||
// + "</content>\n"
|
||||
// + " </entry>\n"
|
||||
// + "</feed>";
|
||||
// return msg;
|
||||
}
|
||||
|
||||
private interface ClientWithoutAnnotation extends IBasicClient {
|
||||
Patient read(@IdParam IdType theId);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public class GenericClientTest {
|
||||
}
|
||||
|
||||
private String getPatientFeedWithOneResult() {
|
||||
return ClientR4Test.getPatientFeedWithOneResult();
|
||||
return ClientR4Test.getPatientFeedWithOneResult(ourCtx);
|
||||
// //@formatter:off
|
||||
// String msg = "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n" +
|
||||
// "<title/>\n" +
|
||||
@ -221,6 +221,7 @@ public class GenericClientTest {
|
||||
count++;
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateWithTag() throws Exception {
|
||||
|
||||
@ -351,7 +352,6 @@ public class GenericClientTest {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHistory() throws Exception {
|
||||
|
||||
@ -436,8 +436,10 @@ public class GenericClientTest {
|
||||
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||
Header[] headers = new Header[] { new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"), new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
|
||||
new BasicHeader(Constants.HEADER_CATEGORY, "http://foo/tagdefinition.html; scheme=\"http://hl7.org/fhir/tag\"; label=\"Some tag\"") };
|
||||
Header[] headers = new Header[] {
|
||||
new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"),
|
||||
new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
|
||||
};
|
||||
when(myHttpResponse.getAllHeaders()).thenReturn(headers);
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
|
||||
@ -475,8 +477,10 @@ public class GenericClientTest {
|
||||
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||
Header[] headers = new Header[] { new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"), new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
|
||||
new BasicHeader(Constants.HEADER_CATEGORY, "http://foo/tagdefinition.html; scheme=\"http://hl7.org/fhir/tag\"; label=\"Some tag\"") };
|
||||
Header[] headers = new Header[] {
|
||||
new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"),
|
||||
new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
|
||||
};
|
||||
when(myHttpResponse.getAllHeaders()).thenReturn(headers);
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
|
||||
@ -519,8 +523,9 @@ public class GenericClientTest {
|
||||
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||
Header[] headers = new Header[] { new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"), new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
|
||||
new BasicHeader(Constants.HEADER_CATEGORY, "http://foo/tagdefinition.html; scheme=\"http://hl7.org/fhir/tag\"; label=\"Some tag\"") };
|
||||
Header[] headers = new Header[] { new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"),
|
||||
new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
|
||||
};
|
||||
when(myHttpResponse.getAllHeaders()).thenReturn(headers);
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
|
||||
@ -622,7 +627,6 @@ public class GenericClientTest {
|
||||
assertEquals("http://example.com/page1", capt.getValue().getURI().toString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSearchByCompartment() throws Exception {
|
||||
|
||||
@ -684,8 +688,7 @@ public class GenericClientTest {
|
||||
.forResource("Observation")
|
||||
.where(Observation.CODE_VALUE_DATE
|
||||
.withLeft(Observation.CODE.exactly().code("FOO$BAR"))
|
||||
.withRight(Observation.VALUE_DATE.exactly().day("2001-01-01"))
|
||||
)
|
||||
.withRight(Observation.VALUE_DATE.exactly().day("2001-01-01")))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
|
||||
@ -727,7 +730,8 @@ public class GenericClientTest {
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
|
||||
assertEquals("http://example.com/fhir/Patient?birthdate=le2012-01-22&birthdate=gt2011-01-01&_include=Patient%3Aorganization&_sort=birthdate%2C-name%2Caddress&_count=123&_format=json", capt.getAllValues().get(idx++).getURI().toString());
|
||||
assertEquals("http://example.com/fhir/Patient?birthdate=le2012-01-22&birthdate=gt2011-01-01&_include=Patient%3Aorganization&_sort=birthdate%2C-name%2Caddress&_count=123&_format=json",
|
||||
capt.getAllValues().get(idx++).getURI().toString());
|
||||
|
||||
response = client.search()
|
||||
.forResource(Patient.class)
|
||||
@ -742,7 +746,8 @@ public class GenericClientTest {
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
|
||||
assertEquals("http://example.com/fhir/Patient?birthdate=le2012-01-22&birthdate=gt2011-01-01&_include=Patient%3Aorganization&_sort=birthdate%2C-name%2Caddress&_count=123&_format=json", capt.getAllValues().get(idx++).getURI().toString());
|
||||
assertEquals("http://example.com/fhir/Patient?birthdate=le2012-01-22&birthdate=gt2011-01-01&_include=Patient%3Aorganization&_sort=birthdate%2C-name%2Caddress&_count=123&_format=json",
|
||||
capt.getAllValues().get(idx++).getURI().toString());
|
||||
|
||||
response = client.search()
|
||||
.forResource(Patient.class)
|
||||
@ -983,7 +988,6 @@ public class GenericClientTest {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Test
|
||||
public void testSearchByToken() throws Exception {
|
||||
@ -1222,7 +1226,6 @@ public class GenericClientTest {
|
||||
assertEquals(1, response.getEntry().size());
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Test
|
||||
public void testSearchWithClientEncodingAndPrettyPrintConfig() throws Exception {
|
||||
@ -1455,8 +1458,6 @@ public class GenericClientTest {
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testUpdate() throws Exception {
|
||||
|
||||
@ -1600,8 +1601,10 @@ public class GenericClientTest {
|
||||
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||
Header[] headers = new Header[] { new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"), new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
|
||||
new BasicHeader(Constants.HEADER_CATEGORY, "http://foo/tagdefinition.html; scheme=\"http://hl7.org/fhir/tag\"; label=\"Some tag\"") };
|
||||
Header[] headers = new Header[] {
|
||||
new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"),
|
||||
new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
|
||||
};
|
||||
when(myHttpResponse.getAllHeaders()).thenReturn(headers);
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
|
||||
@ -1622,7 +1625,6 @@ public class GenericClientTest {
|
||||
ourCtx = FhirContext.forR4();
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
|
@ -64,7 +64,7 @@ public class TransactionClientTest {
|
||||
obs.getCode().addCoding().setSystem("urn:system").setCode("testPersistWithSimpleLinkO01");
|
||||
obs.setSubject(new Reference("Patient/testPersistWithSimpleLinkP01"));
|
||||
|
||||
List<IBaseResource> resources = Arrays.asList((IResource) patient, obs);
|
||||
List<IBaseResource> resources = Arrays.asList((IBaseResource) patient, obs);
|
||||
|
||||
IClient client = ctx.newRestfulClient(IClient.class, "http://foo");
|
||||
|
||||
@ -123,7 +123,7 @@ public class TransactionClientTest {
|
||||
ourLog.info(ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(bundle));
|
||||
|
||||
assertEquals(2, bundle.getEntry().size());
|
||||
assertEquals("http://foo/Patient/testPersistWithSimpleLinkP01", bundle.getEntry().get(0).getIdElement().getValue());
|
||||
assertEquals("http://foo/Patient/testPersistWithSimpleLinkP01", bundle.getEntry().get(0).getResource().getIdElement().getValue());
|
||||
|
||||
assertTrue(bundle.getEntry().get(1).getId().isEmpty());
|
||||
|
||||
|
@ -554,9 +554,6 @@ public class Controller extends BaseController {
|
||||
} else {
|
||||
outcomeDescription = "Create Resource";
|
||||
ICreateTyped create = client.create().resource(body);
|
||||
if (isNotBlank(id)) {
|
||||
create.withId(id);
|
||||
}
|
||||
create.execute();
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,12 @@
|
||||
Schematron validator now applies invariants to resources within a Bundle, not
|
||||
just to the outer Bundle resource itself
|
||||
</action>
|
||||
<action type="fix">
|
||||
Server and Client both still included Category header for resource tags even though
|
||||
this feature was only present in FHIR DSTU1 and was removed from the specification in
|
||||
FHIR DSTU2. The presence of these headers sometimes caused parsed resource instances
|
||||
to contain duplicate tags
|
||||
</action>
|
||||
</release>
|
||||
<release version="2.6" date="TBD">
|
||||
<action type="add">
|
||||
|
Loading…
x
Reference in New Issue
Block a user