iAdd some tests

This commit is contained in:
James Agnew 2015-08-28 18:00:32 -04:00
parent 3ad993dc71
commit eaa2519696
9 changed files with 171 additions and 214 deletions

View File

@ -52,7 +52,6 @@ import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
import org.hl7.fhir.instance.model.api.IBaseDatatype;
import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
import org.hl7.fhir.instance.model.api.IBaseEnumFactory;
import org.hl7.fhir.instance.model.api.IBaseEnumeration;
import org.hl7.fhir.instance.model.api.IBaseExtension;
import org.hl7.fhir.instance.model.api.IBaseReference;
@ -626,12 +625,6 @@ class ModelScanner {
} else if (IBaseEnumeration.class.isAssignableFrom(nextElementType)) {
Class<?> binderType = ReflectionUtil.getGenericCollectionTypeOfFieldWithSecondOrderForList(next);
def = new RuntimeChildPrimitiveEnumerationDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype, binderType);
} else if (childAnnotation.enumFactory().getSimpleName().equals("NoEnumFactory") == false) {
Class<? extends IBaseEnumFactory<?>> enumFactory = childAnnotation.enumFactory();
def = new RuntimeChildEnumerationDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype, enumFactory);
// } else if ("id".equals(elementName) && IIdType.class.isAssignableFrom(nextDatatype)) {
// def = new RuntimeChildIdDatatypeDefinition(next, elementName, descriptionAnnotation,
// childAnnotation, nextDatatype);
} else {
def = new RuntimeChildPrimitiveDatatypeDefinition(next, elementName, descriptionAnnotation, childAnnotation, nextDatatype);
}

View File

@ -1,59 +0,0 @@
package ca.uhn.fhir.context;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2015 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 java.lang.reflect.Field;
import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseEnumFactory;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Description;
public class RuntimeChildEnumerationDatatypeDefinition extends RuntimeChildPrimitiveDatatypeDefinition {
private Class<? extends IBaseEnumFactory<?>> myBinderType;
private volatile IBaseEnumFactory<?> myBinder;
public RuntimeChildEnumerationDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IBase> theDatatype,
Class<? extends IBaseEnumFactory<?>> theBinderType) {
super(theField, theElementName, theDescriptionAnnotation, theChildAnnotation, theDatatype);
myBinderType = theBinderType;
}
@Override
public IBaseEnumFactory<?> getInstanceConstructorArguments() {
IBaseEnumFactory<?> retVal = myBinder;
if (retVal == null) {
try {
retVal = myBinderType.newInstance();
} catch (InstantiationException e) {
throw new IllegalStateException("Failed to instantiate " + myBinderType, e);
} catch (IllegalAccessException e) {
throw new IllegalStateException("Failed to instantiate " + myBinderType, e);
}
myBinder = retVal;
}
return retVal;
}
}

View File

