Some test cleanup (#1616)

* Some test cleanup

* Add test

* More test logging

* More docs cleanup

* Add test logging
This commit is contained in:
James Agnew 2019-12-02 11:00:18 -05:00 committed by GitHub
parent 86bd9a28fe
commit f58fba6f04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 753 additions and 284 deletions

View File

@ -42,20 +42,6 @@ public class QualifierDetails {
} }
} }
} }
/*
* This was removed Sep 9 2015, as I don't see any way it could possibly be triggered.
if (!theQualifierWhitelist.contains(SearchParameter.QUALIFIER_ANY_TYPE)) {
if (myColonQualifier != null) {
if (!theQualifierWhitelist.contains(myColonQualifier)) {
return false;
}
} else {
if (!theQualifierWhitelist.contains(":")) {
return false;
}
}
}
*/
} }
if (theQualifierBlacklist != null) { if (theQualifierBlacklist != null) {
if (myDotQualifier != null) { if (myDotQualifier != null) {

View File

@ -255,8 +255,7 @@ public class MethodUtil {
parameter.setRequired(true); parameter.setRequired(true);
parameter.setDeclaredTypes(((RequiredParam) nextAnnotation).targetTypes()); parameter.setDeclaredTypes(((RequiredParam) nextAnnotation).targetTypes());
parameter.setCompositeTypes(((RequiredParam) nextAnnotation).compositeTypes()); parameter.setCompositeTypes(((RequiredParam) nextAnnotation).compositeTypes());
parameter.setChainlists(((RequiredParam) nextAnnotation).chainWhitelist(), parameter.setChainlists(((RequiredParam) nextAnnotation).chainWhitelist());
((RequiredParam) nextAnnotation).chainBlacklist());
parameter.setType(theContext, parameterType, innerCollectionType, outerCollectionType); parameter.setType(theContext, parameterType, innerCollectionType, outerCollectionType);
param = parameter; param = parameter;
} else if (nextAnnotation instanceof OptionalParam) { } else if (nextAnnotation instanceof OptionalParam) {
@ -265,8 +264,7 @@ public class MethodUtil {
parameter.setRequired(false); parameter.setRequired(false);
parameter.setDeclaredTypes(((OptionalParam) nextAnnotation).targetTypes()); parameter.setDeclaredTypes(((OptionalParam) nextAnnotation).targetTypes());
parameter.setCompositeTypes(((OptionalParam) nextAnnotation).compositeTypes()); parameter.setCompositeTypes(((OptionalParam) nextAnnotation).compositeTypes());
parameter.setChainlists(((OptionalParam) nextAnnotation).chainWhitelist(), parameter.setChainlists(((OptionalParam) nextAnnotation).chainWhitelist());
((OptionalParam) nextAnnotation).chainBlacklist());
parameter.setType(theContext, parameterType, innerCollectionType, outerCollectionType); parameter.setType(theContext, parameterType, innerCollectionType, outerCollectionType);
param = parameter; param = parameter;
} else if (nextAnnotation instanceof RawParam) { } else if (nextAnnotation instanceof RawParam) {

View File

@ -47,8 +47,8 @@ public class SearchParameter extends BaseQueryParameter {
static final String QUALIFIER_ANY_TYPE = ":*"; static final String QUALIFIER_ANY_TYPE = ":*";
static { static {
ourParamTypes = new HashMap<Class<?>, RestSearchParameterTypeEnum>(); ourParamTypes = new HashMap<>();
ourParamQualifiers = new HashMap<RestSearchParameterTypeEnum, Set<String>>(); ourParamQualifiers = new HashMap<>();
ourParamTypes.put(StringParam.class, RestSearchParameterTypeEnum.STRING); ourParamTypes.put(StringParam.class, RestSearchParameterTypeEnum.STRING);
ourParamTypes.put(StringOrListParam.class, RestSearchParameterTypeEnum.STRING); ourParamTypes.put(StringOrListParam.class, RestSearchParameterTypeEnum.STRING);
@ -100,11 +100,9 @@ public class SearchParameter extends BaseQueryParameter {
private List<Class<? extends IQueryParameterType>> myCompositeTypes = Collections.emptyList(); private List<Class<? extends IQueryParameterType>> myCompositeTypes = Collections.emptyList();
private List<Class<? extends IBaseResource>> myDeclaredTypes; private List<Class<? extends IBaseResource>> myDeclaredTypes;
private String myDescription;
private String myName; private String myName;
private IParamBinder<?> myParamBinder; private IParamBinder<?> myParamBinder;
private RestSearchParameterTypeEnum myParamType; private RestSearchParameterTypeEnum myParamType;
private Set<String> myQualifierBlacklist;
private Set<String> myQualifierWhitelist; private Set<String> myQualifierWhitelist;
private boolean myRequired; private boolean myRequired;
private Class<?> myType; private Class<?> myType;
@ -124,7 +122,7 @@ public class SearchParameter extends BaseQueryParameter {
*/ */
@Override @Override
public List<QualifiedParamList> encode(FhirContext theContext, Object theObject) throws InternalErrorException { public List<QualifiedParamList> encode(FhirContext theContext, Object theObject) throws InternalErrorException {
ArrayList<QualifiedParamList> retVal = new ArrayList<QualifiedParamList>(); ArrayList<QualifiedParamList> retVal = new ArrayList<>();
// TODO: declaring method should probably have a generic type.. // TODO: declaring method should probably have a generic type..
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ -139,14 +137,6 @@ public class SearchParameter extends BaseQueryParameter {
return retVal; return retVal;
} }
public List<Class<? extends IBaseResource>> getDeclaredTypes() {
return Collections.unmodifiableList(myDeclaredTypes);
}
public String getDescription() {
return myDescription;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -186,28 +176,17 @@ public class SearchParameter extends BaseQueryParameter {
return myParamBinder.parse(theContext, getName(), theString); return myParamBinder.parse(theContext, getName(), theString);
} }
public void setChainlists(String[] theChainWhitelist, String[] theChainBlacklist) { public void setChainlists(String[] theChainWhitelist) {
myQualifierWhitelist = new HashSet<String>(theChainWhitelist.length); myQualifierWhitelist = new HashSet<>(theChainWhitelist.length);
myQualifierWhitelist.add(QUALIFIER_ANY_TYPE); myQualifierWhitelist.add(QUALIFIER_ANY_TYPE);
for (int i = 0; i < theChainWhitelist.length; i++) { for (String chain : theChainWhitelist) {
if (theChainWhitelist[i].equals(OptionalParam.ALLOW_CHAIN_ANY)) { if (chain.equals(OptionalParam.ALLOW_CHAIN_ANY)) {
myQualifierWhitelist.add('.' + OptionalParam.ALLOW_CHAIN_ANY); myQualifierWhitelist.add('.' + OptionalParam.ALLOW_CHAIN_ANY);
} else if (theChainWhitelist[i].equals(EMPTY_STRING)) { } else if (chain.equals(EMPTY_STRING)) {
myQualifierWhitelist.add("."); myQualifierWhitelist.add(".");
} else { } else {
myQualifierWhitelist.add('.' + theChainWhitelist[i]); myQualifierWhitelist.add('.' + chain);
}
}
if (theChainBlacklist.length > 0) {
myQualifierBlacklist = new HashSet<String>(theChainBlacklist.length);
for (String next : theChainBlacklist) {
if (next.equals(EMPTY_STRING)) {
myQualifierBlacklist.add(EMPTY_STRING);
} else {
myQualifierBlacklist.add('.' + next);
}
} }
} }
} }
@ -220,10 +199,6 @@ public class SearchParameter extends BaseQueryParameter {
myDeclaredTypes = Arrays.asList(theTypes); myDeclaredTypes = Arrays.asList(theTypes);
} }
public void setDescription(String theDescription) {
myDescription = theDescription;
}
public void setName(String name) { public void setName(String name) {
this.myName = name; this.myName = name;
} }
@ -271,7 +246,7 @@ public class SearchParameter extends BaseQueryParameter {
Set<String> builtInQualifiers = ourParamQualifiers.get(typeEnum); Set<String> builtInQualifiers = ourParamQualifiers.get(typeEnum);
if (builtInQualifiers != null) { if (builtInQualifiers != null) {
if (myQualifierWhitelist != null) { if (myQualifierWhitelist != null) {
HashSet<String> qualifierWhitelist = new HashSet<String>(); HashSet<String> qualifierWhitelist = new HashSet<>();
qualifierWhitelist.addAll(myQualifierWhitelist); qualifierWhitelist.addAll(myQualifierWhitelist);
qualifierWhitelist.addAll(builtInQualifiers); qualifierWhitelist.addAll(builtInQualifiers);
myQualifierWhitelist = qualifierWhitelist; myQualifierWhitelist = qualifierWhitelist;

View File

@ -1,5 +1,25 @@
package ca.uhn.hapi.fhir.docs; package ca.uhn.hapi.fhir.docs;
/*-
* #%L
* HAPI FHIR - Docs
* %%
* Copyright (C) 2014 - 2019 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.to.FhirTesterMvcConfig; import ca.uhn.fhir.to.FhirTesterMvcConfig;
import ca.uhn.fhir.to.TesterConfig; import ca.uhn.fhir.to.TesterConfig;

View File

@ -9,7 +9,7 @@ this page.
The following table shows the various versions of the HAPI FHIR library, and the versions of the FHIR standard that they support. Note that support for stable releases of FHIR are shown in <span style="background: #CEC; padding: 3px;">GREEN</span> and support for draft pre-release versions of FHIR are shown in <span style="background: #EEB; padding: 3px;">YELLOW</span>. The following table shows the various versions of the HAPI FHIR library, and the versions of the FHIR standard that they support. Note that support for stable releases of FHIR are shown in <span style="background: #CEC; padding: 3px;">GREEN</span> and support for draft pre-release versions of FHIR are shown in <span style="background: #EEB; padding: 3px;">YELLOW</span>.
Note also that after the release of the FHIR DSTU2 specification, the FHIR Note also that after the release of the FHIR DSTU2 specification, the FHIR
standard itself stopped using the DSTUx naming scheme, in favour or naming new releases STUx or simply Rx. Because HAPI FHIR already had draft support for what was then called DSTU3 at this time, we did not update our naming conventions until R4 in order to avoid breaking existing users' code. From the perspective of a user of HAPI FHIR, consider the terms DSTU3 / STU3 / R3 to be interchangeable. standard itself stopped using the DSTUx naming scheme, in favour or naming new releases STUx or simply Rx. Because HAPI FHIR already had draft support for what was then called DSTU3, we did not update our naming conventions until R4 in order to avoid breaking existing users' code. From the perspective of a user of HAPI FHIR, consider the terms DSTU3 / STU3 / R3 to be interchangeable.
<table class="table table-condensed versions-table"> <table class="table table-condensed versions-table">
<thead> <thead>
@ -26,102 +26,122 @@ Note also that after the release of the FHIR DSTU2 specification, the FHIR
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>HAPI FHIR 1.1</td> <td>HAPI FHIR 4.1.0</td>
<td>JDK6</td> <td>JDK8</td>
<td class="versions-table-cell-draft">0.0.82</td>
<td class="versions-table-cell-release">0.5.0<span class="download-version-hash">-5843</span></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td>
</tr>
<tr>
<td>HAPI FHIR 1.2</td>
<td>JDK6</td>
<td class="versions-table-cell-draft">0.0.82</td>
<td class="versions-table-cell-release">0.5.0<span class="download-version-hash">-5843</span></td>
<td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td>
</tr>
<tr>
<td>HAPI FHIR 1.3</td>
<td>JDK6</td>
<td class="versions-table-cell-draft">0.0.82</td>
<td class="versions-table-cell-draft">1.0.2</td> <td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-draft">3.0.2</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-draft">4.0.1</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-release">4.1.0<span class="download-version-hash"><br/>1a7623d866</span></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 1.4</td> <td>HAPI FHIR 4.0.0</td>
<td>JDK6</td> <td>JDK8</td>
<td class="versions-table-cell-draft">0.0.82</td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">1.0.2</td> <td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-release">1.3.0<span class="download-version-hash">-7602</span></td> <td class="versions-table-cell-draft">3.0.1</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-draft">4.0.0</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-release">4.1.0<span class="download-version-hash"><br/>e0e3caf9ba</span></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 1.5</td> <td>HAPI FHIR 3.8.0</td>
<td>JDK6</td> <td>JDK8</td>
<td class="versions-table-cell-draft">0.0.82</td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">1.0.2</td> <td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-release">1.4.0<span class="download-version-hash">-8138</span></td> <td class="versions-table-cell-draft">3.0.1</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-draft">4.0.0</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 1.6</td> <td>HAPI FHIR 3.7.0</td>
<td>JDK6</td> <td>JDK8</td>
<td class="versions-table-cell-draft">0.0.82</td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">1.0.2</td> <td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-release">1.4.0<span class="download-version-hash">-8636</span></td> <td class="versions-table-cell-draft">3.0.1</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-draft">4.0.0</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 2.0</td> <td>HAPI FHIR 3.6.0</td>
<td>JDK6</td> <td>JDK8</td>
<td class="versions-table-cell-draft">0.0.82</td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">1.0.2</td> <td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-release">1.6.0<span class="download-version-hash">-9663</span></td> <td class="versions-table-cell-draft">3.0.1</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-release">3.6.0<span class="download-version-hash"><br/>1202b2eed0f</span></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 2.1</td> <td>HAPI FHIR 3.5.0</td>
<td>JDK6</td> <td>JDK8</td>
<td class="versions-table-cell-draft">0.0.82</td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">1.0.2</td> <td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-release">1.7.0<span class="download-version-hash">-10129</span></td> <td class="versions-table-cell-draft">3.0.1</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-release">3.4.0<span class="download-version-hash"><br/>13732</span></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 2.2</td> <td>HAPI FHIR 3.4.0</td>
<td>JDK8</td>
<td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-draft">3.0.1</td>
<td class="versions-table-cell-release">3.4.0<span class="download-version-hash"><br/>13732</span></td>
<td class="versions-table-cell-empty"></td>
</tr>
<tr>
<td>HAPI FHIR 3.3.0</td>
<td>JDK7</td>
<td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-draft">3.0.1</td>
<td class="versions-table-cell-release">3.2.0<span class="download-version-hash"><br/>13271</span></td>
<td class="versions-table-cell-empty"></td>
</tr>
<tr>
<td>HAPI FHIR 3.2.0</td>
<td>JDK7</td>
<td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-draft">3.0.1</td>
<td class="versions-table-cell-release">3.2.0<span class="download-version-hash"><br/>12917</span></td>
<td class="versions-table-cell-empty"></td>
</tr>
<tr>
<td>HAPI FHIR 3.1.0</td>
<td>JDK7</td>
<td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-draft">3.0.1</td>
<td class="versions-table-cell-release">3.1.0<span class="download-version-hash"><br/>12370</span></td>
<td class="versions-table-cell-empty"></td>
</tr>
<tr>
<td>HAPI FHIR 3.0.0</td>
<td>JDK7</td>
<td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-draft">3.0.1</td>
<td class="versions-table-cell-release">3.1.0<span class="download-version-hash"><br/>12370</span></td>
<td class="versions-table-cell-empty"></td>
</tr>
<tr>
<td>HAPI FHIR 2.5</td>
<td>JDK6</td> <td>JDK6</td>
<td class="versions-table-cell-draft">0.0.82</td> <td class="versions-table-cell-draft">0.0.82</td>
<td class="versions-table-cell-draft">1.0.2</td> <td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td> <td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-release">1.8.0<span class="download-version-hash">-10528</span></td> <td class="versions-table-cell-draft">3.0.1</td>
<td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td>
</tr>
<tr>
<td>HAPI FHIR 2.3</td>
<td>JDK6</td>
<td class="versions-table-cell-draft">0.0.82</td>
<td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-release">1.9.0<span class="download-version-hash">-11501</span></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr> </tr>
@ -136,124 +156,104 @@ Note also that after the release of the FHIR DSTU2 specification, the FHIR
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 2.5</td> <td>HAPI FHIR 2.3</td>
<td>JDK6</td> <td>JDK6</td>
<td class="versions-table-cell-draft">0.0.82</td> <td class="versions-table-cell-draft">0.0.82</td>
<td class="versions-table-cell-draft">1.0.2</td> <td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td> <td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-draft">3.0.1</td> <td class="versions-table-cell-release">1.9.0<span class="download-version-hash"><br/>11501</span></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 3.0.0</td> <td>HAPI FHIR 2.2</td>
<td>JDK7</td> <td>JDK6</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-draft">0.0.82</td>
<td class="versions-table-cell-draft">1.0.2</td> <td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td> <td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-draft">3.0.1</td> <td class="versions-table-cell-release">1.8.0<span class="download-version-hash"><br/>10528</span></td>
<td class="versions-table-cell-release">3.1.0<span class="download-version-hash">-12370</span></td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 3.1.0</td> <td>HAPI FHIR 2.1</td>
<td>JDK7</td> <td>JDK6</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-draft">0.0.82</td>
<td class="versions-table-cell-draft">1.0.2</td> <td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">3.0.1</td> <td class="versions-table-cell-release">1.7.0<span class="download-version-hash"><br/>10129</span></td>
<td class="versions-table-cell-release">3.1.0<span class="download-version-hash">-12370</span></td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 3.2.0</td> <td>HAPI FHIR 2.0</td>
<td>JDK7</td> <td>JDK6</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-draft">0.0.82</td>
<td class="versions-table-cell-draft">1.0.2</td> <td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">3.0.1</td> <td class="versions-table-cell-release">1.6.0<span class="download-version-hash"><br/>9663</span></td>
<td class="versions-table-cell-release">3.2.0<span class="download-version-hash">-12917</span></td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 3.3.0</td> <td>HAPI FHIR 1.6</td>
<td>JDK7</td> <td>JDK6</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-draft">0.0.82</td>
<td class="versions-table-cell-draft">1.0.2</td> <td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">3.0.1</td> <td class="versions-table-cell-release">1.4.0<span class="download-version-hash"><br/>8636</span></td>
<td class="versions-table-cell-release">3.2.0<span class="download-version-hash">-13271</span></td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 3.4.0</td> <td>HAPI FHIR 1.5</td>
<td>JDK8</td> <td>JDK6</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-draft">0.0.82</td>
<td class="versions-table-cell-draft">1.0.2</td> <td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">3.0.1</td> <td class="versions-table-cell-release">1.4.0<span class="download-version-hash"><br/>8138</span></td>
<td class="versions-table-cell-release">3.4.0<span class="download-version-hash">-13732</span></td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 3.5.0</td> <td>HAPI FHIR 1.4</td>
<td>JDK8</td> <td>JDK6</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-draft">0.0.82</td>
<td class="versions-table-cell-draft">1.0.2</td> <td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">3.0.1</td> <td class="versions-table-cell-release">1.3.0<span class="download-version-hash"><br/>7602</span></td>
<td class="versions-table-cell-release">3.4.0<span class="download-version-hash">-13732</span></td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 3.6.0</td> <td>HAPI FHIR 1.3</td>
<td>JDK8</td> <td>JDK6</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-draft">0.0.82</td>
<td class="versions-table-cell-draft">1.0.2</td> <td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">3.0.1</td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-release">3.6.0<span class="download-version-hash">-1202b2eed0f</span></td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 3.7.0</td> <td>HAPI FHIR 1.2</td>
<td>JDK8</td> <td>JDK6</td>
<td class="versions-table-cell-draft">0.0.82</td>
<td class="versions-table-cell-release">0.5.0<span class="download-version-hash"><br/>5843</span></td>
<td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-draft">3.0.1</td>
<td class="versions-table-cell-draft">4.0.0</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr> </tr>
<tr> <tr>
<td>HAPI FHIR 3.8.0</td> <td>HAPI FHIR 1.1</td>
<td>JDK8</td> <td>JDK6</td>
<td class="versions-table-cell-draft">0.0.82</td>
<td class="versions-table-cell-release">0.5.0<span class="download-version-hash"><br/>5843</span></td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-draft">3.0.1</td>
<td class="versions-table-cell-draft">4.0.0</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
</tr>
<tr>
<td>HAPI FHIR 4.0.0</td>
<td>JDK8</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-draft">3.0.1</td>
<td class="versions-table-cell-draft">4.0.0</td>
<td class="versions-table-cell-release">4.1.0<span class="download-version-hash">-e0e3caf9ba</span></td>
</tr>
<tr>
<td>HAPI FHIR 4.1.0</td>
<td>JDK8</td>
<td class="versions-table-cell-empty"></td> <td class="versions-table-cell-empty"></td>
<td class="versions-table-cell-draft">1.0.2</td>
<td class="versions-table-cell-release">1.4.0</td>
<td class="versions-table-cell-draft">3.0.2</td>
<td class="versions-table-cell-draft">4.0.1</td>
<td class="versions-table-cell-release">4.1.0<span class="download-version-hash">-1a7623d866</span></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -1,6 +1,7 @@
package ca.uhn.fhir.jpa.entity; package ca.uhn.fhir.jpa.entity;
import ca.uhn.fhir.jpa.model.search.SearchStatusEnum; import ca.uhn.fhir.jpa.model.search.SearchStatusEnum;
import ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.rest.param.DateRangeParam; import ca.uhn.fhir.rest.param.DateRangeParam;
@ -184,6 +185,9 @@ public class Search implements ICachedSearchDetails, Serializable {
public void setFailureMessage(String theFailureMessage) { public void setFailureMessage(String theFailureMessage) {
myFailureMessage = left(theFailureMessage, FAILURE_MESSAGE_LENGTH); myFailureMessage = left(theFailureMessage, FAILURE_MESSAGE_LENGTH);
if (System.getProperty(SearchCoordinatorSvcImpl.UNIT_TEST_CAPTURE_STACK) != null) {
myFailureMessage = theFailureMessage;
}
} }
public Long getId() { public Long getId() {

View File

@ -904,7 +904,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
} }
if (System.getProperty(UNIT_TEST_CAPTURE_STACK) != null) { if (System.getProperty(UNIT_TEST_CAPTURE_STACK) != null) {
failureMessage += "\n" + ExceptionUtils.getStackTrace(rootCause); failureMessage += "\nStack\n" + ExceptionUtils.getStackTrace(rootCause);
} }
mySearch.setFailureMessage(failureMessage); mySearch.setFailureMessage(failureMessage);

View File

@ -1824,8 +1824,8 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc, ApplicationCo
if (isNotBlank(targetCode) && isNotBlank(targetCodeSystem)) { if (isNotBlank(targetCode) && isNotBlank(targetCodeSystem)) {
for (Iterator<TermConceptMapGroupElementTarget> iter = nextElement.getConceptMapGroupElementTargets().iterator(); iter.hasNext(); ) { for (Iterator<TermConceptMapGroupElementTarget> iter = nextElement.getConceptMapGroupElementTargets().iterator(); iter.hasNext(); ) {
TermConceptMapGroupElementTarget next = iter.next(); TermConceptMapGroupElementTarget next = iter.next();
if (targetCodeSystem.equals(next.getSystem())) { if (StringUtils.equals(targetCodeSystem, next.getSystem())) {
if (targetCode.equals(next.getCode())) { if (StringUtils.equals(targetCode, next.getCode())) {
continue; continue;
} }
} }

View File

@ -1,6 +1,7 @@
package ca.uhn.fhir.jpa.search.reindex; package ca.uhn.fhir.jpa.search.reindex;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao;
import ca.uhn.fhir.jpa.dao.BaseJpaTest; import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.dao.DaoConfig; import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.dao.DaoRegistry; import ca.uhn.fhir.jpa.dao.DaoRegistry;
@ -24,6 +25,7 @@ import org.mockito.Mock;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.SliceImpl; import org.springframework.data.domain.SliceImpl;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import java.util.*; import java.util.*;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
@ -68,6 +70,8 @@ public class ResourceReindexingSvcImplTest extends BaseJpaTest {
private ResourceReindexJobEntity mySingleJob; private ResourceReindexJobEntity mySingleJob;
@Mock @Mock
private ISearchParamRegistry mySearchParamRegistry; private ISearchParamRegistry mySearchParamRegistry;
@Mock
private TransactionStatus myTxStatus;
@Override @Override
protected FhirContext getContext() { protected FhirContext getContext() {
@ -94,6 +98,8 @@ public class ResourceReindexingSvcImplTest extends BaseJpaTest {
mySvc.setTxManagerForUnitTest(myTxManager); mySvc.setTxManagerForUnitTest(myTxManager);
mySvc.setSearchParamRegistryForUnitTest(mySearchParamRegistry); mySvc.setSearchParamRegistryForUnitTest(mySearchParamRegistry);
mySvc.start(); mySvc.start();
when(myTxManager.getTransaction(any())).thenReturn(myTxStatus);
} }
@Test @Test
@ -252,6 +258,37 @@ public class ResourceReindexingSvcImplTest extends BaseJpaTest {
verifyNoMoreInteractions(myReindexJobDao); verifyNoMoreInteractions(myReindexJobDao);
} }
@Test
public void testReindexDeletedResource() {
mockNothingToExpunge();
mockSingleReindexingJob("Patient");
// Mock resource fetch
List<Long> values = Arrays.asList(0L);
when(myResourceTableDao.findIdsOfResourcesWithinUpdatedRangeOrderedFromOldest(myPageRequestCaptor.capture(), myTypeCaptor.capture(), myLowCaptor.capture(), myHighCaptor.capture())).thenReturn(new SliceImpl<>(values));
// Mock fetching resources
long[] updatedTimes = new long[]{
10 * DateUtils.MILLIS_PER_DAY
};
String[] resourceTypes = new String[]{
"Patient",
};
List<IBaseResource> resources = Arrays.asList(
new Patient().setId("Patient/0/_history/1")
);
mockWhenResourceTableFindById(updatedTimes, resourceTypes);
when(myDaoRegistry.getResourceDao(eq("Patient"))).thenReturn(myResourceDao);
when(myDaoRegistry.getResourceDao(eq(Patient.class))).thenReturn(myResourceDao);
when(myDaoRegistry.getResourceDao(eq("Observation"))).thenReturn(myResourceDao);
when(myDaoRegistry.getResourceDao(eq(Observation.class))).thenReturn(myResourceDao);
when(myResourceDao.read(any(), any(), anyBoolean())).thenReturn(null);
int count = mySvc.forceReindexingPass();
assertEquals(0, count);
verify(myResourceTableDao, times(1)).updateIndexStatus(eq(0L), eq(BaseHapiFhirDao.INDEX_STATUS_INDEXING_FAILED));
}
@Test @Test
public void testReindexThrowsError() { public void testReindexThrowsError() {
mockNothingToExpunge(); mockNothingToExpunge();

View File

@ -1,6 +1,13 @@
package ca.uhn.fhir.jpa.term; package ca.uhn.fhir.jpa.term;
import ca.uhn.fhir.jpa.entity.*; import ca.uhn.fhir.jpa.entity.TermCodeSystem;
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
import ca.uhn.fhir.jpa.entity.TermConcept;
import ca.uhn.fhir.jpa.entity.TermConceptDesignation;
import ca.uhn.fhir.jpa.entity.TermValueSet;
import ca.uhn.fhir.jpa.entity.TermValueSetConcept;
import ca.uhn.fhir.jpa.entity.TermValueSetConceptDesignation;
import ca.uhn.fhir.jpa.entity.TermValueSetPreExpansionStatusEnum;
import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.model.entity.ResourceTable;
import ca.uhn.fhir.jpa.model.util.JpaConstants; import ca.uhn.fhir.jpa.model.util.JpaConstants;
import ca.uhn.fhir.jpa.term.custom.CustomTerminologySet; import ca.uhn.fhir.jpa.term.custom.CustomTerminologySet;
@ -20,14 +27,25 @@ import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate; import org.springframework.transaction.support.TransactionTemplate;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.empty;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.*; import static org.junit.Assert.assertFalse;
import static org.mockito.Mockito.*; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.anyCollection;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class ValueSetExpansionR4Test extends BaseTermR4Test { public class ValueSetExpansionR4Test extends BaseTermR4Test {
private static final Logger ourLog = LoggerFactory.getLogger(ValueSetExpansionR4Test.class); private static final Logger ourLog = LoggerFactory.getLogger(ValueSetExpansionR4Test.class);
@ -35,6 +53,39 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test {
@Mock @Mock
private IValueSetConceptAccumulator myValueSetCodeAccumulator; private IValueSetConceptAccumulator myValueSetCodeAccumulator;
@Test
public void testDeletePreExpandedValueSet() throws IOException {
myDaoConfig.setPreExpandValueSets(true);
loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.POST);
CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId);
ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem));
ValueSet valueSet = myValueSetDao.read(myExtensionalVsId);
ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet));
myTermSvc.preExpandDeferredValueSetsToTerminologyTables();
myCaptureQueriesListener.clear();
ValueSet expandedValueSet = myTermSvc.expandValueSet(valueSet, myDaoConfig.getPreExpandValueSetsDefaultOffset(), myDaoConfig.getPreExpandValueSetsDefaultCount());
assertEquals(24, expandedValueSet.getExpansion().getContains().size());
runInTransaction(()->{
assertEquals(24, myTermValueSetConceptDao.count());
});
myValueSetDao.delete(valueSet.getIdElement());
runInTransaction(()->{
assertEquals(0, myTermValueSetConceptDao.count());
});
expandedValueSet = myTermSvc.expandValueSet(valueSet, myDaoConfig.getPreExpandValueSetsDefaultOffset(), myDaoConfig.getPreExpandValueSetsDefaultCount());
assertEquals(24, expandedValueSet.getExpansion().getContains().size());
}
@SuppressWarnings("SpellCheckingInspection") @SuppressWarnings("SpellCheckingInspection")
@Test @Test
public void testExpandTermValueSetAndChildren() throws Exception { public void testExpandTermValueSetAndChildren() throws Exception {
@ -141,7 +192,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test {
} }
@Test @Test
public void testExpandExistingValueSetNotPreExpanded() throws Exception { public void testExpandExistingValueSetNotPreExpanded() throws Exception {
loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.POST); loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.POST);
@ -494,15 +545,16 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test {
myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); myTermSvc.preExpandDeferredValueSetsToTerminologyTables();
ValueSet expandedValueSet = myTermSvc.expandValueSet(valueSet, myDaoConfig.getPreExpandValueSetsDefaultOffset(), 0); ValueSet expandedValueSet = myTermSvc.expandValueSet(valueSet, myDaoConfig.getPreExpandValueSetsDefaultOffset(), 0);
ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); String expanded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet);
ourLog.info("Expanded ValueSet:\n" + expanded);
assertEquals(codeSystem.getConcept().size(), expandedValueSet.getExpansion().getTotal()); assertEquals(codeSystem.getConcept().size(), expandedValueSet.getExpansion().getTotal());
assertEquals(myDaoConfig.getPreExpandValueSetsDefaultOffset(), expandedValueSet.getExpansion().getOffset()); assertEquals(myDaoConfig.getPreExpandValueSetsDefaultOffset(), expandedValueSet.getExpansion().getOffset());
assertEquals(2, expandedValueSet.getExpansion().getParameter().size()); assertEquals(expanded, 2, expandedValueSet.getExpansion().getParameter().size());
assertEquals("offset", expandedValueSet.getExpansion().getParameter().get(0).getName()); assertEquals(expanded, "offset", expandedValueSet.getExpansion().getParameter().get(0).getName());
assertEquals(0, expandedValueSet.getExpansion().getParameter().get(0).getValueIntegerType().getValue().intValue()); assertEquals(expanded, 0, expandedValueSet.getExpansion().getParameter().get(0).getValueIntegerType().getValue().intValue());
assertEquals("count", expandedValueSet.getExpansion().getParameter().get(1).getName()); assertEquals(expanded, "count", expandedValueSet.getExpansion().getParameter().get(1).getName());
assertEquals(0, expandedValueSet.getExpansion().getParameter().get(1).getValueIntegerType().getValue().intValue()); assertEquals(expanded, 0, expandedValueSet.getExpansion().getParameter().get(1).getValueIntegerType().getValue().intValue());
assertFalse(expandedValueSet.getExpansion().hasContains()); assertFalse(expandedValueSet.getExpansion().hasContains());
} }

View File

@ -7,12 +7,16 @@ import ca.uhn.fhir.rest.annotation.RequiredParam;
import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.api.RequestTypeEnum; import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.param.ReferenceParam;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map; import java.util.Map;
@ -22,90 +26,114 @@ import static org.mockito.Mockito.when;
public class SearchMethodBindingTest { public class SearchMethodBindingTest {
private static final TestResourceProvider TEST_RESOURCE_PROVIDER = new TestResourceProvider(); private static final TestResourceProvider TEST_RESOURCE_PROVIDER = new TestResourceProvider();
private static final Logger ourLog = LoggerFactory.getLogger(SearchMethodBindingTest.class);
private FhirContext fhirContext;
private FhirContext fhirContext; @Before
public void setUp() {
fhirContext = mock(FhirContext.class);
RuntimeResourceDefinition definition = mock(RuntimeResourceDefinition.class);
when(definition.isBundle()).thenReturn(false);
when(fhirContext.getResourceDefinition(any(Class.class))).thenReturn(definition);
}
@Before @Test // fails
public void setUp() { public void methodShouldNotMatchWhenUnderscoreQueryParameter() throws NoSuchMethodException {
fhirContext = mock(FhirContext.class); Assert.assertThat(getBinding("param", String.class).incomingServerRequestMatchesMethod(
RuntimeResourceDefinition definition = mock(RuntimeResourceDefinition.class); mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "_include", new String[]{"test"}))),
when(definition.isBundle()).thenReturn(false); Matchers.is(false));
when(fhirContext.getResourceDefinition(any(Class.class))).thenReturn(definition); Assert.assertThat(getBinding("paramAndTest", String.class, String.class).incomingServerRequestMatchesMethod(
} mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "_include", new String[]{"test"}))),
Matchers.is(false));
Assert.assertThat(getBinding("paramAndUnderscoreTest", String.class, String.class).incomingServerRequestMatchesMethod(
mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "_include", new String[]{"test"}))),
Matchers.is(false));
}
@Test // fails @Test
public void methodShouldNotMatchWhenUnderscoreQueryParameter() throws NoSuchMethodException { public void methodShouldNotMatchWhenExtraQueryParameter() throws NoSuchMethodException {
Assert.assertThat(getBinding("param", String.class).incomingServerRequestMatchesMethod( Assert.assertThat(getBinding("param", String.class).incomingServerRequestMatchesMethod(
mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "_include", new String[]{"test"}))), mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "extra", new String[]{"test"}))),
Matchers.is(false)); Matchers.is(false));
Assert.assertThat(getBinding("paramAndTest", String.class, String.class).incomingServerRequestMatchesMethod( Assert.assertThat(getBinding("paramAndTest", String.class, String.class).incomingServerRequestMatchesMethod(
mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "_include", new String[]{"test"}))), mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "extra", new String[]{"test"}))),
Matchers.is(false)); Matchers.is(false));
Assert.assertThat(getBinding("paramAndUnderscoreTest", String.class, String.class).incomingServerRequestMatchesMethod( Assert.assertThat(getBinding("paramAndUnderscoreTest", String.class, String.class).incomingServerRequestMatchesMethod(
mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "_include", new String[]{"test"}))), mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "extra", new String[]{"test"}))),
Matchers.is(false)); Matchers.is(false));
} }
@Test @Test
public void methodShouldNotMatchWhenExtraQueryParameter() throws NoSuchMethodException { public void methodMatchesOwnParams() throws NoSuchMethodException {
Assert.assertThat(getBinding("param", String.class).incomingServerRequestMatchesMethod( Assert.assertThat(getBinding("param", String.class).incomingServerRequestMatchesMethod(
mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "extra", new String[]{"test"}))), mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}))),
Matchers.is(false)); Matchers.is(true));
Assert.assertThat(getBinding("paramAndTest", String.class, String.class).incomingServerRequestMatchesMethod( Assert.assertThat(getBinding("paramAndTest", String.class, String.class).incomingServerRequestMatchesMethod(
mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "extra", new String[]{"test"}))), mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "test", new String[]{"test"}))),
Matchers.is(false)); Matchers.is(true));
Assert.assertThat(getBinding("paramAndUnderscoreTest", String.class, String.class).incomingServerRequestMatchesMethod( Assert.assertThat(getBinding("paramAndUnderscoreTest", String.class, String.class).incomingServerRequestMatchesMethod(
mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "extra", new String[]{"test"}))), mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "_test", new String[]{"test"}))),
Matchers.is(false)); Matchers.is(true));
} }
@Test @Test
public void methodMatchesOwnParams() throws NoSuchMethodException { public void methodMatchesChainBlacklist() throws NoSuchMethodException {
Assert.assertThat(getBinding("param", String.class).incomingServerRequestMatchesMethod( SearchMethodBinding binding = getBinding("withChainBlacklist", ReferenceParam.class);
mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}))), ourLog.info("Testing binding: {}", binding);
Matchers.is(true)); Assert.assertThat(binding.incomingServerRequestMatchesMethod(
Assert.assertThat(getBinding("paramAndTest", String.class, String.class).incomingServerRequestMatchesMethod( mockSearchRequest(ImmutableMap.of("refChainBlacklist.badChain", new String[]{"foo"}))),
mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "test", new String[]{"test"}))), Matchers.is(false));
Matchers.is(true)); Assert.assertThat(binding.incomingServerRequestMatchesMethod(
Assert.assertThat(getBinding("paramAndUnderscoreTest", String.class, String.class).incomingServerRequestMatchesMethod( mockSearchRequest(ImmutableMap.of("refChainBlacklist.goodChain", new String[]{"foo"}))),
mockSearchRequest(ImmutableMap.of("param", new String[]{"value"}, "_test", new String[]{"test"}))), Matchers.is(true));
Matchers.is(true)); }
}
private SearchMethodBinding getBinding(String name, Class<?>... parameters) throws NoSuchMethodException { private SearchMethodBinding getBinding(String name, Class<?>... parameters) throws NoSuchMethodException {
return new SearchMethodBinding(IBaseResource.class, return new SearchMethodBinding(IBaseResource.class,
IBaseResource.class, IBaseResource.class,
TestResourceProvider.class.getMethod(name, parameters), TestResourceProvider.class.getMethod(name, parameters),
fhirContext, fhirContext,
TEST_RESOURCE_PROVIDER); TEST_RESOURCE_PROVIDER);
} }
private RequestDetails mockSearchRequest(Map<String, String[]> params) { private RequestDetails mockSearchRequest(Map<String, String[]> params) {
RequestDetails requestDetails = mock(RequestDetails.class); RequestDetails requestDetails = mock(RequestDetails.class);
when(requestDetails.getOperation()).thenReturn("_search"); when(requestDetails.getOperation()).thenReturn("_search");
when(requestDetails.getRequestType()).thenReturn(RequestTypeEnum.GET); when(requestDetails.getRequestType()).thenReturn(RequestTypeEnum.GET);
when(requestDetails.getParameters()).thenReturn(params); when(requestDetails.getParameters()).thenReturn(params);
return requestDetails;
}
private static class TestResourceProvider { when(requestDetails.getUnqualifiedToQualifiedNames()).thenAnswer(t -> {
RequestDetails rd = new ServletRequestDetails(null);
rd.setParameters(params);
return rd.getUnqualifiedToQualifiedNames();
});
@Search return requestDetails;
public IBaseResource param(@RequiredParam(name = "param") String param) { }
return null;
}
@Search private static class TestResourceProvider {
public IBaseResource paramAndTest(@RequiredParam(name = "param") String param, @OptionalParam(name = "test") String test) {
return null;
}
@Search @Search
public IBaseResource paramAndUnderscoreTest(@RequiredParam(name = "param") String param, @OptionalParam(name = "_test") String test) { public IBaseResource param(@RequiredParam(name = "param") String param) {
return null; return null;
} }
} @Search
public IBaseResource paramAndTest(@RequiredParam(name = "param") String param, @OptionalParam(name = "test") String test) {
return null;
}
@Search
public IBaseResource paramAndUnderscoreTest(@RequiredParam(name = "param") String param, @OptionalParam(name = "_test") String test) {
return null;
}
@Search
public IBaseResource withChainBlacklist(@OptionalParam(name = "refChainBlacklist", chainWhitelist = "goodChain", chainBlacklist = "badChain") ReferenceParam param) {
return null;
}
}
} }

View File

@ -45,7 +45,7 @@ import java.util.*;
import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
public class XmlParserDstu2_1Test { public class XmlParserDstu2_1Test {

View File

@ -0,0 +1,369 @@
{
"resourceType": "Bundle",
"id": "1f3236fa-2fab-453d-86e8-72387929257c",
"meta": {
"lastUpdated": "2019-04-04T17:53:00.051-04:00"
},
"type": "searchset",
"total": 2,
"link": [
{
"relation": "self",
"url": "https://uhndigitalfhir-dev.uhn.ca/uhn-fhir-service-v2/DiagnosticReport?_include=DiagnosticReport%3Aresult&_query=findDiagnosticReportsByPatientWithIssuedDate&code=urn%3Aoid%3A1.3.6.1.4.1.12201.102.5%7C491&issued=ge2000-08-07&subject%3Aidentifier=urn%3Aoid%3A2.16.840.1.113883.3.239.18.148%7C7001316"
}
],
"entry": [
{
"fullUrl": "https://uhndigitalfhir-dev.uhn.ca/uhn-fhir-service-v2/DiagnosticReport/5541279",
"resource": {
"resourceType": "DiagnosticReport",
"id": "5541279",
"meta": {
"profile": [
"http://fhir.uhn.ca/Profile/diagnosticreport"
]
},
"contained": [
{
"resourceType": "Observation",
"id": "1",
"meta": {
"profile": [
"http://fhir.uhn.ca/Profile/observation"
]
},
"extension": [
{
"url": "http://fhir.uhn.ca/Profile/observation#source_system_status",
"valueString": "F"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#lastUpdatedDateTime",
"valueInstant": "2007-07-30T14:48:41.000-04:00"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#createDateTime",
"valueInstant": "2007-07-30T14:48:41.000-04:00"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#sequence",
"valueString": "1"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#diagnosticReport",
"valueReference": {
"reference": "DiagnosticReport/5541279"
}
}
],
"status": "final",
"code": {
"coding": [
{
"system": "urn:oid:1.3.6.1.4.1.12201.102.6",
"code": "01005.1"
}
],
"text": "Creatinine"
},
"subject": {
"reference": "Patient/5556360"
},
"issued": "2007-07-30T14:48:41.000-04:00",
"valueQuantity": {
"value": 72.0,
"unit": "umol/L"
},
"interpretation": {
"coding": [
{
"system": "urn:uhn:qcpr:interpretation_codes",
"code": "N"
}
]
},
"referenceRange": [
{
"meaning": {
"text": "<=99"
}
}
]
},
{
"resourceType": "Observation",
"id": "2",
"meta": {
"profile": [
"http://fhir.uhn.ca/Profile/observation"
]
},
"extension": [
{
"url": "http://fhir.uhn.ca/Profile/observation#source_system_status",
"valueString": "F"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#lastUpdatedDateTime",
"valueInstant": "2007-07-30T14:48:41.000-04:00"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#createDateTime",
"valueInstant": "2007-07-30T14:48:41.000-04:00"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#sequence",
"valueString": "2"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#diagnosticReport",
"valueReference": {
"reference": "DiagnosticReport/5541279"
}
}
],
"status": "final",
"code": {
"coding": [
{
"system": "urn:oid:1.3.6.1.4.1.12201.102.6",
"code": "01439.2"
}
],
"text": "Tech Comment"
},
"subject": {
"reference": "Patient/5556360"
},
"issued": "2007-07-30T14:48:41.000-04:00",
"valueString": "Req#T07-104306,.",
"interpretation": {
"coding": [
{
"system": "urn:uhn:qcpr:interpretation_codes",
"code": "N"
}
]
}
}
],
"extension": [
{
"url": "http://fhir.uhn.ca/Profile/diagnosticreport#source_system_status",
"valueString": "F"
},
{
"url": "http://fhir.uhn.ca/Profile/diagnosticreport#lastUpdatedDateTime",
"valueInstant": "2007-07-30T14:48:41.000-04:00"
},
{
"url": "http://fhir.uhn.ca/Profile/diagnosticreport#createDateTime",
"valueInstant": "2007-07-30T14:48:41.000-04:00"
},
{
"url": "http://fhir.uhn.ca/Profile/diagnosticreport#terminologyCodesFromQuery",
"valueCoding": {
"system": "urn:oid:1.3.6.1.4.1.12201.102.5",
"code": "491"
}
}
],
"identifier": [
{
"system": "urn:uhn:qcpr:order_ids",
"value": "651621"
}
],
"status": "final",
"code": {
"coding": [
{
"system": "urn:oid:1.3.6.1.4.1.12201.102.5",
"code": "491"
}
],
"text": "Creatinine, Plasma"
},
"subject": {
"reference": "Patient/5556360"
},
"encounter": {
"reference": "Encounter/5556361"
},
"effectiveDateTime": "2007-04-26T14:36:00-04:00",
"issued": "2007-07-30T14:48:41.000-04:00",
"result": [
{
"reference": "#1"
},
{
"reference": "#2"
}
]
}
},
{
"fullUrl": "https://uhndigitalfhir-dev.uhn.ca/uhn-fhir-service-v2/DiagnosticReport/5777012",
"resource": {
"resourceType": "DiagnosticReport",
"id": "5777012",
"meta": {
"profile": [
"http://fhir.uhn.ca/Profile/diagnosticreport"
]
},
"contained": [
{
"resourceType": "Observation",
"id": "1",
"meta": {
"profile": [
"http://fhir.uhn.ca/Profile/observation"
]
},
"extension": [
{
"url": "http://fhir.uhn.ca/Profile/observation#source_system_status",
"valueString": "I"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#lastUpdatedDateTime",
"valueInstant": "2008-03-31T15:09:39.000-04:00"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#createDateTime",
"valueInstant": "2008-03-31T15:09:39.000-04:00"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#sequence",
"valueString": "1"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#diagnosticReport",
"valueReference": {
"reference": "DiagnosticReport/5777012"
}
}
],
"status": "preliminary",
"code": {
"coding": [
{
"system": "urn:oid:1.3.6.1.4.1.12201.102.6",
"code": "4.1"
}
],
"text": "When"
},
"subject": {
"reference": "Patient/5556360"
},
"issued": "2008-03-31T15:09:39.000-04:00",
"valueString": "Monday, 31 March 08 1508 Rout"
},
{
"resourceType": "Observation",
"id": "2",
"meta": {
"profile": [
"http://fhir.uhn.ca/Profile/observation"
]
},
"extension": [
{
"url": "http://fhir.uhn.ca/Profile/observation#source_system_status",
"valueString": "I"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#lastUpdatedDateTime",
"valueInstant": "2008-03-31T15:09:39.000-04:00"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#createDateTime",
"valueInstant": "2008-03-31T15:09:39.000-04:00"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#sequence",
"valueString": "2"
},
{
"url": "http://fhir.uhn.ca/Profile/observation#diagnosticReport",
"valueReference": {
"reference": "DiagnosticReport/5777012"
}
}
],
"status": "preliminary",
"code": {
"coding": [
{
"system": "urn:oid:1.3.6.1.4.1.12201.102.6",
"code": "5.2"
}
],
"text": "Specimen"
},
"subject": {
"reference": "Patient/5556360"
},
"issued": "2008-03-31T15:09:39.000-04:00",
"valueString": "Blood Plasma - Bio (Green)"
}
],
"extension": [
{
"url": "http://fhir.uhn.ca/Profile/diagnosticreport#source_system_status",
"valueString": "I"
},
{
"url": "http://fhir.uhn.ca/Profile/diagnosticreport#lastUpdatedDateTime",
"valueInstant": "2008-03-31T15:09:39.000-04:00"
},
{
"url": "http://fhir.uhn.ca/Profile/diagnosticreport#createDateTime",
"valueInstant": "2008-03-31T15:09:39.000-04:00"
},
{
"url": "http://fhir.uhn.ca/Profile/diagnosticreport#terminologyCodesFromQuery",
"valueCoding": {
"system": "urn:oid:1.3.6.1.4.1.12201.102.5",
"code": "491"
}
}
],
"identifier": [
{
"system": "urn:uhn:qcpr:order_ids",
"value": "814177"
}
],
"status": "registered",
"code": {
"coding": [
{
"system": "urn:oid:1.3.6.1.4.1.12201.102.5",
"code": "491"
}
],
"text": "Creatinine, Plasma"
},
"subject": {
"reference": "Patient/5556360"
},
"encounter": {
"reference": "Encounter/5606097"
},
"effectiveDateTime": "2008-03-31T15:09:00-04:00",
"issued": "2008-03-31T15:09:39.000-04:00",
"result": [
{
"reference": "#1"
},
{
"reference": "#2"
}
]
}
}
]
}