Continue work on removing deprecated API
This commit is contained in:
parent
defea69aa3
commit
0b513b0845
|
@ -3,7 +3,8 @@ package example;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import org.hl7.fhir.dstu3.model.Bundle;
|
||||
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
||||
|
|
|
@ -408,16 +408,6 @@ public class GenericClientExample {
|
|||
@SuppressWarnings("unused")
|
||||
public static void history() {
|
||||
IGenericClient client = FhirContext.forDstu2().newRestfulGenericClient("");
|
||||
{
|
||||
ca.uhn.fhir.model.api.Bundle response;
|
||||
// START SNIPPET: historyDstu1
|
||||
response = client
|
||||
.history()
|
||||
.onServer()
|
||||
.andReturnDstu1Bundle()
|
||||
.execute();
|
||||
// END SNIPPET: historyDstu1
|
||||
}
|
||||
{
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle response;
|
||||
// START SNIPPET: historyDstu2
|
||||
|
|
|
@ -1017,60 +1017,6 @@ public MethodOutcome createPatientResource(@ResourceParam Patient thePatient) {
|
|||
}
|
||||
//END SNIPPET: createTags
|
||||
|
||||
//START SNIPPET: tagMethodProvider
|
||||
public class TagMethodProvider
|
||||
{
|
||||
/** Return a list of all tags that exist on the server */
|
||||
@GetTags
|
||||
public TagList getAllTagsOnServer() {
|
||||
return new TagList(); // populate this
|
||||
}
|
||||
|
||||
/** Return a list of all tags that exist on at least one instance
|
||||
* of the given resource type */
|
||||
@GetTags(type=Patient.class)
|
||||
public TagList getTagsForAllResourcesOfResourceType() {
|
||||
return new TagList(); // populate this
|
||||
}
|
||||
|
||||
/** Return a list of all tags that exist on a specific instance
|
||||
* of the given resource type */
|
||||
@GetTags(type=Patient.class)
|
||||
public TagList getTagsForResources(@IdParam IdType theId) {
|
||||
return new TagList(); // populate this
|
||||
}
|
||||
|
||||
/** Return a list of all tags that exist on a specific version
|
||||
* of the given resource type */
|
||||
@GetTags(type=Patient.class)
|
||||
public TagList getTagsForResourceVersion(@IdParam IdType theId) {
|
||||
return new TagList(); // populate this
|
||||
}
|
||||
|
||||
/** Add tags to a resource */
|
||||
@AddTags(type=Patient.class)
|
||||
public void getTagsForResourceVersion(@IdParam IdType theId,
|
||||
@TagListParam TagList theTagList) {
|
||||
// add tags
|
||||
}
|
||||
|
||||
/** Add tags to a resource version */
|
||||
@AddTags(type=Patient.class)
|
||||
public void addTagsToResourceVersion(@IdParam IdType theId,
|
||||
@TagListParam TagList theTagList) {
|
||||
// add tags
|
||||
}
|
||||
|
||||
/** Remove tags from a resource */
|
||||
@DeleteTags(type=Patient.class)
|
||||
public void deleteTagsFromResourceVersion(@IdParam IdType theId,
|
||||
@TagListParam TagList theTagList) {
|
||||
// add tags
|
||||
}
|
||||
|
||||
}
|
||||
//END SNIPPET: tagMethodProvider
|
||||
|
||||
//START SNIPPET: transaction
|
||||
@Transaction
|
||||
public Bundle transaction(@TransactionParam Bundle theInput) {
|
||||
|
|
|
@ -15,8 +15,7 @@ import org.junit.Test;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.*;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
|
||||
|
||||
|
@ -77,7 +76,7 @@ public class BuiltJarDstu2IT {
|
|||
FhirContext ctx = FhirContext.forDstu2();
|
||||
try {
|
||||
IGenericClient client = ctx.newRestfulGenericClient("http://127.0.0.1:44442/SomeBase");
|
||||
client.conformance();
|
||||
client.capabilities().ofType(Conformance.class).execute();
|
||||
} catch (FhirClientConnectionException e) {
|
||||
// this is good
|
||||
}
|
||||
|
|
|
@ -13,8 +13,7 @@ import org.junit.Test;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.*;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
|
||||
|
||||
|
@ -66,7 +65,7 @@ public class BuiltJarDstu2ShadeIT {
|
|||
FhirContext ctx = FhirContext.forDstu2();
|
||||
try {
|
||||
IGenericClient client = ctx.newRestfulGenericClient("http://127.0.0.1:44442/SomeBase");
|
||||
client.conformance();
|
||||
client.capabilities().ofType(Conformance.class).execute()
|
||||
} catch (FhirClientConnectionException e) {
|
||||
// this is good
|
||||
}
|
||||
|
|
|
@ -12,20 +12,25 @@ import ca.uhn.fhir.rest.gclient.*;
|
|||
|
||||
public interface IGenericClient extends IRestfulClient {
|
||||
|
||||
/**
|
||||
* Fetch the capability statement for the server
|
||||
*/
|
||||
IFetchConformanceUntyped capabilities();
|
||||
|
||||
/**
|
||||
* Fluent method for the "create" operation, which creates a new resource instance on the server
|
||||
*/
|
||||
ICreate create();
|
||||
|
||||
|
||||
/**
|
||||
* Fluent method for the "delete" operation, which performs a logical delete on a server resource
|
||||
*/
|
||||
IDelete delete();
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the server's conformance statement
|
||||
*
|
||||
* @deprecated As of HAPI 3.0.0 this method has been deprecated, as the operation is now called "capabilities". Use {@link #capabilities()} instead
|
||||
*/
|
||||
IFetchConformanceUntyped fetchConformance();
|
||||
|
||||
|
@ -62,6 +67,11 @@ public interface IGenericClient extends IRestfulClient {
|
|||
*/
|
||||
IOperation operation();
|
||||
|
||||
/**
|
||||
* Fluent method for the "patch" operation, which performs a logical patch on a server resource
|
||||
*/
|
||||
IPatch patch();
|
||||
|
||||
/**
|
||||
* Fluent method for "read" and "vread" methods.
|
||||
*/
|
||||
|
@ -111,11 +121,6 @@ public interface IGenericClient extends IRestfulClient {
|
|||
@Override
|
||||
void registerInterceptor(IClientInterceptor theInterceptor);
|
||||
|
||||
/**
|
||||
* Fluent method for the "patch" operation, which performs a logical patch on a server resource
|
||||
*/
|
||||
IPatch patch();
|
||||
|
||||
/**
|
||||
* Search for resources matching a given set of criteria. Searching is a very powerful
|
||||
* feature in FHIR with many features for specifying exactly what should be seaerched for
|
||||
|
@ -142,7 +147,6 @@ public interface IGenericClient extends IRestfulClient {
|
|||
*/
|
||||
ITransaction transaction();
|
||||
|
||||
|
||||
/**
|
||||
* Remove an intercaptor that was previously registered using {@link IRestfulClient#registerInterceptor(IClientInterceptor)}
|
||||
*/
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -10,7 +10,7 @@ package ca.uhn.fhir.rest.client.impl;
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -99,7 +99,7 @@ public abstract class BaseClient implements IRestfulClient {
|
|||
myClient = theClient;
|
||||
myUrlBase = theUrlBase;
|
||||
myFactory = theFactory;
|
||||
|
||||
|
||||
/*
|
||||
* This property is used by unit tests - do not rely on it in production code
|
||||
* as it may change at any time. If you want to capture responses in a reliable
|
||||
|
@ -108,11 +108,11 @@ public abstract class BaseClient implements IRestfulClient {
|
|||
if ("true".equals(System.getProperty(HAPI_CLIENT_KEEPRESPONSES))) {
|
||||
setKeepResponses(true);
|
||||
}
|
||||
|
||||
|
||||
if (XmlUtil.isStaxPresent() == false) {
|
||||
myEncoding = EncodingEnum.JSON;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected Map<String, List<String>> createExtraParams() {
|
||||
|
@ -201,7 +201,8 @@ public abstract class BaseClient implements IRestfulClient {
|
|||
return invokeClient(theContext, binding, clientInvocation, null, null, theLogRequestAndResponse, null, null);
|
||||
}
|
||||
|
||||
<T> T invokeClient(FhirContext theContext, IClientResponseHandler<T> binding, BaseHttpClientInvocation clientInvocation, EncodingEnum theEncoding, Boolean thePrettyPrint, boolean theLogRequestAndResponse, SummaryEnum theSummaryMode, Set<String> theSubsetElements) {
|
||||
<T> T invokeClient(FhirContext theContext, IClientResponseHandler<T> binding, BaseHttpClientInvocation clientInvocation, EncodingEnum theEncoding, Boolean thePrettyPrint,
|
||||
boolean theLogRequestAndResponse, SummaryEnum theSummaryMode, Set<String> theSubsetElements) {
|
||||
|
||||
if (!myDontValidateConformance) {
|
||||
myFactory.validateServerBaseIfConfiguredToDoSo(myUrlBase, myClient, this);
|
||||
|
@ -221,7 +222,7 @@ public abstract class BaseClient implements IRestfulClient {
|
|||
params.put(Constants.PARAM_FORMAT, Collections.singletonList("json"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (theSummaryMode != null) {
|
||||
params.put(Constants.PARAM_SUMMARY, Collections.singletonList(theSummaryMode.getCode()));
|
||||
} else if (mySummary != null) {
|
||||
|
@ -342,10 +343,9 @@ public abstract class BaseClient implements IRestfulClient {
|
|||
|
||||
} catch (DataFormatException e) {
|
||||
String msg;
|
||||
if ( httpRequest != null ) {
|
||||
if (httpRequest != null) {
|
||||
msg = getFhirContext().getLocalizer().getMessage(BaseClient.class, "failedToParseResponse", httpRequest.getHttpVerbName(), httpRequest.getUri(), e.toString());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = getFhirContext().getLocalizer().getMessage(BaseClient.class, "failedToParseResponse", "UNKNOWN", "UNKNOWN", e.toString());
|
||||
}
|
||||
throw new FhirClientConnectionException(msg, e);
|
||||
|
@ -453,6 +453,7 @@ public abstract class BaseClient implements IRestfulClient {
|
|||
Validate.notNull(theInterceptor, "Interceptor can not be null");
|
||||
myInterceptors.remove(theInterceptor);
|
||||
}
|
||||
|
||||
static ArrayList<Class<? extends IBaseResource>> toTypeList(Class<? extends IBaseResource> thePreferResponseType) {
|
||||
ArrayList<Class<? extends IBaseResource>> preferResponseTypes = null;
|
||||
if (thePreferResponseType != null) {
|
||||
|
@ -489,7 +490,6 @@ public abstract class BaseClient implements IRestfulClient {
|
|||
this(theClass, thePreferResponseTypes, null, false);
|
||||
}
|
||||
|
||||
|
||||
public ResourceResponseHandler(Class<T> theReturnType, List<Class<? extends IBaseResource>> thePreferResponseTypes, IIdType theId, boolean theAllowHtmlResponse) {
|
||||
myReturnType = theReturnType;
|
||||
myId = theId;
|
||||
|
@ -507,7 +507,7 @@ public abstract class BaseClient implements IRestfulClient {
|
|||
throw NonFhirResponseException.newInstance(theResponseStatusCode, theResponseMimeType, theResponseReader);
|
||||
}
|
||||
IParser parser = respType.newParser(getFhirContext());
|
||||
parser.setServerBaseUrl(getUrlBase());
|
||||
parser.setServerBaseUrl(getUrlBase());
|
||||
if (myPreferResponseTypes != null) {
|
||||
parser.setPreferTypes(myPreferResponseTypes);
|
||||
}
|
||||
|
|
|
@ -71,6 +71,11 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
myContext = theContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFetchConformanceUntyped capabilities() {
|
||||
return new FetchConformanceInternal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICreate create() {
|
||||
return new CreateInternal();
|
||||
|
@ -125,11 +130,6 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFetchConformanceUntyped fetchConformance() {
|
||||
return new FetchConformanceInternal();
|
||||
}
|
||||
|
||||
// public IResource read(UriDt url) {
|
||||
// return read(inferResourceClass(url), url);
|
||||
// }
|
||||
|
@ -143,6 +143,11 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
// return search(inferResourceClass(url), url);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public IFetchConformanceUntyped fetchConformance() {
|
||||
return new FetchConformanceInternal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceConformanceCheck() {
|
||||
super.forceConformanceCheck();
|
||||
|
@ -164,16 +169,16 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
return theResource.getIdElement().getIdPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IHistory history() {
|
||||
return new HistoryInternal();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public <T extends IBaseResource> T read(final Class<T> theType, IdDt theId) {
|
||||
// return doReadOrVRead(theType, theId, false, null, null);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public IHistory history() {
|
||||
return new HistoryInternal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link LoggingInterceptor} as a client interceptor registered to your
|
||||
* client instead, as this provides much more fine-grained control over what is logged. This
|
||||
|
|
|
@ -10,7 +10,7 @@ package ca.uhn.fhir.rest.client.impl;
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -50,10 +50,10 @@ public abstract class RestfulClientFactory implements IRestfulClientFactory {
|
|||
private ServerValidationModeEnum myServerValidationMode = DEFAULT_SERVER_VALIDATION_MODE;
|
||||
private int mySocketTimeout = DEFAULT_SOCKET_TIMEOUT;
|
||||
private String myProxyUsername;
|
||||
private String myProxyPassword;
|
||||
private String myProxyPassword;
|
||||
private int myPoolMaxTotal = DEFAULT_POOL_MAX;
|
||||
private int myPoolMaxPerRoute = DEFAULT_POOL_MAX_PER_ROUTE;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
@ -64,7 +64,7 @@ public abstract class RestfulClientFactory implements IRestfulClientFactory {
|
|||
* Constructor
|
||||
*
|
||||
* @param theFhirContext
|
||||
* The context
|
||||
* The context
|
||||
*/
|
||||
public RestfulClientFactory(FhirContext theFhirContext) {
|
||||
myContext = theFhirContext;
|
||||
|
@ -82,26 +82,30 @@ public abstract class RestfulClientFactory implements IRestfulClientFactory {
|
|||
|
||||
/**
|
||||
* Return the proxy username to authenticate with the HTTP proxy
|
||||
* @param The proxy username
|
||||
*/
|
||||
*
|
||||
* @param The
|
||||
* proxy username
|
||||
*/
|
||||
protected String getProxyUsername() {
|
||||
return myProxyUsername;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the proxy password to authenticate with the HTTP proxy
|
||||
* @param The proxy password
|
||||
*/
|
||||
*
|
||||
* @param The
|
||||
* proxy password
|
||||
*/
|
||||
protected String getProxyPassword() {
|
||||
return myProxyPassword;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProxyCredentials(String theUsername, String thePassword) {
|
||||
myProxyUsername=theUsername;
|
||||
myProxyPassword=thePassword;
|
||||
myProxyUsername = theUsername;
|
||||
myProxyPassword = thePassword;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ServerValidationModeEnum getServerValidationMode() {
|
||||
return myServerValidationMode;
|
||||
|
@ -132,21 +136,21 @@ public abstract class RestfulClientFactory implements IRestfulClientFactory {
|
|||
* Instantiates a new client instance
|
||||
*
|
||||
* @param theClientType
|
||||
* The client type, which is an interface type to be instantiated
|
||||
* The client type, which is an interface type to be instantiated
|
||||
* @param theServerBase
|
||||
* The URL of the base for the restful FHIR server to connect to
|
||||
* The URL of the base for the restful FHIR server to connect to
|
||||
* @return A newly created client
|
||||
* @throws ConfigurationException
|
||||
* If the interface type is not an interface
|
||||
* If the interface type is not an interface
|
||||
*/
|
||||
@Override
|
||||
public synchronized <T extends IRestfulClient> T newClient(Class<T> theClientType, String theServerBase) {
|
||||
validateConfigured();
|
||||
|
||||
|
||||
if (!theClientType.isInterface()) {
|
||||
throw new ConfigurationException(theClientType.getCanonicalName() + " is not an interface");
|
||||
}
|
||||
|
||||
|
||||
ClientInvocationHandlerFactory invocationHandler = myInvocationHandlers.get(theClientType);
|
||||
if (invocationHandler == null) {
|
||||
IHttpClient httpClient = getHttpClient(theServerBase);
|
||||
|
@ -165,7 +169,7 @@ public abstract class RestfulClientFactory implements IRestfulClientFactory {
|
|||
|
||||
/**
|
||||
* Called automatically before the first use of this factory to ensure that
|
||||
* the configuration is sane. Subclasses may override, but should also call
|
||||
* the configuration is sane. Subclasses may override, but should also call
|
||||
* <code>super.validateConfigured()</code>
|
||||
*/
|
||||
protected void validateConfigured() {
|
||||
|
@ -178,11 +182,10 @@ public abstract class RestfulClientFactory implements IRestfulClientFactory {
|
|||
public synchronized IGenericClient newGenericClient(String theServerBase) {
|
||||
validateConfigured();
|
||||
IHttpClient httpClient = getHttpClient(theServerBase);
|
||||
|
||||
|
||||
return new GenericClient(myContext, httpClient, theServerBase, this);
|
||||
}
|
||||
|
||||
|
||||
private String normalizeBaseUrlForMap(String theServerBase) {
|
||||
String serverBase = theServerBase;
|
||||
if (!serverBase.endsWith("/")) {
|
||||
|
@ -212,10 +215,11 @@ public abstract class RestfulClientFactory implements IRestfulClientFactory {
|
|||
}
|
||||
myContext = theContext;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the fhir context
|
||||
* @return the fhir context
|
||||
*
|
||||
* @return the fhir context
|
||||
*/
|
||||
public FhirContext getFhirContext() {
|
||||
return myContext;
|
||||
|
@ -245,19 +249,18 @@ public abstract class RestfulClientFactory implements IRestfulClientFactory {
|
|||
resetHttpClient();
|
||||
}
|
||||
|
||||
|
||||
@Deprecated //override deprecated method
|
||||
@Deprecated // override deprecated method
|
||||
@Override
|
||||
public ServerValidationModeEnum getServerValidationModeEnum() {
|
||||
return getServerValidationMode();
|
||||
}
|
||||
|
||||
@Deprecated //override deprecated method
|
||||
@Deprecated // override deprecated method
|
||||
@Override
|
||||
public void setServerValidationModeEnum(ServerValidationModeEnum theServerValidationMode) {
|
||||
setServerValidationMode(theServerValidationMode);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void validateServerBaseIfConfiguredToDoSo(String theServerBase, IHttpClient theHttpClient, IRestfulClient theClient) {
|
||||
String serverBase = normalizeBaseUrlForMap(theServerBase);
|
||||
|
@ -283,14 +286,14 @@ public abstract class RestfulClientFactory implements IRestfulClientFactory {
|
|||
client.registerInterceptor(interceptor);
|
||||
}
|
||||
client.setDontValidateConformance(true);
|
||||
|
||||
|
||||
IBaseResource conformance;
|
||||
try {
|
||||
String capabilityStatementResourceName = "CapabilityStatement";
|
||||
if (myContext.getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) {
|
||||
capabilityStatementResourceName = "Conformance";
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
Class implementingClass;
|
||||
try {
|
||||
|
@ -329,10 +332,10 @@ public abstract class RestfulClientFactory implements IRestfulClientFactory {
|
|||
if (StringUtils.isBlank(serverFhirVersionString)) {
|
||||
// we'll be lenient and accept this
|
||||
} else {
|
||||
if (serverFhirVersionString.startsWith("0.4")) {
|
||||
serverFhirVersionEnum = FhirVersionEnum.DSTU2;
|
||||
} else if (serverFhirVersionString.startsWith("0.5")) {
|
||||
if (serverFhirVersionString.startsWith("0.4") || serverFhirVersionString.startsWith("0.5") || serverFhirVersionString.startsWith("1.0.")) {
|
||||
serverFhirVersionEnum = FhirVersionEnum.DSTU2;
|
||||
} else if (serverFhirVersionString.startsWith("3.")) {
|
||||
serverFhirVersionEnum = FhirVersionEnum.DSTU3;
|
||||
} else {
|
||||
// we'll be lenient and accept this
|
||||
ourLog.debug("Server conformance statement indicates unknown FHIR version: {}", serverFhirVersionString);
|
||||
|
@ -342,22 +345,24 @@ public abstract class RestfulClientFactory implements IRestfulClientFactory {
|
|||
if (serverFhirVersionEnum != null) {
|
||||
FhirVersionEnum contextFhirVersion = myContext.getVersion().getVersion();
|
||||
if (!contextFhirVersion.isEquivalentTo(serverFhirVersionEnum)) {
|
||||
throw new FhirClientInappropriateForServerException(myContext.getLocalizer().getMessage(RestfulClientFactory.class, "wrongVersionInConformance", theServerBase + Constants.URL_TOKEN_METADATA, serverFhirVersionString, serverFhirVersionEnum, contextFhirVersion));
|
||||
throw new FhirClientInappropriateForServerException(myContext.getLocalizer().getMessage(RestfulClientFactory.class, "wrongVersionInConformance",
|
||||
theServerBase + Constants.URL_TOKEN_METADATA, serverFhirVersionString, serverFhirVersionEnum, contextFhirVersion));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
myValidatedServerBaseUrls.add(normalizeBaseUrlForMap(theServerBase));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the http client for the given server base
|
||||
* @param theServerBase the server base
|
||||
*
|
||||
* @param theServerBase
|
||||
* the server base
|
||||
* @return the http client
|
||||
*/
|
||||
protected abstract IHttpClient getHttpClient(String theServerBase);
|
||||
|
||||
|
||||
/**
|
||||
* Reset the http client. This method is used when parameters have been set and a
|
||||
* new http client needs to be created
|
||||
|
|
|
@ -109,6 +109,11 @@
|
|||
<artifactId>jersey-media-moxy</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.google.common.collect.*;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.RandomServerPortProvider;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
||||
|
@ -61,7 +60,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
private String getPatientFeedWithOneResult() {
|
||||
//@formatter:off
|
||||
|
||||
String msg = "<Bundle xmlns=\"http://hl7.org/fhir\">\n" +
|
||||
"<id>d039f91a-cc3c-4013-988e-af4d8d0614bd</id>\n" +
|
||||
"<entry>\n" +
|
||||
|
@ -77,7 +76,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
+ "</resource>\n"
|
||||
+ " </entry>\n"
|
||||
+ "</Bundle>";
|
||||
//@formatter:on
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
@ -189,12 +188,8 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
|
||||
Conformance resp = client.capabilities().ofType(Conformance.class).execute();
|
||||
|
||||
//@formatter:off
|
||||
Conformance resp = (Conformance)client.conformance();
|
||||
|
||||
//@formatter:on
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/metadata", ourRequestUri);
|
||||
assertEquals("COPY", resp.getCopyright());
|
||||
assertEquals("GET", ourRequestMethod);
|
||||
|
@ -292,27 +287,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testCreateNonFluent() throws Exception {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
|
||||
|
||||
Patient p = new Patient();
|
||||
p.addName().addFamily("FOOFAMILY");
|
||||
|
||||
client.create(p);
|
||||
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_CONTENT_TYPE).size());
|
||||
assertEquals(EncodingEnum.XML.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, ourRequestFirstHeaders.get(Constants.HEADER_CONTENT_TYPE).getValue().replace(";char", "; char"));
|
||||
assertThat(ourRequestBodyString, containsString("<family value=\"FOOFAMILY\"/>"));
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient", ourRequestUri);
|
||||
assertEquals("POST", ourRequestMethod);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreatePrefer() throws Exception {
|
||||
|
@ -387,25 +362,18 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testDeleteNonFluent() throws Exception {
|
||||
public void testDelete() throws Exception {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
|
||||
|
||||
client.delete(Patient.class, new IdDt("Patient/123"));
|
||||
client.delete().resourceById(new IdDt("Patient/123")).execute();
|
||||
assertEquals("DELETE", ourRequestMethod);
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/123", ourRequestUri);
|
||||
|
||||
|
||||
client.delete(Patient.class, "123");
|
||||
assertEquals("DELETE", ourRequestMethod);
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/123", ourRequestUri);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -421,18 +389,18 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle response;
|
||||
|
||||
//@formatter:off
|
||||
|
||||
response = client
|
||||
.history()
|
||||
.onServer()
|
||||
.andReturnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/_history", ourRequestUri);
|
||||
assertEquals(1, response.getEntry().size());
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
response = client
|
||||
.history()
|
||||
.onServer()
|
||||
|
@ -440,46 +408,46 @@ public class GenericJaxRsClientDstu2Test {
|
|||
.since((Date)null)
|
||||
.count(null)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/_history", ourRequestUri);
|
||||
assertEquals(1, response.getEntry().size());
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
response = client
|
||||
.history()
|
||||
.onServer()
|
||||
.andReturnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.since(new InstantDt())
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/_history", ourRequestUri);
|
||||
assertEquals(1, response.getEntry().size());
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
response = client
|
||||
.history()
|
||||
.onType(Patient.class)
|
||||
.andReturnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/_history", ourRequestUri);
|
||||
assertEquals(1, response.getEntry().size());
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
response = client
|
||||
.history()
|
||||
.onInstance(new IdDt("Patient", "123"))
|
||||
.andReturnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/123/_history", ourRequestUri);
|
||||
assertEquals(1, response.getEntry().size());
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
response = client
|
||||
.history()
|
||||
.onInstance(new IdDt("Patient", "123"))
|
||||
|
@ -487,19 +455,19 @@ public class GenericJaxRsClientDstu2Test {
|
|||
.count(123)
|
||||
.since(new InstantDt("2001-01-02T11:22:33Z"))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertThat(ourRequestUri, either(equalTo("http://localhost:" + ourPort + "/fhir/Patient/123/_history?_since=2001-01-02T11:22:33Z&_count=123")).or(equalTo("http://localhost:" + ourPort + "/fhir/Patient/123/_history?_count=123&_since=2001-01-02T11:22:33Z")));
|
||||
assertEquals(1, response.getEntry().size());
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
response = client
|
||||
.history()
|
||||
.onInstance(new IdDt("Patient", "123"))
|
||||
.andReturnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.since(new InstantDt("2001-01-02T11:22:33Z").getValue())
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertThat(ourRequestUri, containsString("_since=2001-01"));
|
||||
assertEquals(1, response.getEntry().size());
|
||||
|
||||
|
@ -522,14 +490,14 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
MetaDt resp = client
|
||||
.meta()
|
||||
.add()
|
||||
.onResource(new IdDt("Patient/123"))
|
||||
.meta(inMeta)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/123/$meta-add", ourRequestUri);
|
||||
assertEquals("urn:profile:out", resp.getProfile().get(0).getValue());
|
||||
assertEquals("POST", ourRequestMethod);
|
||||
|
@ -556,37 +524,37 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
MetaDt resp = client
|
||||
.meta()
|
||||
.get(MetaDt.class)
|
||||
.fromServer()
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/$meta", ourRequestUri);
|
||||
assertEquals("urn:profile:out", resp.getProfile().get(0).getValue());
|
||||
assertEquals("GET", ourRequestMethod);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
resp = client
|
||||
.meta()
|
||||
.get(MetaDt.class)
|
||||
.fromType("Patient")
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/$meta", ourRequestUri);
|
||||
assertEquals("urn:profile:out", resp.getProfile().get(0).getValue());
|
||||
assertEquals("GET", ourRequestMethod);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
resp = client
|
||||
.meta()
|
||||
.get(MetaDt.class)
|
||||
.fromResource(new IdDt("Patient/123"))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/123/$meta", ourRequestUri);
|
||||
assertEquals("urn:profile:out", resp.getProfile().get(0).getValue());
|
||||
assertEquals("GET", ourRequestMethod);
|
||||
|
@ -618,7 +586,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
Parameters resp = client
|
||||
.operation()
|
||||
.onServer()
|
||||
|
@ -626,13 +594,13 @@ public class GenericJaxRsClientDstu2Test {
|
|||
.withParameters(inParams)
|
||||
.useHttpGet()
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/$SOMEOPERATION?param1=STRINGVALIN1¶m1=STRINGVALIN1b¶m2=STRINGVALIN2", ourRequestUri);
|
||||
assertEquals(respString, p.encodeResourceToString(resp));
|
||||
assertEquals("GET", ourRequestMethod);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
resp = client
|
||||
.operation()
|
||||
.onType(Patient.class)
|
||||
|
@ -640,13 +608,13 @@ public class GenericJaxRsClientDstu2Test {
|
|||
.withParameters(inParams)
|
||||
.useHttpGet()
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/$SOMEOPERATION?param1=STRINGVALIN1¶m1=STRINGVALIN1b¶m2=STRINGVALIN2", ourRequestUri);
|
||||
assertEquals(respString, p.encodeResourceToString(resp));
|
||||
assertEquals("GET", ourRequestMethod);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
resp = client
|
||||
.operation()
|
||||
.onInstance(new IdDt("Patient", "123"))
|
||||
|
@ -654,7 +622,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
.withParameters(inParams)
|
||||
.useHttpGet()
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/123/$SOMEOPERATION?param1=STRINGVALIN1¶m1=STRINGVALIN1b¶m2=STRINGVALIN2", ourRequestUri);
|
||||
assertEquals(respString, p.encodeResourceToString(resp));
|
||||
assertEquals("GET", ourRequestMethod);
|
||||
|
@ -689,7 +657,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
Parameters resp = client
|
||||
.operation()
|
||||
.onServer()
|
||||
|
@ -697,13 +665,13 @@ public class GenericJaxRsClientDstu2Test {
|
|||
.withNoParameters(Parameters.class)
|
||||
.useHttpGet()
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/$SOMEOPERATION", ourRequestUri);
|
||||
assertEquals(respString, p.encodeResourceToString(resp));
|
||||
assertEquals("GET", ourRequestMethod);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
resp = client
|
||||
.operation()
|
||||
.onType(Patient.class)
|
||||
|
@ -711,13 +679,13 @@ public class GenericJaxRsClientDstu2Test {
|
|||
.withNoParameters(Parameters.class)
|
||||
.useHttpGet()
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/$SOMEOPERATION", ourRequestUri);
|
||||
assertEquals(respString, p.encodeResourceToString(resp));
|
||||
assertEquals("GET", ourRequestMethod);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
resp = client
|
||||
.operation()
|
||||
.onInstance(new IdDt("Patient", "123"))
|
||||
|
@ -725,7 +693,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
.withNoParameters(Parameters.class)
|
||||
.useHttpGet()
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/123/$SOMEOPERATION", ourRequestUri);
|
||||
assertEquals(respString, p.encodeResourceToString(resp));
|
||||
assertEquals("GET", ourRequestMethod);
|
||||
|
@ -794,13 +762,13 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
Parameters resp = client
|
||||
.operation()
|
||||
.onServer()
|
||||
.named("$SOMEOPERATION")
|
||||
.withParameters(inParams).execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/$SOMEOPERATION", ourRequestUri);
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_CONTENT_TYPE).size());
|
||||
assertEquals(EncodingEnum.XML.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, ourRequestFirstHeaders.get(Constants.HEADER_CONTENT_TYPE).getValue().replace(";char", "; char"));
|
||||
|
@ -827,7 +795,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
Parameters resp = client
|
||||
.operation()
|
||||
.onServer()
|
||||
|
@ -835,7 +803,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
.withParameter(Parameters.class, "name1", new StringDt("value1"))
|
||||
.andParameter("name2", new StringDt("value1"))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/$SOMEOPERATION", ourRequestUri);
|
||||
assertEquals(respString, p.encodeResourceToString(resp));
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_CONTENT_TYPE).size());
|
||||
|
@ -848,7 +816,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
* Composite type
|
||||
*/
|
||||
|
||||
//@formatter:off
|
||||
|
||||
resp = client
|
||||
.operation()
|
||||
.onServer()
|
||||
|
@ -856,7 +824,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
.withParameter(Parameters.class, "name1", new IdentifierDt("system1", "value1"))
|
||||
.andParameter("name2", new StringDt("value1"))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/$SOMEOPERATION", ourRequestUri);
|
||||
assertEquals(respString, p.encodeResourceToString(resp));
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_CONTENT_TYPE).size());
|
||||
|
@ -870,7 +838,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
* Resource
|
||||
*/
|
||||
|
||||
//@formatter:off
|
||||
|
||||
resp = client
|
||||
.operation()
|
||||
.onServer()
|
||||
|
@ -878,7 +846,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
.withParameter(Parameters.class, "name1", new IdentifierDt("system1", "value1"))
|
||||
.andParameter("name2", new Patient().setActive(true))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/$SOMEOPERATION", ourRequestUri);
|
||||
assertEquals(respString, p.encodeResourceToString(resp));
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_CONTENT_TYPE).size());
|
||||
|
@ -920,14 +888,14 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
};
|
||||
|
||||
//@formatter:off
|
||||
|
||||
client
|
||||
.operation()
|
||||
.onServer()
|
||||
.named("$SOMEOPERATION")
|
||||
.withParameter(Parameters.class, "name1", weirdBase)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -949,7 +917,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
client
|
||||
.operation()
|
||||
.onInstance(new IdDt("http://foo/Patient/1"))
|
||||
|
@ -958,11 +926,11 @@ public class GenericJaxRsClientDstu2Test {
|
|||
.andParameter("system", new UriDt("http://loinc.org"))
|
||||
.useHttpGet()
|
||||
.execute();
|
||||
//@formatter:off
|
||||
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/1/$validate-code?code=8495-4&system=http%3A%2F%2Floinc.org", ourRequestUri);
|
||||
|
||||
//@formatter:off
|
||||
|
||||
|
||||
client
|
||||
.operation()
|
||||
|
@ -971,7 +939,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
.withParameter(Parameters.class, "code", new CodeDt("8495-4"))
|
||||
.andParameter("system", new UriDt("http://loinc.org"))
|
||||
.execute();
|
||||
//@formatter:off
|
||||
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/1/$validate-code", ourRequestUri);
|
||||
ourLog.info(ourRequestBodyString);
|
||||
|
@ -1003,13 +971,13 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
Parameters resp = client
|
||||
.operation()
|
||||
.onServer()
|
||||
.named("$SOMEOPERATION")
|
||||
.withParameters(inParams).execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/$SOMEOPERATION", ourRequestUri);
|
||||
assertEquals(respString, p.encodeResourceToString(resp));
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_CONTENT_TYPE).size());
|
||||
|
@ -1018,13 +986,13 @@ public class GenericJaxRsClientDstu2Test {
|
|||
assertEquals("POST", ourRequestMethod);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
resp = client
|
||||
.operation()
|
||||
.onType(Patient.class)
|
||||
.named("$SOMEOPERATION")
|
||||
.withParameters(inParams).execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/$SOMEOPERATION", ourRequestUri);
|
||||
assertEquals(respString, p.encodeResourceToString(resp));
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_CONTENT_TYPE).size());
|
||||
|
@ -1033,13 +1001,13 @@ public class GenericJaxRsClientDstu2Test {
|
|||
assertEquals("POST", ourRequestMethod);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
resp = client
|
||||
.operation()
|
||||
.onInstance(new IdDt("Patient", "123"))
|
||||
.named("$SOMEOPERATION")
|
||||
.withParameters(inParams).execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/123/$SOMEOPERATION", ourRequestUri);
|
||||
assertEquals(respString, p.encodeResourceToString(resp));
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_CONTENT_TYPE).size());
|
||||
|
@ -1076,13 +1044,13 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
Parameters resp = client
|
||||
.operation()
|
||||
.onServer()
|
||||
.named("$SOMEOPERATION")
|
||||
.withNoParameters(Parameters.class).execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/$SOMEOPERATION", ourRequestUri);
|
||||
assertEquals(respString, p.encodeResourceToString(resp));
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_CONTENT_TYPE).size());
|
||||
|
@ -1091,13 +1059,13 @@ public class GenericJaxRsClientDstu2Test {
|
|||
assertEquals("POST", ourRequestMethod);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
resp = client
|
||||
.operation()
|
||||
.onType(Patient.class)
|
||||
.named("$SOMEOPERATION")
|
||||
.withNoParameters(Parameters.class).execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/$SOMEOPERATION", ourRequestUri);
|
||||
assertEquals(respString, p.encodeResourceToString(resp));
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_CONTENT_TYPE).size());
|
||||
|
@ -1106,13 +1074,13 @@ public class GenericJaxRsClientDstu2Test {
|
|||
assertEquals("POST", ourRequestMethod);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
resp = client
|
||||
.operation()
|
||||
.onInstance(new IdDt("Patient", "123"))
|
||||
.named("$SOMEOPERATION")
|
||||
.withNoParameters(Parameters.class).execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/123/$SOMEOPERATION", ourRequestUri);
|
||||
assertEquals(respString, p.encodeResourceToString(resp));
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_CONTENT_TYPE).size());
|
||||
|
@ -1147,12 +1115,12 @@ public class GenericJaxRsClientDstu2Test {
|
|||
sourceBundle.getLinkOrCreate(IBaseBundle.LINK_PREV).setUrl("http://localhost:" + ourPort + "/fhir/prev");
|
||||
sourceBundle.getLinkOrCreate(IBaseBundle.LINK_NEXT).setUrl("http://localhost:" + ourPort + "/fhir/next");
|
||||
|
||||
//@formatter:off
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle resp = client
|
||||
.loadPage()
|
||||
.next(sourceBundle)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
|
||||
assertEquals(1, resp.getEntry().size());
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/next", ourRequestUri);
|
||||
|
@ -1187,12 +1155,12 @@ public class GenericJaxRsClientDstu2Test {
|
|||
ca.uhn.fhir.model.dstu2.resource.Bundle sourceBundle = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
||||
sourceBundle.getLinkOrCreate("previous").setUrl("http://localhost:" + ourPort + "/fhir/prev");
|
||||
|
||||
//@formatter:off
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle resp = client
|
||||
.loadPage()
|
||||
.previous(sourceBundle)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
|
||||
assertEquals(1, resp.getEntry().size());
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/prev", ourRequestUri);
|
||||
|
@ -1205,12 +1173,12 @@ public class GenericJaxRsClientDstu2Test {
|
|||
sourceBundle = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
||||
sourceBundle.getLinkOrCreate("prev").setUrl("http://localhost:" + ourPort + "/fhir/prev");
|
||||
|
||||
//@formatter:off
|
||||
|
||||
resp = client
|
||||
.loadPage()
|
||||
.previous(sourceBundle)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
|
||||
assertEquals(1, resp.getEntry().size());
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/prev", ourRequestUri);
|
||||
|
@ -1260,7 +1228,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
@Test
|
||||
public void testReadUpdatedHeaderDoesntOverwriteResourceValue() throws Exception {
|
||||
|
||||
//@formatter:off
|
||||
|
||||
final String input = "<Bundle xmlns=\"http://hl7.org/fhir\">\n" +
|
||||
" <id value=\"e2ee823b-ee4d-472d-b79d-495c23f16b99\"/>\n" +
|
||||
" <meta>\n" +
|
||||
|
@ -1274,7 +1242,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
" <url value=\"http://localhost:58109/fhir/context/Patient?_pretty=true\"/>\n" +
|
||||
" </link>\n" +
|
||||
"</Bundle>";
|
||||
//@formatter:on
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1286,13 +1254,11 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle response;
|
||||
|
||||
//@formatter:off
|
||||
response = client
|
||||
.search()
|
||||
.forResource(Patient.class)
|
||||
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("2015-06-22T15:48:57.554-04:00", ResourceMetadataKeyEnum.UPDATED.get(response).getValueAsString());
|
||||
}
|
||||
|
@ -1309,13 +1275,11 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
//@formatter:off
|
||||
IBaseResource response = client.read()
|
||||
.resource("Patient")
|
||||
.withId("123")
|
||||
.elementsSubset("name", "identifier")
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertThat(ourRequestUri, either(equalTo("http://localhost:" + ourPort + "/fhir/Patient/123?_elements=name%2Cidentifier")).or(equalTo("http://localhost:" + ourPort + "/fhir/Patient/123?_elements=identifier%2Cname")));
|
||||
assertEquals(Patient.class, response.getClass());
|
||||
|
@ -1335,7 +1299,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
//@formatter:off
|
||||
|
||||
try {
|
||||
client.read()
|
||||
.resource(Patient.class)
|
||||
|
@ -1346,7 +1310,6 @@ public class GenericJaxRsClientDstu2Test {
|
|||
} catch (InvalidResponseException e) {
|
||||
assertThat(e.getMessage(), containsString("String does not appear to be valid"));
|
||||
}
|
||||
//@formatter:on
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1362,13 +1325,11 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
//@formatter:off
|
||||
Patient response = client.read()
|
||||
.resource(Patient.class)
|
||||
.withId("123")
|
||||
.summaryMode(SummaryEnum.TEXT)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/123?_summary=text", ourRequestUri);
|
||||
assertEquals(Patient.class, response.getClass());
|
||||
|
@ -1389,15 +1350,14 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
//@formatter:off
|
||||
Bundle response = client.search()
|
||||
.forResource("Patient")
|
||||
.where(Patient.NAME.matches().value("james"))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient?name=james", ourRequestUri);
|
||||
assertEquals(Patient.class, response.getEntries().get(0).getResource().getClass());
|
||||
assertEquals(Patient.class, response.getEntry().get(0).getResource().getClass());
|
||||
|
||||
}
|
||||
|
||||
|
@ -1415,55 +1375,55 @@ public class GenericJaxRsClientDstu2Test {
|
|||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle response = client.search()
|
||||
.byUrl("http://localhost:" + ourPort + "/AAA?name=http://foo|bar")
|
||||
.encodedJson()
|
||||
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/AAA?name=http%3A//foo%7Cbar&_format=json", ourRequestUri);
|
||||
assertNotNull(response);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
response = client.search()
|
||||
.byUrl("Patient?name=http://foo|bar")
|
||||
.encodedJson()
|
||||
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient?name=http%3A//foo%7Cbar&_format=json", ourRequestUri);
|
||||
assertNotNull(response);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
response = client.search()
|
||||
.byUrl("/Patient?name=http://foo|bar")
|
||||
.encodedJson()
|
||||
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient?name=http%3A//foo%7Cbar&_format=json", ourRequestUri);
|
||||
assertNotNull(response);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
response = client.search()
|
||||
.byUrl("Patient")
|
||||
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient", ourRequestUri);
|
||||
assertNotNull(response);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
|
||||
response = client.search()
|
||||
.byUrl("Patient?")
|
||||
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient", ourRequestUri);
|
||||
assertNotNull(response);
|
||||
|
||||
|
@ -1490,13 +1450,13 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
//@formatter:off
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle response = client.search()
|
||||
.forResource("Observation")
|
||||
.where(Patient.NAME.matches().value("FOO"))
|
||||
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
|
||||
Link link = response.getLink().get(0);
|
||||
assertEquals("just trying add link", link.getRelation());
|
||||
|
@ -1521,16 +1481,17 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
//@formatter:off
|
||||
|
||||
Bundle response = client.search()
|
||||
.forResource("Patient")
|
||||
.where(Patient.NAME.matches().value("james"))
|
||||
.elementsSubset("name", "identifier")
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
|
||||
assertThat(ourRequestUri, either(equalTo("http://localhost:" + ourPort + "/fhir/Patient?name=james&_elements=name%2Cidentifier")).or(equalTo("http://localhost:" + ourPort + "/fhir/Patient?name=james&_elements=identifier%2Cname")));
|
||||
assertEquals(Patient.class, response.getEntries().get(0).getResource().getClass());
|
||||
assertEquals(Patient.class, response.getEntry().get(0).getResource().getClass());
|
||||
|
||||
}
|
||||
|
||||
|
@ -1547,21 +1508,22 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
//@formatter:off
|
||||
|
||||
Bundle response = client.search()
|
||||
.forResource("Patient")
|
||||
.where(Patient.NAME.matches().value("james"))
|
||||
.elementsSubset("name", "identifier")
|
||||
.usingStyle(SearchStyleEnum.POST)
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/_search?_elements=identifier%2Cname", ourRequestUri);
|
||||
|
||||
// assertThat(ourRequestUri,
|
||||
// either(equalTo("http://localhost:" + ourPort + "/fhir/Patient?name=james&_elements=name%2Cidentifier")).or(equalTo("http://localhost:" + ourPort + "/fhir/Patient?name=james&_elements=identifier%2Cname")));
|
||||
|
||||
assertEquals(Patient.class, response.getEntries().get(0).getResource().getClass());
|
||||
assertEquals(Patient.class, response.getEntry().get(0).getResource().getClass());
|
||||
|
||||
assertEquals("name=james", ourRequestBodyString);
|
||||
|
||||
|
@ -1583,15 +1545,16 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
//@formatter:off
|
||||
|
||||
Bundle response = client.search()
|
||||
.forResource("Patient")
|
||||
.where(Patient.NAME.matches().value("james"))
|
||||
.elementsSubset("name", "identifier")
|
||||
.usingStyle(SearchStyleEnum.POST)
|
||||
.encodedJson()
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
|
||||
assertThat(ourRequestUri, containsString("http://localhost:" + ourPort + "/fhir/Patient/_search?"));
|
||||
assertThat(ourRequestUri, containsString("_elements=identifier%2Cname"));
|
||||
|
@ -1599,7 +1562,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
// assertThat(ourRequestUri,
|
||||
// either(equalTo("http://localhost:" + ourPort + "/fhir/Patient?name=james&_elements=name%2Cidentifier")).or(equalTo("http://localhost:" + ourPort + "/fhir/Patient?name=james&_elements=identifier%2Cname")));
|
||||
|
||||
assertEquals(Patient.class, response.getEntries().get(0).getResource().getClass());
|
||||
assertEquals(Patient.class, response.getEntry().get(0).getResource().getClass());
|
||||
|
||||
assertEquals("name=james", ourRequestBodyString);
|
||||
|
||||
|
@ -1620,16 +1583,17 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
//@formatter:off
|
||||
|
||||
Bundle response = client.search()
|
||||
.forResource("Patient")
|
||||
.where(Patient.NAME.matches().value("james"))
|
||||
.returnBundle(Bundle.class)
|
||||
.lastUpdated(new DateRangeParam("2011-01-01", "2012-01-01"))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient?name=james&_lastUpdated=ge2011-01-01&_lastUpdated=le2012-01-01", ourRequestUri);
|
||||
assertEquals(Patient.class, response.getEntries().get(0).getResource().getClass());
|
||||
assertEquals(Patient.class, response.getEntry().get(0).getResource().getClass());
|
||||
|
||||
}
|
||||
|
||||
|
@ -1646,18 +1610,19 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
//@formatter:off
|
||||
|
||||
Bundle response = client.search()
|
||||
.forResource("Patient")
|
||||
.withProfile("http://foo1")
|
||||
.withProfile("http://foo2")
|
||||
.withSecurity("system1", "code1")
|
||||
.withSecurity("system2", "code2")
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient?_security=system1%7Ccode1&_security=system2%7Ccode2&_profile=http%3A%2F%2Ffoo1&_profile=http%3A%2F%2Ffoo2", ourRequestUri);
|
||||
assertEquals(Patient.class, response.getEntries().get(0).getResource().getClass());
|
||||
assertEquals(Patient.class, response.getEntry().get(0).getResource().getClass());
|
||||
|
||||
}
|
||||
|
||||
|
@ -1676,13 +1641,14 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
//@formatter:off
|
||||
|
||||
Bundle response = client.search()
|
||||
.forResource(Patient.class)
|
||||
.encodedJson()
|
||||
.revInclude(new Include("Provenance:target"))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient?_revinclude=Provenance%3Atarget&_format=json", ourRequestUri);
|
||||
|
||||
|
@ -1701,16 +1667,17 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
//@formatter:off
|
||||
|
||||
Bundle response = client.search()
|
||||
.forResource("Patient")
|
||||
.where(Patient.NAME.matches().value("james"))
|
||||
.summaryMode(SummaryEnum.FALSE)
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient?name=james&_summary=false", ourRequestUri);
|
||||
assertEquals(Patient.class, response.getEntries().get(0).getResource().getClass());
|
||||
assertEquals(Patient.class, response.getEntry().get(0).getResource().getClass());
|
||||
|
||||
}
|
||||
|
||||
|
@ -1741,12 +1708,12 @@ public class GenericJaxRsClientDstu2Test {
|
|||
p2.setId("Patient/2");
|
||||
input.add(p2);
|
||||
|
||||
//@formatter:off
|
||||
|
||||
List<IBaseResource> response = client.transaction()
|
||||
.withResources(input)
|
||||
.encodedJson()
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir", ourRequestUri);
|
||||
assertEquals(2, response.size());
|
||||
|
@ -1791,22 +1758,22 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
//@formatter:off
|
||||
|
||||
String response = client.transaction()
|
||||
.withBundle(reqString)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/", ourRequestUri);
|
||||
assertThat(response, containsString("\"Bundle\""));
|
||||
assertEquals("application/json+fhir;charset=UTF-8", ourRequestFirstHeaders.get("Content-Type").getValue());
|
||||
|
||||
//@formatter:off
|
||||
|
||||
response = client.transaction()
|
||||
.withBundle(reqString)
|
||||
.encodedXml()
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/", ourRequestUri);
|
||||
assertEquals("application/xml+fhir;charset=UTF-8", ourRequestFirstHeaders.get("Content-Type").getValue());
|
||||
|
@ -1840,12 +1807,12 @@ public class GenericJaxRsClientDstu2Test {
|
|||
p2.setId("Patient/2");
|
||||
input.addEntry().setResource(p2);
|
||||
|
||||
//@formatter:off
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle response = client.transaction()
|
||||
.withBundle(input)
|
||||
.encodedJson()
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir", ourRequestUri);
|
||||
assertEquals(2, response.getEntry().size());
|
||||
|
@ -2059,9 +2026,9 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
MethodOutcome response;
|
||||
|
||||
//@formatter:off
|
||||
|
||||
response = client.validate(p);
|
||||
//@formatter:on
|
||||
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/$validate", ourRequestUri);
|
||||
assertEquals("POST", ourRequestMethod);
|
||||
|
|
|
@ -288,9 +288,8 @@ public class GenericJaxRsClientDstu3Test {
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testCreateNonFluent() throws Exception {
|
||||
public void testCreate2() throws Exception {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
@ -300,7 +299,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
Patient p = new Patient();
|
||||
p.addName().setFamily("FOOFAMILY");
|
||||
|
||||
client.create(p);
|
||||
client.create().resource(p).execute();
|
||||
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_CONTENT_TYPE).size());
|
||||
assertEquals(EncodingEnum.XML.getResourceContentTypeNonLegacy() + Constants.HEADER_SUFFIX_CT_UTF_8, ourRequestFirstHeaders.get(Constants.HEADER_CONTENT_TYPE).getValue().replace(";char", "; char"));
|
||||
|
@ -392,16 +391,10 @@ public class GenericJaxRsClientDstu3Test {
|
|||
|
||||
|
||||
|
||||
client.delete(Patient.class, new IdType("Patient/123").getValue());
|
||||
client.delete().resourceById(new IdType("Patient/123")).execute();
|
||||
assertEquals("DELETE", ourRequestMethod);
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/123", ourRequestUri);
|
||||
|
||||
|
||||
client.delete(Patient.class, "123");
|
||||
assertEquals("DELETE", ourRequestMethod);
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/123", ourRequestUri);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.hl7.fhir.instance.model.api.IBaseBinary;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Binary;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
|
|
|
@ -203,9 +203,9 @@ public class JaxRsPatientProviderDstu3Test {
|
|||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
client.delete(Patient.class, patient.getId());
|
||||
client.delete().resourceById(patient.getIdElement()).execute();
|
||||
try {
|
||||
client.read(Patient.class, patient.getId());
|
||||
client.read().resource(Patient.class).withId(patient.getId()).execute();
|
||||
fail();
|
||||
}
|
||||
catch (final Exception e) {
|
||||
|
|
|
@ -14,9 +14,9 @@ import org.junit.Test;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.client.JaxRsRestfulClientFactory;
|
||||
import ca.uhn.fhir.model.api.BundleEntry;
|
||||
import ca.uhn.fhir.model.dstu2.composite.HumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.*;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry;
|
||||
import ca.uhn.fhir.model.primitive.*;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntryTransactionMethodEnum;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
|
@ -29,7 +29,7 @@ public class JaxRsPatientProviderTest {
|
|||
|
||||
private static IGenericClient client;
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static final String PATIENT_NAME = "Van Houte";
|
||||
private static final String PATIENT_NAME = "Van Houte";
|
||||
private static int ourPort;
|
||||
private static Server jettyServer;
|
||||
|
||||
|
@ -72,234 +72,236 @@ public class JaxRsPatientProviderTest {
|
|||
throws Exception {
|
||||
try {
|
||||
jettyServer.destroy();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Search/Query - Type */
|
||||
@Test
|
||||
public void findUsingGenericClientBySearch() {
|
||||
// Perform a search
|
||||
final ca.uhn.fhir.model.api.Bundle results = client.search().forResource(Patient.class)
|
||||
.where(Patient.NAME.matchesExactly().value(PATIENT_NAME)).execute();
|
||||
System.out.println(results.getEntries().get(0));
|
||||
assertEquals(results.getEntries().size(), 1);
|
||||
}
|
||||
/** Search/Query - Type */
|
||||
@Test
|
||||
public void findUsingGenericClientBySearch() {
|
||||
// Perform a search
|
||||
final Bundle results = client
|
||||
.search()
|
||||
.forResource(Patient.class)
|
||||
.where(Patient.NAME.matchesExactly().value(PATIENT_NAME))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
System.out.println(results.getEntry().get(0));
|
||||
assertEquals(results.getEntry().size(), 1);
|
||||
}
|
||||
|
||||
/** Search - Multi-valued Parameters (ANY/OR) */
|
||||
@Test
|
||||
public void findUsingGenericClientBySearchWithMultiValues() {
|
||||
final ca.uhn.fhir.model.api.Bundle response = client.search().forResource(Patient.class)
|
||||
.where(Patient.ADDRESS.matches().values("Toronto")).and(Patient.ADDRESS.matches().values("Ontario"))
|
||||
.and(Patient.ADDRESS.matches().values("Canada"))
|
||||
.where(Patient.IDENTIFIER.exactly().systemAndIdentifier("SHORTNAME", "TOYS")).execute();
|
||||
System.out.println(response.getEntries().get(0));
|
||||
}
|
||||
/** Search - Multi-valued Parameters (ANY/OR) */
|
||||
@Test
|
||||
public void findUsingGenericClientBySearchWithMultiValues() {
|
||||
final Bundle response = client
|
||||
.search()
|
||||
.forResource(Patient.class)
|
||||
.where(Patient.ADDRESS.matches().values("Toronto")).and(Patient.ADDRESS.matches().values("Ontario"))
|
||||
.and(Patient.ADDRESS.matches().values("Canada"))
|
||||
.where(Patient.IDENTIFIER.exactly().systemAndIdentifier("SHORTNAME", "TOYS"))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
System.out.println(response.getEntry().get(0));
|
||||
}
|
||||
|
||||
/** Search - Paging */
|
||||
@Test
|
||||
public void findWithPaging() {
|
||||
// Perform a search
|
||||
final Bundle results = client.search().forResource(Patient.class).limitTo(8).returnBundle(Bundle.class).execute();
|
||||
System.out.println(results.getEntry().size());
|
||||
/** Search - Paging */
|
||||
@Test
|
||||
public void findWithPaging() {
|
||||
// Perform a search
|
||||
final Bundle results = client.search().forResource(Patient.class).limitTo(8).returnBundle(Bundle.class).execute();
|
||||
System.out.println(results.getEntry().size());
|
||||
|
||||
if (results.getLink(Bundle.LINK_NEXT) != null) {
|
||||
if (results.getLink(Bundle.LINK_NEXT) != null) {
|
||||
|
||||
// load next page
|
||||
final Bundle nextPage = client.loadPage().next(results).execute();
|
||||
System.out.println(nextPage.getEntry().size());
|
||||
}
|
||||
}
|
||||
|
||||
/** Search using other query options */
|
||||
public void testOther() {
|
||||
//missing
|
||||
}
|
||||
|
||||
/** */
|
||||
@Test
|
||||
public void testSearchPost() {
|
||||
Bundle response = client.search()
|
||||
.forResource("Patient")
|
||||
.usingStyle(SearchStyleEnum.POST)
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
assertTrue(response.getEntry().size() > 0);
|
||||
}
|
||||
|
||||
/** Search - Compartments */
|
||||
@Test
|
||||
public void testSearchCompartements() {
|
||||
Bundle response = client.search()
|
||||
.forResource(Patient.class)
|
||||
.withIdAndCompartment("1", "Condition")
|
||||
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
assertTrue(response.getEntry().size() > 0);
|
||||
}
|
||||
|
||||
/** Search - Subsetting (_summary and _elements) */
|
||||
@Test
|
||||
@Ignore
|
||||
public void testSummary() {
|
||||
client.search()
|
||||
.forResource(Patient.class)
|
||||
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreatePatient() {
|
||||
final Patient existing = new Patient();
|
||||
existing.setId((IdDt) null);
|
||||
existing.getNameFirstRep().addFamily("Created Patient 54");
|
||||
client.setEncoding(EncodingEnum.JSON);
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
System.out.println(patient);
|
||||
assertNotNull(client.read(patient.getId()));
|
||||
client.setEncoding(EncodingEnum.JSON);
|
||||
}
|
||||
|
||||
|
||||
/** Conditional Creates */
|
||||
@Test
|
||||
public void testConditionalCreate() {
|
||||
final Patient existing = new Patient();
|
||||
existing.setId((IdDt) null);
|
||||
existing.getNameFirstRep().addFamily("Created Patient 54");
|
||||
client.setEncoding(EncodingEnum.XML);
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
// load next page
|
||||
final Bundle nextPage = client.loadPage().next(results).execute();
|
||||
System.out.println(nextPage.getEntry().size());
|
||||
}
|
||||
}
|
||||
|
||||
client.create()
|
||||
.resource(patient)
|
||||
.conditional()
|
||||
.where(Patient.IDENTIFIER.exactly().identifier(patient.getIdentifierFirstRep()))
|
||||
.execute();
|
||||
}
|
||||
|
||||
|
||||
/** Find By Id */
|
||||
@Test
|
||||
public void findUsingGenericClientById() {
|
||||
final Patient results = client.read(Patient.class, "1");
|
||||
assertEquals(results.getId().getIdPartAsLong().longValue(), 1L);
|
||||
}
|
||||
/** Search using other query options */
|
||||
public void testOther() {
|
||||
// missing
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateById() {
|
||||
final Patient existing = client.read(Patient.class, "1");
|
||||
final List<HumanNameDt> name = existing.getName();
|
||||
name.get(0).addSuffix("The Second");
|
||||
existing.setName(name);
|
||||
client.setEncoding(EncodingEnum.XML);
|
||||
final MethodOutcome results = client.update("1", existing);
|
||||
}
|
||||
/** */
|
||||
@Test
|
||||
public void testSearchPost() {
|
||||
Bundle response = client.search()
|
||||
.forResource("Patient")
|
||||
.usingStyle(SearchStyleEnum.POST)
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
assertTrue(response.getEntry().size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeletePatient() {
|
||||
final Patient existing = new Patient();
|
||||
existing.getNameFirstRep().addFamily("Created Patient XYZ");
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
client.delete(Patient.class, patient.getId());
|
||||
try {
|
||||
client.read(patient.getId());
|
||||
fail();
|
||||
}
|
||||
catch (final Exception e) {
|
||||
//assertEquals(e.getStatusCode(), Constants.STATUS_HTTP_404_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
/** Transaction - Server */
|
||||
@Ignore
|
||||
@Test
|
||||
public void testTransaction() {
|
||||
ca.uhn.fhir.model.api.Bundle bundle = new ca.uhn.fhir.model.api.Bundle();
|
||||
BundleEntry entry = bundle.addEntry();
|
||||
final Patient existing = new Patient();
|
||||
existing.getNameFirstRep().addFamily("Created with bundle");
|
||||
entry.setResource(existing);
|
||||
|
||||
BoundCodeDt<BundleEntryTransactionMethodEnum> theTransactionOperation =
|
||||
new BoundCodeDt(
|
||||
BundleEntryTransactionMethodEnum.VALUESET_BINDER,
|
||||
BundleEntryTransactionMethodEnum.POST);
|
||||
entry.setTransactionMethod(theTransactionOperation);
|
||||
ca.uhn.fhir.model.api.Bundle response = client.transaction().withBundle(bundle).execute();
|
||||
}
|
||||
|
||||
/** Conformance - Server */
|
||||
@Test
|
||||
@Ignore
|
||||
public void testConformance() {
|
||||
final Conformance conf = client.fetchConformance().ofType(Conformance.class).execute();
|
||||
System.out.println(conf.getRest().get(0).getResource().get(0).getType());
|
||||
assertEquals(conf.getRest().get(0).getResource().get(0).getType().toString(), "Patient");
|
||||
}
|
||||
|
||||
/** Extended Operations */
|
||||
// Create a client to talk to the HeathIntersections server
|
||||
@Test
|
||||
public void testExtendedOperations() {
|
||||
client.registerInterceptor(new LoggingInterceptor(true));
|
||||
|
||||
// Create the input parameters to pass to the server
|
||||
Parameters inParams = new Parameters();
|
||||
inParams.addParameter().setName("start").setValue(new DateDt("2001-01-01"));
|
||||
inParams.addParameter().setName("end").setValue(new DateDt("2015-03-01"));
|
||||
inParams.addParameter().setName("dummy").setValue(new StringDt("myAwesomeDummyValue"));
|
||||
|
||||
// Invoke $everything on "Patient/1"
|
||||
Parameters outParams = client
|
||||
.operation()
|
||||
.onInstance(new IdDt("Patient", "1"))
|
||||
.named("$firstVersion")
|
||||
.withParameters(inParams)
|
||||
//.useHttpGet() // Use HTTP GET instead of POST
|
||||
.execute();
|
||||
String resultValue = outParams.getParameter().get(0).getValue().toString();
|
||||
System.out.println(resultValue);
|
||||
assertEquals("expected but found : "+ resultValue, resultValue.contains("myAwesomeDummyValue"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtendedOperationsUsingGet() {
|
||||
// Create the input parameters to pass to the server
|
||||
Parameters inParams = new Parameters();
|
||||
inParams.addParameter().setName("start").setValue(new DateDt("2001-01-01"));
|
||||
inParams.addParameter().setName("end").setValue(new DateDt("2015-03-01"));
|
||||
inParams.addParameter().setName("dummy").setValue(new StringDt("myAwesomeDummyValue"));
|
||||
|
||||
// Invoke $everything on "Patient/1"
|
||||
Parameters outParams = client
|
||||
.operation()
|
||||
.onInstance(new IdDt("Patient", "1"))
|
||||
.named("$firstVersion")
|
||||
.withParameters(inParams)
|
||||
.useHttpGet() // Use HTTP GET instead of POST
|
||||
.execute();
|
||||
String resultValue = outParams.getParameter().get(0).getValue().toString();
|
||||
System.out.println(resultValue);
|
||||
assertEquals("expected but found : "+ resultValue, resultValue.contains("myAwesomeDummyValue"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVRead() {
|
||||
final Patient patient = client.vread(Patient.class, "1", "1");
|
||||
System.out.println(patient);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRead() {
|
||||
final Patient patient = client.read(Patient.class, "1");
|
||||
System.out.println(patient);
|
||||
}
|
||||
/** Search - Compartments */
|
||||
@Test
|
||||
public void testSearchCompartements() {
|
||||
Bundle response = client.search()
|
||||
.forResource(Patient.class)
|
||||
.withIdAndCompartment("1", "Condition")
|
||||
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
assertTrue(response.getEntry().size() > 0);
|
||||
}
|
||||
|
||||
/** Search - Subsetting (_summary and _elements) */
|
||||
@Test
|
||||
@Ignore
|
||||
public void testSummary() {
|
||||
client.search()
|
||||
.forResource(Patient.class)
|
||||
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreatePatient() {
|
||||
final Patient existing = new Patient();
|
||||
existing.setId((IdDt) null);
|
||||
existing.getNameFirstRep().addFamily("Created Patient 54");
|
||||
client.setEncoding(EncodingEnum.JSON);
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
System.out.println(patient);
|
||||
assertNotNull(client.read(patient.getId()));
|
||||
client.setEncoding(EncodingEnum.JSON);
|
||||
}
|
||||
|
||||
/** Conditional Creates */
|
||||
@Test
|
||||
public void testConditionalCreate() {
|
||||
final Patient existing = new Patient();
|
||||
existing.setId((IdDt) null);
|
||||
existing.getNameFirstRep().addFamily("Created Patient 54");
|
||||
client.setEncoding(EncodingEnum.XML);
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
|
||||
client.create()
|
||||
.resource(patient)
|
||||
.conditional()
|
||||
.where(Patient.IDENTIFIER.exactly().identifier(patient.getIdentifierFirstRep()))
|
||||
.execute();
|
||||
}
|
||||
|
||||
/** Find By Id */
|
||||
@Test
|
||||
public void findUsingGenericClientById() {
|
||||
final Patient results = client.read(Patient.class, "1");
|
||||
assertEquals(results.getId().getIdPartAsLong().longValue(), 1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateById() {
|
||||
final Patient existing = client.read(Patient.class, "1");
|
||||
final List<HumanNameDt> name = existing.getName();
|
||||
name.get(0).addSuffix("The Second");
|
||||
existing.setName(name);
|
||||
client.setEncoding(EncodingEnum.XML);
|
||||
final MethodOutcome results = client.update("1", existing);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeletePatient() {
|
||||
final Patient existing = new Patient();
|
||||
existing.getNameFirstRep().addFamily("Created Patient XYZ");
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
client.delete().resourceById(patient.getId()).execute();
|
||||
try {
|
||||
client.read(patient.getId());
|
||||
fail();
|
||||
} catch (final Exception e) {
|
||||
// assertEquals(e.getStatusCode(), Constants.STATUS_HTTP_404_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
/** Transaction - Server */
|
||||
@Ignore
|
||||
@Test
|
||||
public void testTransaction() {
|
||||
Bundle bundle = new Bundle();
|
||||
Entry entry = bundle.addEntry();
|
||||
final Patient existing = new Patient();
|
||||
existing.getNameFirstRep().addFamily("Created with bundle");
|
||||
entry.setResource(existing);
|
||||
|
||||
BoundCodeDt<BundleEntryTransactionMethodEnum> theTransactionOperation = new BoundCodeDt(
|
||||
BundleEntryTransactionMethodEnum.VALUESET_BINDER,
|
||||
BundleEntryTransactionMethodEnum.POST);
|
||||
Bundle response = client.transaction().withBundle(bundle).execute();
|
||||
}
|
||||
|
||||
/** Conformance - Server */
|
||||
@Test
|
||||
@Ignore
|
||||
public void testConformance() {
|
||||
final Conformance conf = client.fetchConformance().ofType(Conformance.class).execute();
|
||||
System.out.println(conf.getRest().get(0).getResource().get(0).getType());
|
||||
assertEquals(conf.getRest().get(0).getResource().get(0).getType().toString(), "Patient");
|
||||
}
|
||||
|
||||
/** Extended Operations */
|
||||
// Create a client to talk to the HeathIntersections server
|
||||
@Test
|
||||
public void testExtendedOperations() {
|
||||
client.registerInterceptor(new LoggingInterceptor(true));
|
||||
|
||||
// Create the input parameters to pass to the server
|
||||
Parameters inParams = new Parameters();
|
||||
inParams.addParameter().setName("start").setValue(new DateDt("2001-01-01"));
|
||||
inParams.addParameter().setName("end").setValue(new DateDt("2015-03-01"));
|
||||
inParams.addParameter().setName("dummy").setValue(new StringDt("myAwesomeDummyValue"));
|
||||
|
||||
// Invoke $everything on "Patient/1"
|
||||
Parameters outParams = client
|
||||
.operation()
|
||||
.onInstance(new IdDt("Patient", "1"))
|
||||
.named("$firstVersion")
|
||||
.withParameters(inParams)
|
||||
// .useHttpGet() // Use HTTP GET instead of POST
|
||||
.execute();
|
||||
String resultValue = outParams.getParameter().get(0).getValue().toString();
|
||||
System.out.println(resultValue);
|
||||
assertEquals("expected but found : " + resultValue, resultValue.contains("myAwesomeDummyValue"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtendedOperationsUsingGet() {
|
||||
// Create the input parameters to pass to the server
|
||||
Parameters inParams = new Parameters();
|
||||
inParams.addParameter().setName("start").setValue(new DateDt("2001-01-01"));
|
||||
inParams.addParameter().setName("end").setValue(new DateDt("2015-03-01"));
|
||||
inParams.addParameter().setName("dummy").setValue(new StringDt("myAwesomeDummyValue"));
|
||||
|
||||
// Invoke $everything on "Patient/1"
|
||||
Parameters outParams = client
|
||||
.operation()
|
||||
.onInstance(new IdDt("Patient", "1"))
|
||||
.named("$firstVersion")
|
||||
.withParameters(inParams)
|
||||
.useHttpGet() // Use HTTP GET instead of POST
|
||||
.execute();
|
||||
String resultValue = outParams.getParameter().get(0).getValue().toString();
|
||||
System.out.println(resultValue);
|
||||
assertEquals("expected but found : " + resultValue, resultValue.contains("myAwesomeDummyValue"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVRead() {
|
||||
final Patient patient = client.vread(Patient.class, "1", "1");
|
||||
System.out.println(patient);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRead() {
|
||||
final Patient patient = client.read(Patient.class, "1");
|
||||
System.out.println(patient);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,23 +1,7 @@
|
|||
package ca.uhn.fhir.jpa.provider;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.containsInRelativeOrder;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.emptyString;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.hasItems;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
@ -45,7 +29,6 @@ import ca.uhn.fhir.model.dstu2.resource.*;
|
|||
import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.*;
|
||||
import ca.uhn.fhir.model.primitive.*;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
|
@ -1607,7 +1590,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
.encodedXml()
|
||||
.execute();
|
||||
assertThat(returned.getEntry().size(), greaterThan(1));
|
||||
assertEquals(BundleTypeEnum.SEARCHSET, returned.getTypeElement().getValueAsEnum());
|
||||
assertEquals(ca.uhn.fhir.model.dstu2.valueset.BundleTypeEnum.SEARCH_RESULTS, returned.getTypeElement().getValueAsEnum());
|
||||
}
|
||||
{
|
||||
Bundle returned = ourClient
|
||||
|
@ -2064,13 +2047,12 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
|
||||
assertEquals(2, found.getEntry().size());
|
||||
assertEquals(Patient.class, found.getEntry().get(0).getResource().getClass());
|
||||
assertEquals(BundleEntrySearchModeEnum.MATCH, found.getEntry().get(0).getSearch().getModeElement().getValueAsEnum());
|
||||
assertEquals(BundleEntrySearchModeEnum.MATCH, found.getEntry().get(0).getResource().getResourceMetadata().get(ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE));
|
||||
assertEquals(SearchEntryModeEnum.MATCH, found.getEntry().get(0).getSearch().getModeElement().getValueAsEnum());
|
||||
assertThat(found.getEntry().get(0).getResource().getText().getDiv().getValueAsString(), containsString("<table class=\"hapiPropertyTable"));
|
||||
assertEquals(Organization.class, found.getEntry().get(1).getResource().getClass());
|
||||
assertEquals(BundleEntrySearchModeEnum.INCLUDE, found.getEntry().get(1).getSearch().getModeElement().getValueAsEnum());
|
||||
assertEquals(BundleEntrySearchModeEnum.INCLUDE, found.getEntry().get(1).getResource().getResourceMetadata().get(ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE));
|
||||
assertEquals(SearchEntryModeEnum.INCLUDE, found.getEntry().get(1).getSearch().getModeElement().getValueAsEnum());
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = InvalidRequestException.class)
|
||||
public void testSearchWithInvalidSort() throws Exception {
|
||||
|
|
|
@ -257,7 +257,7 @@ public class ClientServerValidationDstu2Test {
|
|||
@Test
|
||||
public void testServerReturnsWrongVersionForDstu2() throws Exception {
|
||||
Conformance conf = new Conformance();
|
||||
conf.setFhirVersion("0.80");
|
||||
conf.setFhirVersion("3.0.1");
|
||||
String msg = myCtx.newXmlParser().encodeResourceToString(conf);
|
||||
|
||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||
|
@ -274,7 +274,7 @@ public class ClientServerValidationDstu2Test {
|
|||
fail();
|
||||
} catch (FhirClientInappropriateForServerException e) {
|
||||
String out = e.toString();
|
||||
String want = "The server at base URL \"http://foo/metadata\" returned a conformance statement indicating that it supports FHIR version \"0.80\" which corresponds to DSTU1, but this client is configured to use DSTU2 (via the FhirContext)";
|
||||
String want = "The server at base URL \"http://foo/metadata\" returned a conformance statement indicating that it supports FHIR version \"3.0.1\" which corresponds to DSTU3, but this client is configured to use DSTU2 (via the FhirContext)";
|
||||
ourLog.info(out);
|
||||
ourLog.info(want);
|
||||
assertThat(out, containsString(want));
|
||||
|
|
|
@ -21,7 +21,7 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
|
@ -51,7 +51,7 @@ public class BundleTypeInResponseTest {
|
|||
|
||||
Bundle bundle = ourCtx.newXmlParser().parseResource(Bundle.class, responseContent);
|
||||
assertEquals(1, bundle.getEntry().size());
|
||||
assertEquals(BundleTypeEnum.SEARCHSET, bundle.getTypeElement().getValueAsEnum());
|
||||
assertEquals(BundleTypeEnum.SEARCH_RESULTS, bundle.getTypeElement().getValueAsEnum());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@ import ca.uhn.fhir.model.api.Include;
|
|||
import ca.uhn.fhir.model.api.annotation.*;
|
||||
import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.*;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.SearchEntryModeEnum;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum;
|
||||
import ca.uhn.fhir.rest.annotation.*;
|
||||
import ca.uhn.fhir.util.*;
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class IncludeDstu2Test {
|
|||
assertEquals(new IdDt("Patient/p1"), BundleUtil.toListOfResources(ourCtx, bundle).get(0).getIdElement().toUnqualifiedVersionless());
|
||||
assertEquals(new IdDt("Patient/p2"), BundleUtil.toListOfResources(ourCtx, bundle).get(1).getIdElement().toUnqualifiedVersionless());
|
||||
assertEquals(new IdDt("Organization/o1"), BundleUtil.toListOfResources(ourCtx, bundle).get(2).getIdElement().toUnqualifiedVersionless());
|
||||
assertEquals(BundleEntrySearchModeEnum.INCLUDE, bundle.getEntry().get(2).getSearch().getModeElement().getValueAsEnum());
|
||||
assertEquals(SearchEntryModeEnum.INCLUDE, bundle.getEntry().get(2).getSearch().getModeElement().getValueAsEnum());
|
||||
|
||||
Patient p1 = (Patient) BundleUtil.toListOfResources(ourCtx, bundle).get(0);
|
||||
assertEquals(0, p1.getContained().getContainedResources().size());
|
||||
|
@ -96,8 +96,8 @@ public class IncludeDstu2Test {
|
|||
assertEquals(new IdDt("Patient/p2"), BundleUtil.toListOfResources(ourCtx, bundle).get(1).getIdElement().toUnqualifiedVersionless());
|
||||
assertEquals(new IdDt("Organization/o1"), BundleUtil.toListOfResources(ourCtx, bundle).get(2).getIdElement().toUnqualifiedVersionless());
|
||||
assertEquals(new IdDt("Organization/o2"), BundleUtil.toListOfResources(ourCtx, bundle).get(3).getIdElement().toUnqualifiedVersionless());
|
||||
assertEquals(BundleEntrySearchModeEnum.INCLUDE, bundle.getEntry().get(2).getSearch().getModeElement().getValueAsEnum());
|
||||
assertEquals(BundleEntrySearchModeEnum.INCLUDE, bundle.getEntry().get(3).getSearch().getModeElement().getValueAsEnum());
|
||||
assertEquals(SearchEntryModeEnum.INCLUDE, bundle.getEntry().get(2).getSearch().getModeElement().getValueAsEnum());
|
||||
assertEquals(SearchEntryModeEnum.INCLUDE, bundle.getEntry().get(3).getSearch().getModeElement().getValueAsEnum());
|
||||
|
||||
Patient p1 = (Patient) BundleUtil.toListOfResources(ourCtx, bundle).get(0);
|
||||
assertEquals(0, p1.getContained().getContainedResources().size());
|
||||
|
@ -123,7 +123,7 @@ public class IncludeDstu2Test {
|
|||
assertEquals(new IdDt("Patient/p1"), BundleUtil.toListOfResources(ourCtx, bundle).get(0).getIdElement().toUnqualifiedVersionless());
|
||||
assertEquals(new IdDt("Patient/p2"), BundleUtil.toListOfResources(ourCtx, bundle).get(1).getIdElement().toUnqualifiedVersionless());
|
||||
assertEquals(new IdDt("Organization/o1"), BundleUtil.toListOfResources(ourCtx, bundle).get(2).getIdElement().toUnqualifiedVersionless());
|
||||
assertEquals(BundleEntrySearchModeEnum.INCLUDE, bundle.getEntry().get(2).getSearch().getModeElement().getValueAsEnum());
|
||||
assertEquals(SearchEntryModeEnum.INCLUDE, bundle.getEntry().get(2).getSearch().getModeElement().getValueAsEnum());
|
||||
|
||||
Patient p1 = (Patient) BundleUtil.toListOfResources(ourCtx, bundle).get(0);
|
||||
assertEquals(0, p1.getContained().getContainedResources().size());
|
||||
|
@ -149,7 +149,7 @@ public class IncludeDstu2Test {
|
|||
assertEquals(new IdDt("Patient/p1"), BundleUtil.toListOfResources(ourCtx, bundle).get(0).getIdElement().toUnqualifiedVersionless());
|
||||
assertEquals(new IdDt("Patient/p2"), BundleUtil.toListOfResources(ourCtx, bundle).get(1).getIdElement().toUnqualifiedVersionless());
|
||||
assertEquals(new IdDt("Organization/o1"), BundleUtil.toListOfResources(ourCtx, bundle).get(2).getIdElement().toUnqualifiedVersionless());
|
||||
assertEquals(BundleEntrySearchModeEnum.INCLUDE, bundle.getEntry().get(2).getSearch().getModeElement().getValueAsEnum());
|
||||
assertEquals(SearchEntryModeEnum.INCLUDE, bundle.getEntry().get(2).getSearch().getModeElement().getValueAsEnum());
|
||||
|
||||
Patient p1 = (Patient) BundleUtil.toListOfResources(ourCtx, bundle).get(0);
|
||||
assertEquals(0, p1.getContained().getContainedResources().size());
|
||||
|
|
|
@ -295,10 +295,10 @@ public class SearchDstu3Test {
|
|||
.search()
|
||||
.forResource(Patient.class)
|
||||
.where(new StringClientParam("foo").matches().value("bar"))
|
||||
.encodedJson()
|
||||
.prettyPrint()
|
||||
.usingStyle(SearchStyleEnum.POST)
|
||||
.returnBundle(org.hl7.fhir.dstu3.model.Bundle.class)
|
||||
.encodedJson()
|
||||
.execute();
|
||||
fail();
|
||||
} catch (InvalidRequestException e) {
|
||||
|
|
|
@ -142,7 +142,8 @@ public class OperationClientR4Test {
|
|||
assertEquals("sys|val", ((StringType) request.getParameter().get(1).getValue()).getValue());
|
||||
}
|
||||
|
||||
public interface IOpClient extends IBasicClient {
|
||||
|
||||
public interface IOpClient extends IBasicClient {
|
||||
|
||||
@Operation(name = "$andlist", idempotent = true)
|
||||
public Parameters andlist(
|
||||
|
|
|
@ -31,165 +31,30 @@ import ca.uhn.fhir.rest.annotation.Count;
|
|||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.SortOrderEnum;
|
||||
import ca.uhn.fhir.rest.api.SortSpec;
|
||||
import ca.uhn.fhir.rest.client.api.IRestfulClient;
|
||||
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.client.api.*;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
|
||||
public class SearchClientR4Test {
|
||||
|
||||
private FhirContext ourCtx;
|
||||
private HttpClient ourHttpClient;
|
||||
private HttpResponse ourHttpResponse;
|
||||
private FhirContext ourCtx;
|
||||
private HttpClient ourHttpClient;
|
||||
private HttpResponse ourHttpResponse;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
@Before
|
||||
public void before() {
|
||||
ourCtx = FhirContext.forR4();
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
ourCtx = FhirContext.forR4();
|
||||
ourHttpClient = mock(HttpClient.class, new ReturnsDeepStubs());
|
||||
ourCtx.getRestfulClientFactory().setHttpClient(ourHttpClient);
|
||||
ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
|
||||
|
||||
ourHttpClient = mock(HttpClient.class, new ReturnsDeepStubs());
|
||||
ourCtx.getRestfulClientFactory().setHttpClient(ourHttpClient);
|
||||
ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
|
||||
ourHttpResponse = mock(HttpResponse.class, new ReturnsDeepStubs());
|
||||
}
|
||||
|
||||
ourHttpResponse = mock(HttpResponse.class, new ReturnsDeepStubs());
|
||||
}
|
||||
|
||||
/**
|
||||
* See #299
|
||||
*/
|
||||
@Test
|
||||
public void testListResponseWithSearchExtension() throws Exception {
|
||||
|
||||
final String response = createBundleWithSearchExtension();
|
||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||
when(ourHttpClient.execute(capt.capture())).thenReturn(ourHttpResponse);
|
||||
when(ourHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(ourHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(ourHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
|
||||
@Override
|
||||
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
||||
return new ReaderInputStream(new StringReader(response), Charset.forName("UTF-8"));
|
||||
}
|
||||
});
|
||||
|
||||
ILocationClient client = ourCtx.newRestfulClient(ILocationClient.class, "http://localhost:8081/hapi-fhir/fhir");
|
||||
|
||||
List<Location> matches = client.getMatches(new StringParam("smith"), 100);
|
||||
assertEquals(1, matches.size());
|
||||
assertEquals("Sample Clinic", matches.get(0).getName());
|
||||
|
||||
HttpGet value = (HttpGet) capt.getValue();
|
||||
assertEquals("http://localhost:8081/hapi-fhir/fhir/Location?_query=match&name=smith&_count=100", value.getURI().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* See #371
|
||||
*/
|
||||
@Test
|
||||
public void testSortForDstu3() throws Exception {
|
||||
|
||||
final String response = createBundleWithSearchExtension();
|
||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||
when(ourHttpClient.execute(capt.capture())).thenReturn(ourHttpResponse);
|
||||
when(ourHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(ourHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(ourHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
|
||||
@Override
|
||||
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
||||
return new ReaderInputStream(new StringReader(response), Charset.forName("UTF-8"));
|
||||
}
|
||||
});
|
||||
|
||||
ILocationClient client = ourCtx.newRestfulClient(ILocationClient.class, "http://localhost/fhir");
|
||||
|
||||
int idx = 0;
|
||||
|
||||
client.search(new SortSpec("param1", SortOrderEnum.ASC));
|
||||
assertEquals("http://localhost/fhir/Bundle?_sort=param1", ((HttpGet) capt.getAllValues().get(idx++)).getURI().toString());
|
||||
|
||||
client.search(new SortSpec("param1", SortOrderEnum.ASC).setChain(new SortSpec("param2", SortOrderEnum.DESC)));
|
||||
assertEquals("http://localhost/fhir/Bundle?_sort=param1%2C-param2", ((HttpGet) capt.getAllValues().get(idx++)).getURI().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithPrimitiveTypes() throws Exception {
|
||||
TimeZone tz = TimeZone.getDefault();
|
||||
try {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("America/Toronto"));
|
||||
|
||||
Date date = new Date(23898235986L);
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.setTime(date);
|
||||
;
|
||||
|
||||
final String response = createBundleWithSearchExtension();
|
||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||
when(ourHttpClient.execute(capt.capture())).thenReturn(ourHttpResponse);
|
||||
when(ourHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(ourHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(ourHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
|
||||
@Override
|
||||
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
||||
return new ReaderInputStream(new StringReader(response), Charset.forName("UTF-8"));
|
||||
}
|
||||
});
|
||||
|
||||
ILocationClient client = ourCtx.newRestfulClient(ILocationClient.class, "http://localhost/fhir");
|
||||
|
||||
int idx = 0;
|
||||
|
||||
client.search("STRING1", new StringType("STRING2"), date, cal);
|
||||
assertEquals("http://localhost/fhir/Bundle?stringParam=STRING1&stringTypeParam=STRING2&dateParam=1970-10-04T10:23:55.986-04:00&calParam=1970-10-04T10:23:55.986-04:00",
|
||||
UrlUtil.unescape(((HttpGet) capt.getAllValues().get(idx++)).getURI().toString()));
|
||||
|
||||
client.search(null, null, null, null);
|
||||
assertEquals("http://localhost/fhir/Bundle",
|
||||
UrlUtil.unescape(((HttpGet) capt.getAllValues().get(idx++)).getURI().toString()));
|
||||
} finally {
|
||||
TimeZone.setDefault(tz);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See #299
|
||||
*/
|
||||
@Test
|
||||
public void testBundleResponseWithSearchExtension() throws Exception {
|
||||
|
||||
final String response = createBundleWithSearchExtension();
|
||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||
when(ourHttpClient.execute(capt.capture())).thenReturn(ourHttpResponse);
|
||||
when(ourHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(ourHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(ourHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
|
||||
@Override
|
||||
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
||||
return new ReaderInputStream(new StringReader(response), Charset.forName("UTF-8"));
|
||||
}
|
||||
});
|
||||
|
||||
ILocationClient client = ourCtx.newRestfulClient(ILocationClient.class, "http://localhost:8081/hapi-fhir/fhir");
|
||||
|
||||
Bundle matches = client.getMatchesReturnBundle(new StringParam("smith"), 100);
|
||||
|
||||
assertEquals(1, matches.getEntry().size());
|
||||
BundleEntryComponent entry = matches.getEntry().get(0);
|
||||
assertEquals("Sample Clinic", ((Location) entry.getResource()).getName());
|
||||
|
||||
List<Extension> ext = entry.getSearch().getExtensionsByUrl("http://hl7.org/fhir/StructureDefinition/algorithmic-match");
|
||||
assertEquals(1, ext.size());
|
||||
|
||||
HttpGet value = (HttpGet) capt.getValue();
|
||||
assertEquals("http://localhost:8081/hapi-fhir/fhir/Location?_query=match&name=smith&_count=100", value.getURI().toString());
|
||||
}
|
||||
|
||||
private String createBundleWithSearchExtension() {
|
||||
//@formatter:off
|
||||
private String createBundleWithSearchExtension() {
|
||||
//@formatter:off
|
||||
final String response = "<Bundle xmlns=\"http://hl7.org/fhir\">"
|
||||
+ "<id value=\"f61f6ddc-95e8-4ef9-a4cd-17c79bbb74f3\"></id>"
|
||||
+ "<meta><lastUpdated value=\"2016-02-19T12:04:02.616-05:00\"></lastUpdated></meta>"
|
||||
|
@ -212,23 +77,181 @@ public class SearchClientR4Test {
|
|||
+ "</entry>"
|
||||
+ "</Bundle>";
|
||||
//@formatter:on
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public interface ILocationClient extends IRestfulClient {
|
||||
@Search(queryName = "match")
|
||||
public List<Location> getMatches(final @RequiredParam(name = Location.SP_NAME) StringParam name, final @Count Integer count);
|
||||
/**
|
||||
* See #299
|
||||
*/
|
||||
@Test
|
||||
public void testBundleResponseWithSearchExtension() throws Exception {
|
||||
|
||||
@Search(queryName = "match", type = Location.class)
|
||||
public Bundle getMatchesReturnBundle(final @RequiredParam(name = Location.SP_NAME) StringParam name, final @Count Integer count);
|
||||
final String response = createBundleWithSearchExtension();
|
||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||
when(ourHttpClient.execute(capt.capture())).thenReturn(ourHttpResponse);
|
||||
when(ourHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(ourHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(ourHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
|
||||
@Override
|
||||
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
||||
return new ReaderInputStream(new StringReader(response), Charset.forName("UTF-8"));
|
||||
}
|
||||
});
|
||||
|
||||
@Search
|
||||
public Bundle search(@Sort SortSpec theSort);
|
||||
ILocationClient client = ourCtx.newRestfulClient(ILocationClient.class, "http://localhost:8081/hapi-fhir/fhir");
|
||||
|
||||
@Search
|
||||
public Bundle search(@OptionalParam(name = "stringParam") String theString, @OptionalParam(name = "stringTypeParam") StringType theStringDt, @OptionalParam(name = "dateParam") Date theDate,
|
||||
@OptionalParam(name = "calParam") Calendar theCal);
|
||||
Bundle matches = client.getMatchesReturnBundle(new StringParam("smith"), 100);
|
||||
|
||||
}
|
||||
assertEquals(1, matches.getEntry().size());
|
||||
BundleEntryComponent entry = matches.getEntry().get(0);
|
||||
assertEquals("Sample Clinic", ((Location) entry.getResource()).getName());
|
||||
|
||||
List<Extension> ext = entry.getSearch().getExtensionsByUrl("http://hl7.org/fhir/StructureDefinition/algorithmic-match");
|
||||
assertEquals(1, ext.size());
|
||||
|
||||
HttpGet value = (HttpGet) capt.getValue();
|
||||
assertEquals("http://localhost:8081/hapi-fhir/fhir/Location?_query=match&name=smith&_count=100", value.getURI().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCapabilities() throws Exception {
|
||||
|
||||
CapabilityStatement cs= new CapabilityStatement();
|
||||
cs.setName("FOO");
|
||||
|
||||
final String response = ourCtx.newXmlParser().encodeResourceToString(cs);
|
||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||
when(ourHttpClient.execute(capt.capture())).thenReturn(ourHttpResponse);
|
||||
when(ourHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(ourHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(ourHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
|
||||
@Override
|
||||
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
||||
return new ReaderInputStream(new StringReader(response), Charset.forName("UTF-8"));
|
||||
}
|
||||
});
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:8081/hapi-fhir/fhir");
|
||||
|
||||
CapabilityStatement actual = client.capabilities().ofType(CapabilityStatement.class).execute();
|
||||
assertEquals("FOO", actual.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* See #299
|
||||
*/
|
||||
@Test
|
||||
public void testListResponseWithSearchExtension() throws Exception {
|
||||
|
||||
final String response = createBundleWithSearchExtension();
|
||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||
when(ourHttpClient.execute(capt.capture())).thenReturn(ourHttpResponse);
|
||||
when(ourHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(ourHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(ourHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
|
||||
@Override
|
||||
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
||||
return new ReaderInputStream(new StringReader(response), Charset.forName("UTF-8"));
|
||||
}
|
||||
});
|
||||
|
||||
ILocationClient client = ourCtx.newRestfulClient(ILocationClient.class, "http://localhost:8081/hapi-fhir/fhir");
|
||||
|
||||
List<Location> matches = client.getMatches(new StringParam("smith"), 100);
|
||||
assertEquals(1, matches.size());
|
||||
assertEquals("Sample Clinic", matches.get(0).getName());
|
||||
|
||||
HttpGet value = (HttpGet) capt.getValue();
|
||||
assertEquals("http://localhost:8081/hapi-fhir/fhir/Location?_query=match&name=smith&_count=100", value.getURI().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithPrimitiveTypes() throws Exception {
|
||||
TimeZone tz = TimeZone.getDefault();
|
||||
try {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("America/Toronto"));
|
||||
|
||||
Date date = new Date(23898235986L);
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.setTime(date);
|
||||
;
|
||||
|
||||
final String response = createBundleWithSearchExtension();
|
||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||
when(ourHttpClient.execute(capt.capture())).thenReturn(ourHttpResponse);
|
||||
when(ourHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(ourHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(ourHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
|
||||
@Override
|
||||
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
||||
return new ReaderInputStream(new StringReader(response), Charset.forName("UTF-8"));
|
||||
}
|
||||
});
|
||||
|
||||
ILocationClient client = ourCtx.newRestfulClient(ILocationClient.class, "http://localhost/fhir");
|
||||
|
||||
int idx = 0;
|
||||
|
||||
client.search("STRING1", new StringType("STRING2"), date, cal);
|
||||
assertEquals("http://localhost/fhir/Bundle?stringParam=STRING1&stringTypeParam=STRING2&dateParam=1970-10-04T10:23:55.986-04:00&calParam=1970-10-04T10:23:55.986-04:00",
|
||||
UrlUtil.unescape(((HttpGet) capt.getAllValues().get(idx++)).getURI().toString()));
|
||||
|
||||
client.search(null, null, null, null);
|
||||
assertEquals("http://localhost/fhir/Bundle",
|
||||
UrlUtil.unescape(((HttpGet) capt.getAllValues().get(idx++)).getURI().toString()));
|
||||
} finally {
|
||||
TimeZone.setDefault(tz);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See #371
|
||||
*/
|
||||
@Test
|
||||
public void testSortForDstu3() throws Exception {
|
||||
|
||||
final String response = createBundleWithSearchExtension();
|
||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||
when(ourHttpClient.execute(capt.capture())).thenReturn(ourHttpResponse);
|
||||
when(ourHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(ourHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(ourHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
|
||||
@Override
|
||||
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
||||
return new ReaderInputStream(new StringReader(response), Charset.forName("UTF-8"));
|
||||
}
|
||||
});
|
||||
|
||||
ILocationClient client = ourCtx.newRestfulClient(ILocationClient.class, "http://localhost/fhir");
|
||||
|
||||
int idx = 0;
|
||||
|
||||
client.search(new SortSpec("param1", SortOrderEnum.ASC));
|
||||
assertEquals("http://localhost/fhir/Bundle?_sort=param1", ((HttpGet) capt.getAllValues().get(idx++)).getURI().toString());
|
||||
|
||||
client.search(new SortSpec("param1", SortOrderEnum.ASC).setChain(new SortSpec("param2", SortOrderEnum.DESC)));
|
||||
assertEquals("http://localhost/fhir/Bundle?_sort=param1%2C-param2", ((HttpGet) capt.getAllValues().get(idx++)).getURI().toString());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
public interface ILocationClient extends IRestfulClient {
|
||||
@Search(queryName = "match")
|
||||
public List<Location> getMatches(final @RequiredParam(name = Location.SP_NAME) StringParam name, final @Count Integer count);
|
||||
|
||||
@Search(queryName = "match", type = Location.class)
|
||||
public Bundle getMatchesReturnBundle(final @RequiredParam(name = Location.SP_NAME) StringParam name, final @Count Integer count);
|
||||
|
||||
@Search
|
||||
public Bundle search(@Sort SortSpec theSort);
|
||||
|
||||
@Search
|
||||
public Bundle search(@OptionalParam(name = "stringParam") String theString, @OptionalParam(name = "stringTypeParam") StringType theStringDt, @OptionalParam(name = "dateParam") Date theDate,
|
||||
@OptionalParam(name = "calParam") Calendar theCal);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -296,10 +296,10 @@ public class SearchR4Test {
|
|||
.search()
|
||||
.forResource(Patient.class)
|
||||
.where(new StringClientParam("foo").matches().value("bar"))
|
||||
.encodedJson()
|
||||
.prettyPrint()
|
||||
.usingStyle(SearchStyleEnum.POST)
|
||||
.returnBundle(org.hl7.fhir.r4.model.Bundle.class)
|
||||
.encodedJson()
|
||||
.execute();
|
||||
fail();
|
||||
} catch (InvalidRequestException e) {
|
||||
|
|
|
@ -4,7 +4,8 @@ import static org.hamcrest.Matchers.containsInAnyOrder;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.hl7.fhir.r4.model.*;
|
||||
import org.hl7.fhir.r4.model.Enumerations.AdministrativeGender;
|
||||
|
@ -15,53 +16,61 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
|
||||
public class FhirTerserTest {
|
||||
|
||||
private static FhirContext ourCtx = FhirContext.forR4();
|
||||
private static FhirContext ourCtx = FhirContext.forR4();
|
||||
|
||||
@Test
|
||||
public void testGetAllPopulatedChildElementsOfType() {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirTerserTest.class);
|
||||
|
||||
Patient p = new Patient();
|
||||
p.setGender(AdministrativeGender.MALE);
|
||||
p.addIdentifier().setSystem("urn:foo");
|
||||
p.addAddress().addLine("Line1");
|
||||
p.addAddress().addLine("Line2");
|
||||
p.addName().setFamily("Line3");
|
||||
@Test
|
||||
public void testGetAllPopulatedChildElementsOfType() {
|
||||
|
||||
FhirTerser t = ourCtx.newTerser();
|
||||
List<StringType> strings = t.getAllPopulatedChildElementsOfType(p, StringType.class);
|
||||
Patient p = new Patient();
|
||||
p.setGender(AdministrativeGender.MALE);
|
||||
p.addIdentifier().setSystem("urn:foo");
|
||||
p.addAddress().addLine("Line1");
|
||||
p.addAddress().addLine("Line2");
|
||||
p.addName().setFamily("Line3");
|
||||
|
||||
assertEquals(3, strings.size());
|
||||
assertThat(strings, containsInAnyOrder(new StringType("Line1"), new StringType("Line2"), new StringType("Line3")));
|
||||
FhirTerser t = ourCtx.newTerser();
|
||||
List<StringType> strings = t.getAllPopulatedChildElementsOfType(p, StringType.class);
|
||||
|
||||
}
|
||||
assertEquals(3, strings.size());
|
||||
|
||||
@Test
|
||||
public void testMultiValueTypes() {
|
||||
Set<String> allStrings = new HashSet<>();
|
||||
for (StringType next : strings) {
|
||||
allStrings.add(next.getValue());
|
||||
}
|
||||
|
||||
Observation obs = new Observation();
|
||||
obs.setValue(new Quantity(123L));
|
||||
assertThat(allStrings, containsInAnyOrder("Line1", "Line2", "Line3"));
|
||||
|
||||
FhirTerser t = ourCtx.newTerser();
|
||||
}
|
||||
|
||||
// As string
|
||||
{
|
||||
List<Object> values = t.getValues(obs, "Observation.valueString");
|
||||
assertEquals(0, values.size());
|
||||
}
|
||||
@Test
|
||||
public void testMultiValueTypes() {
|
||||
|
||||
// As quantity
|
||||
{
|
||||
List<Object> values = t.getValues(obs, "Observation.valueQuantity");
|
||||
assertEquals(1, values.size());
|
||||
Quantity actual = (Quantity) values.get(0);
|
||||
assertEquals("123", actual.getValueElement().getValueAsString());
|
||||
}
|
||||
}
|
||||
Observation obs = new Observation();
|
||||
obs.setValue(new Quantity(123L));
|
||||
|
||||
@Test
|
||||
public void testTerser() {
|
||||
FhirTerser t = ourCtx.newTerser();
|
||||
|
||||
//@formatter:off
|
||||
// As string
|
||||
{
|
||||
List<Object> values = t.getValues(obs, "Observation.valueString");
|
||||
assertEquals(0, values.size());
|
||||
}
|
||||
|
||||
// As quantity
|
||||
{
|
||||
List<Object> values = t.getValues(obs, "Observation.valueQuantity");
|
||||
assertEquals(1, values.size());
|
||||
Quantity actual = (Quantity) values.get(0);
|
||||
assertEquals("123", actual.getValueElement().getValueAsString());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTerser() {
|
||||
|
||||
//@formatter:off
|
||||
String msg = "<Observation xmlns=\"http://hl7.org/fhir\">\n" +
|
||||
" <text>\n" +
|
||||
" <status value=\"empty\"/>\n" +
|
||||
|
@ -92,18 +101,18 @@ public class FhirTerserTest {
|
|||
"</Observation>";
|
||||
//@formatter:on
|
||||
|
||||
Observation parsed = ourCtx.newXmlParser().parseResource(Observation.class, msg);
|
||||
FhirTerser t = ourCtx.newTerser();
|
||||
Observation parsed = ourCtx.newXmlParser().parseResource(Observation.class, msg);
|
||||
FhirTerser t = ourCtx.newTerser();
|
||||
|
||||
List<Reference> elems = t.getAllPopulatedChildElementsOfType(parsed, Reference.class);
|
||||
assertEquals(2, elems.size());
|
||||
assertEquals("cid:patient@bundle", elems.get(0).getReferenceElement().getValue());
|
||||
assertEquals("cid:device@bundle", elems.get(1).getReferenceElement().getValue());
|
||||
}
|
||||
List<Reference> elems = t.getAllPopulatedChildElementsOfType(parsed, Reference.class);
|
||||
assertEquals(2, elems.size());
|
||||
assertEquals("cid:patient@bundle", elems.get(0).getReferenceElement().getValue());
|
||||
assertEquals("cid:device@bundle", elems.get(1).getReferenceElement().getValue());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.thymeleaf.TemplateEngine;
|
|||
import ca.uhn.fhir.context.*;
|
||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Conformance;
|
||||
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
|
@ -310,7 +311,7 @@ public class BaseController {
|
|||
|
||||
ca.uhn.fhir.model.dstu2.resource.Conformance conformance;
|
||||
try {
|
||||
conformance = (ca.uhn.fhir.model.dstu2.resource.Conformance) client.conformance();
|
||||
conformance = (ca.uhn.fhir.model.dstu2.resource.Conformance) client.fetchConformance().ofType(Conformance.class).execute();
|
||||
} catch (Exception e) {
|
||||
ourLog.warn("Failed to load conformance statement, error was: {}", e.toString());
|
||||
theModel.put("errorMsg", toDisplayError("Failed to load conformance statement, error was: " + e.toString(), e));
|
||||
|
|
|
@ -121,7 +121,7 @@ public class Controller extends BaseController {
|
|||
|
||||
long start = System.currentTimeMillis();
|
||||
try {
|
||||
client.delete((Class<? extends IBaseResource>) def.getImplementingClass(), new IdDt(id));
|
||||
client.delete().resourceById(new IdDt(id)).execute();
|
||||
} catch (Exception e) {
|
||||
returnsResource = handleClientException(client, e, theModel);
|
||||
}
|
||||
|
@ -133,57 +133,6 @@ public class Controller extends BaseController {
|
|||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping(value = { "/get-tags" })
|
||||
public String actionGetTags(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) {
|
||||
addCommonParams(theReq, theRequest, theModel);
|
||||
|
||||
CaptureInterceptor interceptor = new CaptureInterceptor();
|
||||
GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor);
|
||||
|
||||
Class<? extends IBaseResource> resType = null;
|
||||
ResultType returnsResource = ResultType.TAGLIST;
|
||||
String outcomeDescription = "Tag List";
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
try {
|
||||
if (isNotBlank(theReq.getParameter(PARAM_RESOURCE))) {
|
||||
RuntimeResourceDefinition def;
|
||||
try {
|
||||
def = getResourceType(theRequest, theReq);
|
||||
} catch (ServletException e) {
|
||||
theModel.put("errorMsg", toDisplayError(e.toString(), e));
|
||||
return "resource";
|
||||
}
|
||||
|
||||
resType = (Class<? extends IBaseResource>) def.getImplementingClass();
|
||||
String id = theReq.getParameter("resource-tags-id");
|
||||
if (isNotBlank(id)) {
|
||||
String vid = theReq.getParameter("resource-tags-vid");
|
||||
if (isNotBlank(vid)) {
|
||||
client.getTags().forResource(resType, id, vid).execute();
|
||||
ourLog.info(logPrefix(theModel) + "Got tags for type " + def.getName() + " ID " + id + " version" + vid);
|
||||
} else {
|
||||
client.getTags().forResource(resType, id).execute();
|
||||
ourLog.info(logPrefix(theModel) + "Got tags for type " + def.getName() + " ID " + id);
|
||||
}
|
||||
} else {
|
||||
client.getTags().forResource(resType).execute();
|
||||
ourLog.info(logPrefix(theModel) + "Got tags for type " + def.getName());
|
||||
}
|
||||
} else {
|
||||
client.getTags().execute();
|
||||
ourLog.info(logPrefix(theModel) + "Got tags for server");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
returnsResource = handleClientException(client, e, theModel);
|
||||
}
|
||||
long delay = System.currentTimeMillis() - start;
|
||||
|
||||
processAndAddLastClientInvocation(client, returnsResource, theModel, delay, outcomeDescription, interceptor, theRequest);
|
||||
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping(value = { "/history-server" })
|
||||
public String actionHistoryServer(final HttpServletRequest theReq, final HomeRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) {
|
||||
doActionHistory(theReq, theRequest, theBindingResult, theModel, "history-server", "Server History");
|
||||
|
@ -467,7 +416,7 @@ public class Controller extends BaseController {
|
|||
|
||||
Class<? extends IBaseBundle> bundleType;
|
||||
bundleType = (Class<? extends IBaseBundle>) client.getFhirContext().getResourceDefinition("Bundle").getImplementingClass();
|
||||
IQueryTyped<? extends IBaseBundle> queryTyped = query.returnBundle(bundleType);
|
||||
IQuery<?> queryTyped = query.returnBundle(bundleType);
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
ResultType returnsResource;
|
||||
|
|
|
@ -199,6 +199,7 @@
|
|||
</div>
|
||||
|
||||
<!-- Get Tags -->
|
||||
<!--
|
||||
|
||||
<br clear="all"/>
|
||||
<div class="row-fluid">
|
||||
|
@ -221,6 +222,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
-->
|
||||
<!-- Next Server Action? -->
|
||||
|
||||
</div>
|
||||
|
|
|
@ -577,7 +577,8 @@
|
|||
<div class="container-fluid">
|
||||
|
||||
<!-- Get Tags -->
|
||||
|
||||
<!--
|
||||
|
||||
<div class="row-fluid">
|
||||
Show all of the tags currently in use on the server for this resource type. If an ID is specified,
|
||||
returns only tags posted to the given version. If an ID and a version are specified,
|
||||
|
@ -623,6 +624,7 @@
|
|||
});
|
||||
</script>
|
||||
</div>
|
||||
-->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.hamcrest.core.StringContains;
|
|||
import org.junit.*;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
|
||||
|
@ -45,8 +45,8 @@ public class ExampleTest {
|
|||
return;
|
||||
}
|
||||
|
||||
Bundle results = ourClient.search().forResource(Patient.class).execute();
|
||||
assertEquals(1, results.size());
|
||||
Bundle results = ourClient.search().forResource(Patient.class).returnBundle(Bundle.class).execute();
|
||||
assertEquals(1, results.getEntry().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -138,8 +138,8 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
|
Loading…
Reference in New Issue