@ -21,6 +21,7 @@ package ca.uhn.fhir.model.api;
*/
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@ -32,66 +33,56 @@ import ca.uhn.fhir.model.primitive.CodeDt;
import ca.uhn.fhir.model.primitive.IdDt;
/**
* This interface is the parent interface for all FHIR Resource definition
* classes. Classes implementing this interface should be annotated
* with the {@link ResourceDef @ResourceDef} annotation.
* This interface is the parent interface for all FHIR Resource definition classes. Classes implementing this interface should be annotated with the {@link ResourceDef @ResourceDef} annotation.
*
* <p>
* Note that this class is a part of HAPI's model API, used to define
* structure classes. Users will often interact with this interface, but
* should not need to implement it directly.
* Note that this class is a part of HAPI's model API, used to define structure classes. Users will often interact with this interface, but should not need to implement it directly.
* </p>
*/
public interface IResource extends ICompositeElement, org.hl7.fhir.instance.model.api.IBaseResource {
public static final Include INCLUDE_ALL = new Include("*");
public static final Set<Include> WILDCARD_ALL_SET = new HashSet<Include>(Arrays.asList(INCLUDE_ALL));
/**
* Include constant for <code>*</code> (return all includes)
*/
public static final Include INCLUDE_ALL = new Include("*", true);
/**
/**
* Include set containing only {@link #INCLUDE_ALL}
*/
public static final Set<Include> WILDCARD_ALL_SET = Collections.unmodifiableSet(new HashSet<Include>(Arrays.asList(INCLUDE_ALL)));
/**
* Returns the contained resource list for this resource.
* <p>
* Usage note: HAPI will generally populate and use the resources from this
* list automatically (placing inline resources in the contained list when
* encoding, and copying contained resources from this list to their
* appropriate references when parsing) so it is generally not neccesary to
* interact with this list directly. Instead, in a server you can place
* resource instances in reference fields (such as <code>Patient#setManagingOrganization(ResourceReferenceDt)</code> )
* and the resource will be automatically contained. In a client, contained resources will
* be automatically populated into their appropriate fields by the HAPI parser.
* Usage note: HAPI will generally populate and use the resources from this list automatically (placing inline resources in the contained list when encoding, and copying contained resources from
* this list to their appropriate references when parsing) so it is generally not neccesary to interact with this list directly. Instead, in a server you can place resource instances in reference
* fields (such as <code>Patient#setManagingOrganization(ResourceReferenceDt)</code> ) and the resource will be automatically contained. In a client, contained resources will be automatically
* populated into their appropriate fields by the HAPI parser.
* </p>
* TODO: document contained resources and link there
*/
BaseContainedDt getContained();
/**
* Returns the ID of this resource. Note that this identifier is the URL (or a portion
* of the URL) used to access this resource, and is not the same thing as any business
* identifiers stored within the resource. For example, a Patient resource might
* have any number of medical record numbers but these are not stored here.
* Returns the ID of this resource. Note that this identifier is the URL (or a portion of the URL) used to access this resource, and is not the same thing as any business identifiers stored within
* the resource. For example, a Patient resource might have any number of medical record numbers but these are not stored here.
* <p>
* This ID is specified as the "Logical ID" and "Version ID" in the FHIR specification, see
* <a href="http://www.hl7.org/implement/standards/fhir/resources.html#metadata">here</a>
* This ID is specified as the "Logical ID" and "Version ID" in the FHIR specification, see <a href="http://www.hl7.org/implement/standards/fhir/resources.html#metadata">here</a>
* </p>
*/
IdDt getId();
/**
* Gets the language of the resource itself - <b>NOTE that this language attribute
* applies to the resource itself, it is not (for example) the language spoken by
* a practitioner or patient</b>
* Gets the language of the resource itself - <b>NOTE that this language attribute applies to the resource itself, it is not (for example) the language spoken by a practitioner or patient</b>
*/
CodeDt getLanguage();
/**
* Returns the metadata map for this object, creating it if neccesary.
* Metadata entries are used to get/set feed bundle entries, such as the
* resource version, or the last updated timestamp.
* Returns the metadata map for this object, creating it if neccesary. Metadata entries are used to get/set feed bundle entries, such as the resource version, or the last updated timestamp.
* <p>
* Keys in this map are enumerated in the {@link ResourceMetadataKeyEnum},
* and each key has a specific value type that it must use.
* Keys in this map are enumerated in the {@link ResourceMetadataKeyEnum}, and each key has a specific value type that it must use.
* </p>
*
* @see ResourceMetadataKeyEnum for a list of allowable keys and the object
* types that values of a given key must use.
* @see ResourceMetadataKeyEnum for a list of allowable keys and the object types that values of a given key must use.
*/
ResourceMetadataMap getResourceMetadata();
@ -99,40 +90,31 @@ public interface IResource extends ICompositeElement, org.hl7.fhir.instance.mode
* Returns the narrative block for this resource
*/
BaseNarrativeDt getText();
/**
* Sets the ID of this resource. Note that this identifier is the URL (or a portion
* of the URL) used to access this resource, and is not the same thing as any business
* identifiers stored within the resource. For example, a Patient resource might
* have any number of medical record numbers but these are not stored here.
* Sets the ID of this resource. Note that this identifier is the URL (or a portion of the URL) used to access this resource, and is not the same thing as any business identifiers stored within the
* resource. For example, a Patient resource might have any number of medical record numbers but these are not stored here.
* <p>
* This ID is specified as the "Logical ID" and "Version ID" in the FHIR specification, see
* <a href="http://www.hl7.org/implement/standards/fhir/resources.html#metadata">here</a>
* This ID is specified as the "Logical ID" and "Version ID" in the FHIR specification, see <a href="http://www.hl7.org/implement/standards/fhir/resources.html#metadata">here</a>
* </p>
*/
void setId(IdDt theId);
/**
* Sets the language of the resource itself - <b>NOTE that this language attribute
* applies to the resource itself, it is not (for example) the language spoken by
* a practitioner or patient</b>
* Sets the language of the resource itself - <b>NOTE that this language attribute applies to the resource itself, it is not (for example) the language spoken by a practitioner or patient</b>
*/
void setLanguage(CodeDt theLanguage);
/**
* Sets the metadata map for this object. Metadata entries are used to
* get/set feed bundle entries, such as the resource version, or the last
* updated timestamp.
* Sets the metadata map for this object. Metadata entries are used to get/set feed bundle entries, such as the resource version, or the last updated timestamp.
*
* @throws NullPointerException
* The map must not be null
* The map must not be null
*/
void setResourceMetadata(ResourceMetadataMap theMap);
/**
* Returns a String representing the name of this Resource. This return
* value is not used for anything by HAPI itself, but is provided as a
* convenience to developers using the API.
* Returns a String representing the name of this Resource. This return value is not used for anything by HAPI itself, but is provided as a convenience to developers using the API.
*
* @return the name of this resource, e.g. "Patient", or "Observation"
*/
@ -141,7 +123,6 @@ public interface IResource extends ICompositeElement, org.hl7.fhir.instance.mode
/**
* Returns the FHIR version represented by this structure
*/
public ca.uhn.fhir.context.FhirVersionEnum getStructureFhirVersionEnum();
public ca.uhn.fhir.context.FhirVersionEnum getStructureFhirVersionEnum();
}

View File

@ -33,11 +33,17 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
public class Include {
private String myValue;
private boolean myImmutable;
public Include(String theValue) {
myValue = theValue;
}
public Include(String theValue, boolean theImmutable) {
myValue = theValue;
myImmutable = theImmutable;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
@ -68,6 +74,9 @@ public class Include {
}
public void setValue(String theValue) {
if (myImmutable) {
throw new IllegalStateException("Can not change the value of this include");
}
myValue = theValue;
}

View File

@ -24,11 +24,6 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Enumeration;
import net.sourceforge.cobertura.CoverageIgnore;
import org.hl7.fhir.instance.model.api.IBaseEnumFactory;
import ca.uhn.fhir.model.api.IElement;
@ -112,32 +107,4 @@ public @interface Child {
*/
boolean summary() default false;
/**
* For children which accept an {@link Enumeration} as the type, this
* field indicates the type to use for the enum factory
*/
Class<? extends IBaseEnumFactory<?>> enumFactory() default NoEnumFactory.class;
@CoverageIgnore
public static class NoEnumFactory implements IBaseEnumFactory<Enum<?>> {
@CoverageIgnore
private NoEnumFactory() {
// non instantiable
}
@CoverageIgnore
@Override
public Enum<?> fromCode(String theCodeString) throws IllegalArgumentException {
return null;
}
@CoverageIgnore
@Override
public String toCode(Enum<?> theCode) {
return null;
}
}
}

View File

@ -15,6 +15,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.naming.InsufficientResourcesException;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.hamcrest.Matchers;
@ -2117,7 +2119,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaTest {
// * include
SearchParameterMap params = new SearchParameterMap();
params.add(Patient.SP_FAMILY, new StringDt("Tester_testSearchWithIncludes_P1"));
params.addInclude(new Include("*"));
params.addInclude(IResource.INCLUDE_ALL);
IBundleProvider search = ourPatientDao.search(params);
List<IResource> patients = toList(search);
assertEquals(3, patients.size());

View File

@ -6,8 +6,14 @@ import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
@ -21,6 +27,7 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.testutil.RandomServerPortProvider;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.IResource;
@ -63,6 +70,8 @@ public class ResourceProviderDstu1Test extends BaseJpaTest {
// private static IFhirResourceDao<Patient> ourPatientDao;
// private static IFhirResourceDao<Questionnaire> ourQuestionnaireDao;
private static Server ourServer;
private static String ourServerBase;
private static CloseableHttpClient ourHttpClient;
// private static JpaConformanceProvider ourConfProvider;
@ -482,6 +491,22 @@ public class ResourceProviderDstu1Test extends BaseJpaTest {
assertEquals(p1Id.getIdPart(), actual.getEntries().get(0).getId().getIdPart());
}
@Test
public void testMetadata() throws Exception {
HttpGet get = new HttpGet(ourServerBase + "/metadata");
CloseableHttpResponse response = ourHttpClient.execute(get);
try {
String resp = IOUtils.toString(response.getEntity().getContent());
ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode());
assertThat(resp, stringContainsInOrder("THIS IS THE DESC"));
} finally {
IOUtils.closeQuietly(response.getEntity().getContent());
response.close();
}
}
@AfterClass
public static void afterClass() throws Exception {
@ -496,7 +521,7 @@ public class ResourceProviderDstu1Test extends BaseJpaTest {
RestfulServer restServer = new RestfulServer(ourCtx);
String serverBase = "http://localhost:" + port + "/fhir/context";
ourServerBase = "http://localhost:" + port + "/fhir/context";
ourAppCtx = new ClassPathXmlApplicationContext("hapi-fhir-server-resourceproviders-dstu1.xml", "fhir-jpabase-spring-test-config.xml");
@ -514,6 +539,11 @@ public class ResourceProviderDstu1Test extends BaseJpaTest {
restServer.setPagingProvider(new FifoMemoryPagingProvider(10));
IFhirSystemDao<List<IResource>> systemDao = ourAppCtx.getBean(IFhirSystemDao.class);
JpaConformanceProviderDstu1 confProvider = new JpaConformanceProviderDstu1(restServer, systemDao);
confProvider.setImplementationDescription("THIS IS THE DESC");
restServer.setServerConformanceProvider(confProvider);
ourServer = new Server(port);
ServletContextHandler proxyHandler = new ServletContextHandler();
@ -526,9 +556,14 @@ public class ResourceProviderDstu1Test extends BaseJpaTest {
ourServer.setHandler(proxyHandler);
ourServer.start();
ourClient = ourCtx.newRestfulGenericClient(serverBase);
ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
ourClient.registerInterceptor(new LoggingInterceptor(true));
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
HttpClientBuilder builder = HttpClientBuilder.create();
builder.setConnectionManager(connectionManager);
ourHttpClient = builder.build();
}
}

View File

@ -58,6 +58,7 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.testutil.RandomServerPortProvider;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.BundleEntry;
@ -123,9 +124,6 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu2Test.class);
private static IFhirResourceDao<Organization> ourOrganizationDao;
private static int ourPort;
// private static IFhirResourceDao<Observation> ourObservationDao;
// private static IFhirResourceDao<Patient> ourPatientDao;
// private static IFhirResourceDao<Questionnaire> ourQuestionnaireDao;
private static Server ourServer;
private static String ourServerBase;
@ -1060,7 +1058,7 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
ourLog.info(resp);
ca.uhn.fhir.model.dstu2.resource.Bundle bundle = ourCtx.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, resp);
matches = bundle.getTotal();
assertThat(matches, greaterThan(0));
}
@ -1627,6 +1625,21 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
ourHttpClient.close();
}
@Test
public void testMetadata() throws Exception {
HttpGet get = new HttpGet(ourServerBase + "/metadata");
CloseableHttpResponse response = ourHttpClient.execute(get);
try {
String resp = IOUtils.toString(response.getEntity().getContent());
ourLog.info(resp);
assertEquals(200, response.getStatusLine().getStatusCode());
assertThat(resp, stringContainsInOrder("THIS IS THE DESC"));
} finally {
IOUtils.closeQuietly(response.getEntity().getContent());
response.close();
}
}
@SuppressWarnings("unchecked")
@BeforeClass
public static void beforeClass() throws Exception {
@ -1651,6 +1664,11 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
JpaSystemProviderDstu2 systemProv = ourAppCtx.getBean(JpaSystemProviderDstu2.class, "mySystemProviderDstu2");
restServer.setPlainProviders(systemProv);
IFhirSystemDao<ca.uhn.fhir.model.dstu2.resource.Bundle> systemDao = ourAppCtx.getBean(IFhirSystemDao.class);
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(restServer, systemDao);
confProvider.setImplementationDescription("THIS IS THE DESC");
restServer.setServerConformanceProvider(confProvider);
restServer.setPagingProvider(new FifoMemoryPagingProvider(10));
ourServer = new Server(ourPort);

View File

@ -13,6 +13,7 @@ import org.junit.Test;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
@ -25,16 +26,72 @@ public class ResourceMethodTest {
private SearchMethodBinding rm;
@Search
public Bundle foo() {
return null;
}
@Before
public void before() throws NoSuchMethodException, SecurityException {
rm = new SearchMethodBinding(Patient.class, ResourceMethodTest.class.getMethod("foo"), FhirContext.forDstu1(), null);
}
@Search
public Bundle foo() {
return null;
}
@Test
public void testAllParams() {
List<IParameter> methodParams = new ArrayList<IParameter>();
methodParams.add(new SearchParameter("firstName", false));
methodParams.add(new SearchParameter("lastName", false));
methodParams.add(new SearchParameter("mrn", true));
rm.setParameters(methodParams);
Set<String> inputParams = new HashSet<String>();
inputParams.add("firstName");
inputParams.add("lastName");
inputParams.add("mrn");
RequestDetails params = RequestDetails.withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams);
boolean actual = rm.incomingServerRequestMatchesMethod(params);
assertTrue( actual); // True
}
@Test
public void testAllParamsWithExtra() {
List<IParameter> methodParams = new ArrayList<IParameter>();
methodParams.add(new SearchParameter("firstName", false));
methodParams.add(new SearchParameter("lastName", false));
methodParams.add(new SearchParameter("mrn", true));
rm.setParameters(methodParams);
Set<String> inputParams = new HashSet<String>();
inputParams.add("firstName");
inputParams.add("lastName");
inputParams.add("mrn");
inputParams.add("foo");
assertEquals(false, rm.incomingServerRequestMatchesMethod(RequestDetails.withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams))); // False
}
@Test
public void testMixedParams() {
List<IParameter> methodParams = new ArrayList<IParameter>();
methodParams.add(new SearchParameter("firstName", false));
methodParams.add(new SearchParameter("lastName", false));
methodParams.add(new SearchParameter("mrn", true));
rm.setParameters(methodParams);
Set<String> inputParams = new HashSet<String>();
inputParams.add("firstName");
inputParams.add("mrn");
assertEquals(true, rm.incomingServerRequestMatchesMethod(RequestDetails.withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams))); // True
}
@Test
public void testRequiredParamsMissing() {
List<IParameter> methodParams = new ArrayList<IParameter>();
@ -67,59 +124,13 @@ public class ResourceMethodTest {
assertEquals(true, rm.incomingServerRequestMatchesMethod(RequestDetails.withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams))); // True
}
@Test
public void testMixedParams() {
List<IParameter> methodParams = new ArrayList<IParameter>();
methodParams.add(new SearchParameter("firstName", false));
methodParams.add(new SearchParameter("lastName", false));
methodParams.add(new SearchParameter("mrn", true));
rm.setParameters(methodParams);
Set<String> inputParams = new HashSet<String>();
inputParams.add("firstName");
inputParams.add("mrn");
assertEquals(true, rm.incomingServerRequestMatchesMethod(RequestDetails.withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams))); // True
@Test(expected=IllegalStateException.class)
public void testWildcardImmutable() {
IResource.INCLUDE_ALL.setValue("AAA");
}
@Test
public void testAllParams() {
List<IParameter> methodParams = new ArrayList<IParameter>();
methodParams.add(new SearchParameter("firstName", false));
methodParams.add(new SearchParameter("lastName", false));
methodParams.add(new SearchParameter("mrn", true));
rm.setParameters(methodParams);
Set<String> inputParams = new HashSet<String>();
inputParams.add("firstName");
inputParams.add("lastName");
inputParams.add("mrn");
RequestDetails params = RequestDetails.withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams);
boolean actual = rm.incomingServerRequestMatchesMethod(params);
assertTrue( actual); // True
}
@Test
public void testAllParamsWithExtra() {
List<IParameter> methodParams = new ArrayList<IParameter>();
methodParams.add(new SearchParameter("firstName", false));
methodParams.add(new SearchParameter("lastName", false));
methodParams.add(new SearchParameter("mrn", true));
rm.setParameters(methodParams);
Set<String> inputParams = new HashSet<String>();
inputParams.add("firstName");
inputParams.add("lastName");
inputParams.add("mrn");
inputParams.add("foo");
assertEquals(false, rm.incomingServerRequestMatchesMethod(RequestDetails.withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams))); // False
public void testWildcardSet() {
assertTrue(IResource.WILDCARD_ALL_SET.contains(IResource.INCLUDE_ALL));
}
}