Try to get cobertura working
This commit is contained in:
parent
e1196ec70b
commit
a090f5481f
|
@ -19,8 +19,7 @@ before_script:
|
|||
- export MAVEN_SKIP_RC=true
|
||||
|
||||
script:
|
||||
- mvn -e -B clean install && cd hapi-fhir-cobertura && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID clean test jacoco:report coveralls:report
|
||||
|
||||
# - mvn -e -B clean install && cd hapi-fhir-cobertura && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:cobertura coveralls:report
|
||||
# - mvn -e -B clean install && cd hapi-fhir-cobertura && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID clean test jacoco:report coveralls:report
|
||||
- mvn -e -B clean install && cd hapi-fhir-cobertura && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:cobertura coveralls:report
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class TestUtil {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TestUtil.class);
|
||||
|
||||
/**
|
||||
* THIS IS FOR UNIT TESTS ONLY
|
||||
*/
|
||||
@CoverageIgnore
|
||||
public static void clearAllStaticFieldsForUnitTest() {
|
||||
|
||||
Class<?> theType;
|
||||
try {
|
||||
throw new Exception();
|
||||
} catch (Exception e) {
|
||||
StackTraceElement[] st = e.getStackTrace();
|
||||
StackTraceElement elem = st[1];
|
||||
String clazzName = elem.getClassName();
|
||||
try {
|
||||
theType = Class.forName(clazzName);
|
||||
} catch (ClassNotFoundException e1) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
for (Field next : Arrays.asList(theType.getDeclaredFields())) {
|
||||
if (Modifier.isStatic(next.getModifiers())) {
|
||||
if (!Modifier.isFinal(next.getModifiers()) && !next.getType().isPrimitive()) {
|
||||
ourLog.info("Clearing value of field: {}", next.toString());
|
||||
try {
|
||||
next.setAccessible(true);
|
||||
next.set(theType, null);
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -296,7 +296,7 @@
|
|||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<runOrder>alphabetical</runOrder>
|
||||
<argLine>-Xmx1024m</argLine>
|
||||
<argLine>-Xmx1624m</argLine>
|
||||
<redirectTestOutputToFile>true</redirectTestOutputToFile>
|
||||
<!--<reportFormat>plain</reportFormat>-->
|
||||
<!--<argLine>-Xmx600m -XX:+HeapDumpOnOutOfMemoryError</argLine>-->
|
||||
|
@ -400,21 +400,4 @@
|
|||
</plugins>
|
||||
</reporting>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>TRAVIS</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- Travis build seems to run out of memory unless we don't reuse JVMs -->
|
||||
<reuseForks>false</reuseForks>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
@ -2,6 +2,7 @@ package ca.uhn.fhir.jpa.dao;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -12,11 +13,18 @@ import ca.uhn.fhir.model.primitive.DateTimeDt;
|
|||
import ca.uhn.fhir.rest.annotation.ResourceParam;
|
||||
import ca.uhn.fhir.rest.param.ReferenceParam;
|
||||
import ca.uhn.fhir.rest.param.ResourceParameter;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class BaseFhirDaoTest extends BaseJpaTest {
|
||||
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testTranslateMatchUrl() {
|
||||
SearchParameterMap match = BaseHapiFhirDao.translateMatchUrl("Condition?patient=304&_lastUpdated=>2011-01-01T11:12:21.0000Z", ourCtx.getResourceDefinition(Condition.class));
|
||||
|
|
|
@ -51,12 +51,19 @@ import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry;
|
|||
import ca.uhn.fhir.rest.method.IRequestOperationCallback;
|
||||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class BaseJpaTest {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseJpaTest.class);
|
||||
protected ServletRequestDetails mySrd;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
protected List toList(IBundleProvider theSearch) {
|
||||
return theSearch.getResources(0, theSearch.size());
|
||||
|
|
|
@ -27,6 +27,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class FhirResourceDaoDstu1Test extends BaseJpaTest {
|
||||
|
@ -124,11 +125,6 @@ public class FhirResourceDaoDstu1Test extends BaseJpaTest {
|
|||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() {
|
||||
ourCtx.close();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@BeforeClass
|
||||
public static void beforeClass() {
|
||||
|
@ -143,4 +139,10 @@ public class FhirResourceDaoDstu1Test extends BaseJpaTest {
|
|||
ourFhirCtx = ourCtx.getBean(FhirContext.class);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
ourCtx.close();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ import ca.uhn.fhir.rest.method.RequestDetails;
|
|||
import ca.uhn.fhir.rest.param.TokenParam;
|
||||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirSystemDaoDstu1Test extends BaseJpaTest {
|
||||
|
||||
|
@ -65,6 +65,13 @@ public class FhirSystemDaoDstu1Test extends BaseJpaTest {
|
|||
private static EntityManager ourEntityManager;
|
||||
private static PlatformTransactionManager ourTxManager;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
ourCtx.close();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
myRequestDetails = mock(RequestDetails.class);
|
||||
|
@ -476,10 +483,6 @@ public class FhirSystemDaoDstu1Test extends BaseJpaTest {
|
|||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() {
|
||||
ourCtx.close();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@BeforeClass
|
||||
|
|
|
@ -6,13 +6,21 @@ import static org.junit.Assert.*;
|
|||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.rest.param.ParamPrefixEnum;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class SearchBuilderTest {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchBuilderTest.class);
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAA() {
|
||||
assertTrue(123.00004f <= 123.0001f);
|
||||
|
|
|
@ -9,16 +9,24 @@ import javax.servlet.ServletConfig;
|
|||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
|
||||
import ca.uhn.fhir.jpa.rp.dstu2.PatientResourceProvider;
|
||||
import ca.uhn.fhir.rest.method.IRequestOperationCallback;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public abstract class BaseJpaDstu2SystemTest extends BaseJpaDstu2Test {
|
||||
private RestfulServer myServer;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Before
|
||||
public void before() throws ServletException {
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.hibernate.search.jpa.FullTextEntityManager;
|
||||
import org.hibernate.search.jpa.Search;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -63,6 +64,7 @@ import ca.uhn.fhir.model.dstu2.resource.ValueSet;
|
|||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.rest.method.MethodUtil;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
//@formatter:off
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
|
@ -70,6 +72,12 @@ import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
|||
//@formatter:on
|
||||
public abstract class BaseJpaDstu2Test extends BaseJpaTest {
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
protected ApplicationContext myAppCtx;
|
||||
@Autowired
|
||||
|
|
|
@ -8,6 +8,7 @@ import static org.mockito.Mockito.times;
|
|||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
@ -19,12 +20,19 @@ import ca.uhn.fhir.model.dstu2.resource.Patient;
|
|||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirResourceDaoDstu2InterceptorTest extends BaseJpaDstu2Test {
|
||||
|
||||
private IJpaServerInterceptor myJpaInterceptor;
|
||||
private JpaServerInterceptorAdapter myJpaInterceptorAdapter = new JpaServerInterceptorAdapter();
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
myDaoConfig.getInterceptors().remove(myJpaInterceptor);
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.List;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.FulltextSearchSvcImpl.Suggestion;
|
||||
|
@ -29,11 +30,18 @@ import ca.uhn.fhir.rest.param.StringOrListParam;
|
|||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirResourceDaoDstu2SearchFtTest extends BaseJpaDstu2Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu2SearchFtTest.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSuggestIgnoresBase64Content() {
|
||||
Patient patient = new Patient();
|
||||
|
|
|
@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -97,11 +98,18 @@ import ca.uhn.fhir.rest.server.IBundleProvider;
|
|||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FhirResourceDaoDstu2SearchNoFtTest extends BaseJpaDstu2Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu2SearchNoFtTest.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCodeSearch() {
|
||||
Subscription subs = new Subscription();
|
||||
|
|
|
@ -21,6 +21,7 @@ import javax.persistence.TypedQuery;
|
|||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -39,11 +40,18 @@ import ca.uhn.fhir.rest.server.IBundleProvider;
|
|||
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirResourceDaoDstu2SubscriptionTest extends BaseJpaDstu2Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu2SubscriptionTest.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private ISubscriptionFlaggedResourceDataDao mySubscriptionFlaggedResourceDataDao;
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.hamcrest.Matchers;
|
|||
import org.hamcrest.core.StringContains;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
|
@ -106,12 +107,19 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu2Test.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
private void assertGone(IIdType theId) {
|
||||
try {
|
||||
assertNotGone(theId);
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Set;
|
|||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
|
@ -45,10 +46,17 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirResourceDaoDstu2UpdateTest extends BaseJpaDstu2Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu2UpdateTest.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUpdateAndGetHistoryResource() throws InterruptedException {
|
||||
Patient patient = new Patient();
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.io.IOException;
|
|||
import java.util.Arrays;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
|
@ -29,10 +30,17 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirResourceDaoDstu2ValidateTest extends BaseJpaDstu2Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu2ValidateTest.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testValidateResourceContainingProfileDeclarationJson() throws Exception {
|
||||
String methodName = "testValidateResourceContainingProfileDeclarationJson";
|
||||
|
|
|
@ -11,6 +11,7 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -25,6 +26,7 @@ import ca.uhn.fhir.model.primitive.IdDt;
|
|||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirResourceDaoValueSetDstu2Test extends BaseJpaDstu2Test {
|
||||
|
||||
|
@ -32,6 +34,12 @@ public class FhirResourceDaoValueSetDstu2Test extends BaseJpaDstu2Test {
|
|||
|
||||
private IIdType myExtensionalVsId;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Before
|
||||
@Transactional
|
||||
|
|
|
@ -6,6 +6,7 @@ import static org.junit.Assert.assertThat;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
@ -18,9 +19,16 @@ import ca.uhn.fhir.rest.param.StringOrListParam;
|
|||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private IFulltextSearchSvc mySearchDao;
|
||||
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
package ca.uhn.fhir.jpa.dao.dstu2;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirSystemDaoDstu2SearchTest extends BaseJpaDstu2SystemTest {
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSearchByParans() {
|
||||
// code to come.. just here to prevent a failure
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
|
@ -66,11 +67,18 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirSystemDaoDstu2Test.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReindexing() {
|
||||
Patient p = new Patient();
|
||||
|
|
|
@ -9,17 +9,25 @@ import javax.servlet.ServletConfig;
|
|||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
|
||||
import ca.uhn.fhir.jpa.rp.dstu3.PatientResourceProvider;
|
||||
import ca.uhn.fhir.rest.method.IRequestOperationCallback;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public abstract class BaseJpaDstu3SystemTest extends BaseJpaDstu3Test {
|
||||
protected ServletRequestDetails mySrd;
|
||||
private RestfulServer myServer;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Before
|
||||
public void before() throws ServletException {
|
||||
|
|
|
@ -74,6 +74,7 @@ import ca.uhn.fhir.jpa.validation.JpaValidationSupportChainDstu3;
|
|||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.rest.method.MethodUtil;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
//@formatter:off
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
|
@ -84,6 +85,12 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
|
|||
private static IFhirResourceDaoValueSet<ValueSet, Coding, CodeableConcept> ourValueSetDao;
|
||||
private static JpaValidationSupportChainDstu3 ourJpaValidationSupportChainDstu3;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private JpaValidationSupportChainDstu3 myJpaValidationSupportChainDstu3;
|
||||
@Autowired
|
||||
|
|
|
@ -7,16 +7,24 @@ import org.hl7.fhir.dstu3.model.Observation;
|
|||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.hl7.fhir.dstu3.model.Reference;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.SearchParameterMap;
|
||||
import ca.uhn.fhir.rest.param.TokenParam;
|
||||
import ca.uhn.fhir.rest.param.TokenParamModifier;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirResourceDaoDstu3ContainedTest extends BaseJpaDstu3Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3ContainedTest.class);
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void before() {
|
||||
myDaoConfig.setIndexContainedResources(true);
|
||||
|
|
|
@ -10,6 +10,7 @@ import static org.mockito.Mockito.verify;
|
|||
import org.hl7.fhir.dstu3.model.IdType;
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
@ -19,12 +20,20 @@ import ca.uhn.fhir.jpa.interceptor.IJpaServerInterceptor;
|
|||
import ca.uhn.fhir.jpa.interceptor.JpaServerInterceptorAdapter;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirResourceDaoDstu3InterceptorTest extends BaseJpaDstu3Test {
|
||||
|
||||
private IJpaServerInterceptor myJpaInterceptor;
|
||||
private JpaServerInterceptorAdapter myJpaInterceptorAdapter = new JpaServerInterceptorAdapter();
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
myDaoConfig.getInterceptors().remove(myJpaInterceptor);
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.hl7.fhir.dstu3.model.Patient;
|
|||
import org.hl7.fhir.dstu3.model.Quantity;
|
||||
import org.hl7.fhir.dstu3.model.StringType;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -34,11 +35,18 @@ import ca.uhn.fhir.rest.param.TokenParam;
|
|||
import ca.uhn.fhir.rest.param.TokenParamModifier;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3SearchFtTest.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testCodeTextSearch() {
|
||||
|
|
|
@ -54,6 +54,7 @@ import org.hl7.fhir.dstu3.model.ValueSet;
|
|||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -92,11 +93,18 @@ import ca.uhn.fhir.rest.server.IBundleProvider;
|
|||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3SearchNoFtTest.class);
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCodeSearch() {
|
||||
Subscription subs = new Subscription();
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType;
|
|||
import org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -39,11 +40,18 @@ import ca.uhn.fhir.rest.server.IBundleProvider;
|
|||
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirResourceDaoDstu3SubscriptionTest extends BaseJpaDstu3Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3SubscriptionTest.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private ISubscriptionFlaggedResourceDataDao mySubscriptionFlaggedResourceDataDao;
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ import org.hl7.fhir.dstu3.model.UriType;
|
|||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
|
@ -104,12 +105,19 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3Test.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
private void assertGone(IIdType theId) {
|
||||
try {
|
||||
assertNotGone(theId);
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.hl7.fhir.dstu3.model.Resource;
|
|||
import org.hl7.fhir.dstu3.model.UriType;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
@ -43,10 +44,17 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3UpdateTest.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUpdateAndGetHistoryResource() throws InterruptedException {
|
||||
Patient patient = new Patient();
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.hl7.fhir.dstu3.model.StructureDefinition;
|
|||
import org.hl7.fhir.dstu3.model.ValueSet;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -29,10 +30,17 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3ValidateTest.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testValidateResourceContainingProfileDeclarationJson() throws Exception {
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.hl7.fhir.dstu3.model.StringType;
|
|||
import org.hl7.fhir.dstu3.model.UriType;
|
||||
import org.hl7.fhir.dstu3.model.ValueSet;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
@ -26,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirResourceDaoValueSetDstu3Test extends BaseJpaDstu3Test {
|
||||
|
||||
|
@ -34,6 +36,12 @@ public class FhirResourceDaoValueSetDstu3Test extends BaseJpaDstu3Test {
|
|||
private IIdType myExtensionalVsId;
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
@Transactional
|
||||
public void before02() throws IOException {
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.List;
|
|||
|
||||
import org.hl7.fhir.dstu3.model.Organization;
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
@ -18,9 +19,16 @@ import ca.uhn.fhir.rest.param.StringOrListParam;
|
|||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private IFulltextSearchSvc mySearchDao;
|
||||
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
package ca.uhn.fhir.jpa.dao.dstu3;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirSystemDaoDstu3SearchTest extends BaseJpaDstu3SystemTest {
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSearchByParans() {
|
||||
// code to come.. just here to prevent a failure
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.hl7.fhir.dstu3.model.ValueSet;
|
|||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
@ -65,11 +66,18 @@ import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirSystemDaoDstu3Test.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReindexing() {
|
||||
Patient p = new Patient();
|
||||
|
|
|
@ -5,17 +5,25 @@ import static org.junit.Assert.*;
|
|||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.dstu3.model.Observation;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jpa.entity.BaseResourceIndexedSearchParam;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamToken;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class SearchParamExtractorDstu3Test {
|
||||
|
||||
private static final FhirContext ourCtx = FhirContext.forDstu3();
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParamWithOrInPath() {
|
||||
Observation obs = new Observation();
|
||||
|
|
|
@ -2,10 +2,19 @@ package ca.uhn.fhir.jpa.entity;
|
|||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class TagTypeEnumTest {
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOrder() {
|
||||
// Ordinals are used in DB columns so the order
|
||||
|
|
|
@ -34,6 +34,7 @@ import ca.uhn.fhir.rest.client.ServerValidationModeEnum;
|
|||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
import ca.uhn.fhir.rest.server.FifoMemoryPagingProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public abstract class BaseResourceProviderDstu2Test extends BaseJpaDstu2Test {
|
||||
|
||||
|
@ -44,6 +45,12 @@ public abstract class BaseResourceProviderDstu2Test extends BaseJpaDstu2Test {
|
|||
protected static String ourServerBase;
|
||||
private static GenericWebApplicationContext ourWebApplicationContext;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
public BaseResourceProviderDstu2Test() {
|
||||
super();
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ import ca.uhn.fhir.rest.server.RestfulServer;
|
|||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class ResourceProviderDstu1Test extends BaseJpaTest {
|
||||
|
||||
|
@ -80,6 +81,14 @@ public class ResourceProviderDstu1Test extends BaseJpaTest {
|
|||
private static String ourServerBase;
|
||||
private static CloseableHttpClient ourHttpClient;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
ourAppCtx.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
// private static JpaConformanceProvider ourConfProvider;
|
||||
|
||||
private void delete(String theResourceType, String theParamName, String theParamValue) {
|
||||
|
@ -515,11 +524,6 @@ public class ResourceProviderDstu1Test extends BaseJpaTest {
|
|||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
ourServer.stop();
|
||||
ourAppCtx.stop();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@BeforeClass
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.apache.http.entity.ContentType;
|
|||
import org.apache.http.entity.StringEntity;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
|
@ -100,12 +101,19 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
|
||||
public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu2Test.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void before() throws Exception {
|
||||
super.before();
|
||||
|
|
|
@ -10,6 +10,7 @@ import static org.junit.Assert.fail;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
@ -24,12 +25,19 @@ import ca.uhn.fhir.model.primitive.StringDt;
|
|||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class ResourceProviderDstu2ValueSetTest extends BaseResourceProviderDstu2Test {
|
||||
|
||||
private IIdType myExtensionalVsId;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu2ValueSetTest.class);
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
@Transactional
|
||||
public void before02() throws IOException {
|
||||
|
|
|
@ -2,12 +2,20 @@ package ca.uhn.fhir.jpa.provider;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.SearchParameterMap.EverythingModeEnum;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class SearchParameterMapTest {
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@link Search} uses these ordinals so they shouldn't get out of order
|
||||
*/
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
|
|||
import org.eclipse.jetty.websocket.client.WebSocketClient;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -32,6 +33,7 @@ import ca.uhn.fhir.model.primitive.IdDt;
|
|||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class SubscriptionsDstu2Test extends BaseResourceProviderDstu2Test {
|
||||
|
||||
|
@ -45,6 +47,12 @@ public class SubscriptionsDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SubscriptionsDstu2Test.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void beforeEnableScheduling() {
|
||||
myDaoConfig.setSchedulingDisabled(false);
|
||||
|
|
|
@ -36,6 +36,7 @@ import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
|||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class SystemProviderDstu1Test extends BaseJpaTest {
|
||||
|
||||
|
@ -65,11 +66,6 @@ public class SystemProviderDstu1Test extends BaseJpaTest {
|
|||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
ourServer.stop();
|
||||
ourAppCtx.stop();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@BeforeClass
|
||||
|
@ -121,5 +117,13 @@ public class SystemProviderDstu1Test extends BaseJpaTest {
|
|||
ourClient = ourCtx.newRestfulGenericClient(serverBase);
|
||||
ourClient.setLogRequestAndResponse(true);
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
ourAppCtx.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ import ca.uhn.fhir.rest.server.RestfulServer;
|
|||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class SystemProviderDstu2Test extends BaseJpaDstu2Test {
|
||||
|
||||
|
@ -63,6 +64,13 @@ public class SystemProviderDstu2Test extends BaseJpaDstu2Test {
|
|||
private static Server ourServer;
|
||||
private static String ourServerBase;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void beforeStartServer() throws Exception {
|
||||
if (myRestServer == null) {
|
||||
|
@ -419,9 +427,5 @@ public class SystemProviderDstu2Test extends BaseJpaDstu2Test {
|
|||
assertEquals(0, respSub.getEntry().size());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
ourServer.stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import ca.uhn.fhir.rest.client.ServerValidationModeEnum;
|
|||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
import ca.uhn.fhir.rest.server.FifoMemoryPagingProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public abstract class BaseResourceProviderDstu3Test extends BaseJpaDstu3Test {
|
||||
|
||||
|
@ -50,6 +51,12 @@ public abstract class BaseResourceProviderDstu3Test extends BaseJpaDstu3Test {
|
|||
private static JpaValidationSupportChainDstu3 myValidationSupport;
|
||||
private static GenericWebApplicationContext ourWebApplicationContext;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
public BaseResourceProviderDstu3Test() {
|
||||
super();
|
||||
}
|
||||
|
|
|
@ -18,18 +18,26 @@ import org.hl7.fhir.dstu3.model.StringType;
|
|||
import org.hl7.fhir.dstu3.model.UriType;
|
||||
import org.hl7.fhir.dstu3.model.ValueSet;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class ResourceProviderDstu3CodeSystemTest extends BaseResourceProviderDstu3Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu3CodeSystemTest.class);
|
||||
private IIdType myExtensionalVsId;
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
@Transactional
|
||||
public void before02() throws IOException {
|
||||
|
|
|
@ -86,6 +86,7 @@ import org.hl7.fhir.dstu3.model.UnsignedIntType;
|
|||
import org.hl7.fhir.dstu3.model.ValueSet;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -107,12 +108,19 @@ import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
|
||||
public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu3Test.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void before() throws Exception {
|
||||
super.before();
|
||||
|
|
|
@ -18,18 +18,26 @@ import org.hl7.fhir.dstu3.model.StringType;
|
|||
import org.hl7.fhir.dstu3.model.UriType;
|
||||
import org.hl7.fhir.dstu3.model.ValueSet;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu3ValueSetTest.class);
|
||||
private IIdType myExtensionalVsId;
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
@Transactional
|
||||
public void before02() throws IOException {
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.junit.Test;
|
|||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.validation.IValidatorModule;
|
||||
import ca.uhn.fhir.validation.ResultSeverityEnum;
|
||||
|
||||
|
@ -28,6 +29,14 @@ public class ResourceProviderQuestionnaireResponseDstu3Test extends BaseResource
|
|||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderQuestionnaireResponseDstu3Test.class);
|
||||
private static RequestValidatingInterceptor ourValidatingInterceptor;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
ourRestServer.unregisterInterceptor(ourValidatingInterceptor);
|
||||
ourValidatingInterceptor = null;
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
|
@ -45,11 +54,6 @@ public class ResourceProviderQuestionnaireResponseDstu3Test extends BaseResource
|
|||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() {
|
||||
ourRestServer.unregisterInterceptor(ourValidatingInterceptor);
|
||||
ourValidatingInterceptor = null;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
|
|
|
@ -11,11 +11,13 @@ import org.apache.commons.lang3.time.DateUtils;
|
|||
import org.hl7.fhir.dstu3.model.Bundle;
|
||||
import org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent;
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.rest.gclient.IQuery;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class StaleSearchDeletingSvcDstu3Test extends BaseResourceProviderDstu3Test {
|
||||
|
||||
|
@ -28,6 +30,13 @@ public class StaleSearchDeletingSvcDstu3Test extends BaseResourceProviderDstu3Te
|
|||
myDaoConfig.setExpireSearchResultsAfterMillis(DateUtils.MILLIS_PER_HOUR);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testEverythingInstanceWithContentFilter() throws Exception {
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType;
|
|||
import org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -30,6 +31,7 @@ import ca.uhn.fhir.model.primitive.IdDt;
|
|||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class SubscriptionsDstu3Test extends BaseResourceProviderDstu3Test {
|
||||
|
||||
|
@ -45,6 +47,12 @@ public class SubscriptionsDstu3Test extends BaseResourceProviderDstu3Test {
|
|||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SubscriptionsDstu3Test.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void beforeEnableScheduling() {
|
||||
myDaoConfig.setSchedulingDisabled(false);
|
||||
|
|
|
@ -62,6 +62,7 @@ import ca.uhn.fhir.rest.server.RestfulServer;
|
|||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
|
||||
import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.validation.ResultSeverityEnum;
|
||||
|
||||
public class SystemProviderDstu3Test extends BaseJpaDstu3Test {
|
||||
|
@ -74,6 +75,7 @@ public class SystemProviderDstu3Test extends BaseJpaDstu3Test {
|
|||
private static Server ourServer;
|
||||
private static String ourServerBase;
|
||||
|
||||
|
||||
@Before
|
||||
public void beforeStartServer() throws Exception {
|
||||
if (myRestServer == null) {
|
||||
|
@ -508,8 +510,9 @@ public class SystemProviderDstu3Test extends BaseJpaDstu3Test {
|
|||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.util.Set;
|
|||
import org.hl7.fhir.dstu3.model.CodeSystem;
|
||||
import org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -22,9 +23,16 @@ import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
|
|||
import ca.uhn.fhir.jpa.entity.TermConcept;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class TerminologySvcImplTest extends BaseJpaDstu3Test {
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testStoreCodeSystemInvalidCyclicLoop() {
|
||||
CodeSystem codeSystem = new CodeSystem();
|
||||
|
|
|
@ -4,10 +4,19 @@ import static org.hamcrest.Matchers.*;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class SpringFileTest {
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNoBadResources() throws Exception {
|
||||
String text = IOUtils.toString(SpringFileTest.class.getResourceAsStream("/hapi-fhir-server-resourceproviders-dstu2.xml"));
|
||||
|
|
|
@ -3,11 +3,13 @@ package ca.uhn.fhir.validator;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.hl7.fhir.instance.hapi.validation.FhirInstanceValidator;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.resource.QuestionnaireResponse;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.validation.FhirValidator;
|
||||
import ca.uhn.fhir.validation.ValidationResult;
|
||||
|
||||
|
@ -17,6 +19,12 @@ import ca.uhn.fhir.validation.ValidationResult;
|
|||
public class ValidatorAcrossVersionsTest {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ValidatorAcrossVersionsTest.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testValidateProfileOnDstu2Resource() {
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package ca.uhn.fhir.ctx;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDatatypeDefinition;
|
||||
|
@ -10,12 +11,19 @@ import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
|||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.MaritalStatusCodesEnum;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class FhirContextDstu2Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirContextDstu2Test.class);
|
||||
|
||||
private FhirContext ourCtx = FhirContext.forDstu2();
|
||||
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testQueryBoundCode() {
|
||||
RuntimeResourceDefinition patientType = ourCtx.getResourceDefinition(Patient.class);
|
||||
|
|
|
@ -2,13 +2,21 @@ package ca.uhn.fhir.model.dstu2;
|
|||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle.Link;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class BundleTest {
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetLink() {
|
||||
Bundle b = new Bundle();
|
||||
|
|
|
@ -2,17 +2,25 @@ package ca.uhn.fhir.model.dstu2;
|
|||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class CompartmentDstu2Test {
|
||||
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMembership() {
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -12,11 +13,18 @@ import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
|
|||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Practitioner;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Practitioner.PractitionerRole;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class ModelDstu2Test {
|
||||
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* See #320
|
||||
*/
|
||||
|
|
|
@ -5,17 +5,25 @@ import static org.junit.Assert.*;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseBinary;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Binary;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class ModelInstantiationTest {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ModelInstantiationTest.class);
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBinaryIsBaseBinary() {
|
||||
assertTrue(IBaseBinary.class.isAssignableFrom(Binary.class));
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.Date;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -21,11 +22,18 @@ import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
|
|||
import ca.uhn.fhir.model.dstu2.valueset.IdentifierTypeCodesEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.MaritalStatusCodesEnum;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class ModelSerializationDstu2Test {
|
||||
|
||||
private static final FhirContext ourCtx = FhirContext.forDstu2();
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Verify that MaritalStatusCodeEnum (and, by extension, BoundCodeableConcepts in general) are serializable. Author: Nick Peterson (nrpeterson@gmail.com)
|
||||
*/
|
||||
|
|
|
@ -11,17 +11,25 @@ import java.util.Date;
|
|||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class BaseDateTimeDtDstu2Test {
|
||||
private static Locale ourDefaultLocale;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseDateTimeDtDstu2Test.class);
|
||||
private SimpleDateFormat myDateInstantParser;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
myDateInstantParser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.apache.http.client.HttpClient;
|
|||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.message.BasicStatusLine;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
@ -35,6 +36,7 @@ import ca.uhn.fhir.rest.client.IGenericClient;
|
|||
import ca.uhn.fhir.rest.client.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.client.api.IRestfulClient;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class BaseResourceReferenceDtTest {
|
||||
|
||||
|
@ -43,6 +45,12 @@ public class BaseResourceReferenceDtTest {
|
|||
private HttpClient myHttpClient;
|
||||
private HttpResponse myHttpResponse;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
ourCtx = FhirContext.forDstu2();
|
||||
|
|
|
@ -7,11 +7,20 @@ import java.util.Calendar;
|
|||
import java.util.TimeZone;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class DateDtTest {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DateDtTest.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPrecision() {
|
||||
|
||||
|
|
|
@ -2,11 +2,20 @@ package ca.uhn.fhir.narrative;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class BaseThymeleafNarrativeGeneratorDstu2Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseThymeleafNarrativeGeneratorDstu2Test.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testTrimWhitespace() {
|
||||
|
||||
|
|
|
@ -3,18 +3,26 @@ package ca.uhn.fhir.narrative;
|
|||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.composite.NarrativeDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Practitioner;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class CustomThymeleafNarrativeGeneratorDstu2Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CustomThymeleafNarrativeGeneratorDstu2Test.class);
|
||||
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGenerator() {
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.util.Date;
|
||||
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
@ -34,12 +35,19 @@ import ca.uhn.fhir.model.dstu2.valueset.ObservationStatusEnum;
|
|||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class DefaultThymeleafNarrativeGeneratorTestDstu2 {
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DefaultThymeleafNarrativeGeneratorTestDstu2.class);
|
||||
private DefaultThymeleafNarrativeGenerator myGen;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
myGen = new DefaultThymeleafNarrativeGenerator();
|
||||
|
|
|
@ -11,6 +11,7 @@ import static org.junit.Assert.assertThat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -29,12 +30,19 @@ import ca.uhn.fhir.model.primitive.DateTimeDt;
|
|||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.rest.server.AddProfileTagEnum;
|
||||
import ca.uhn.fhir.util.ElementUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class CustomTypeDstu2Test {
|
||||
|
||||
private static final FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CustomTypeDstu2Test.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
ourCtx.setAddProfileTagWhenEncoding(AddProfileTagEnum.ONLY_FOR_CUSTOM);
|
||||
|
|
|
@ -2,12 +2,14 @@ package ca.uhn.fhir.parser;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
/**
|
||||
* Created by Bill de Beaubien on 12/20/2015.
|
||||
|
@ -17,6 +19,12 @@ public class EmptyElementWithExtensionDstu2Test {
|
|||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(EmptyElementWithExtensionDstu2Test.class);
|
||||
private static FhirContext ctx = FhirContext.forDstu2();
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNullFlavorCompositeJson() throws Exception {
|
||||
Observation observation = new Observation();
|
||||
|
|
|
@ -5,17 +5,25 @@ import static org.junit.Assert.assertEquals;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Conformance;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Conformance.RestSecurity;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class ExtensionsDstu2Test {
|
||||
|
||||
private static final FhirContext ourCtx = FhirContext.forDstu2();
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParseExtensions() throws Exception {
|
||||
String input = IOUtils.toString(getClass().getResourceAsStream("/smart-conf.xml"));
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.UUID;
|
|||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
@ -68,6 +69,7 @@ import ca.uhn.fhir.model.primitive.InstantDt;
|
|||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.parser.IParserErrorHandler.IParseLocation;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import net.sf.json.JSON;
|
||||
import net.sf.json.JSONSerializer;
|
||||
import net.sf.json.JsonConfig;
|
||||
|
@ -76,6 +78,12 @@ public class JsonParserDstu2Test {
|
|||
private static final FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(JsonParserDstu2Test.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testContainedResourceInExtensionUndeclared() {
|
||||
Patient p = new Patient();
|
||||
|
|
|
@ -17,15 +17,23 @@ import javax.xml.stream.events.XMLEvent;
|
|||
import org.custommonkey.xmlunit.DetailedDiff;
|
||||
import org.custommonkey.xmlunit.Diff;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.util.XmlUtil;
|
||||
|
||||
public class RoundTripDstu2Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RoundTripDstu2Test.class);
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIt() {
|
||||
// Just so this doesn't complain until we enable roundtrip test
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.hamcrest.collection.IsEmptyCollection;
|
|||
import org.hamcrest.core.StringContains;
|
||||
import org.hamcrest.text.StringContainsInOrder;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
@ -95,11 +96,18 @@ import ca.uhn.fhir.model.primitive.StringDt;
|
|||
import ca.uhn.fhir.parser.IParserErrorHandler.IParseLocation;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class XmlParserDstu2Test {
|
||||
private static final FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(XmlParserDstu2Test.class);
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBundleWithBinary() {
|
||||
//@formatter:off
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.apache.http.message.BasicHeader;
|
|||
import org.apache.http.message.BasicStatusLine;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
@ -30,6 +31,7 @@ import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
|||
import ca.uhn.fhir.rest.client.interceptor.BearerTokenAuthInterceptor;
|
||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class BundleTypeDstu2Test {
|
||||
|
||||
|
@ -39,6 +41,12 @@ public class BundleTypeDstu2Test {
|
|||
|
||||
private HttpResponse ourHttpResponse;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
ourCtx = FhirContext.forDstu2();
|
||||
|
|
|
@ -4,6 +4,7 @@ import static org.junit.Assert.*;
|
|||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs;
|
||||
import org.mockito.internal.stubbing.defaultanswers.ReturnsSmartNulls;
|
||||
|
@ -12,9 +13,16 @@ import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
|||
import ca.uhn.fhir.model.dstu2.resource.Condition;
|
||||
import ca.uhn.fhir.rest.gclient.ICriterion;
|
||||
import ca.uhn.fhir.rest.gclient.IQuery;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class ClientMockingTest {
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testMockingDeepStubs() {
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.apache.http.client.HttpClient;
|
|||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.message.BasicStatusLine;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
@ -36,6 +37,7 @@ import ca.uhn.fhir.rest.client.exceptions.FhirClientInappropriateForServerExcept
|
|||
import ca.uhn.fhir.rest.client.interceptor.BasicAuthInterceptor;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.exceptions.AuthenticationException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class ClientServerValidationTestDstu2 {
|
||||
|
||||
|
@ -45,6 +47,12 @@ public class ClientServerValidationTestDstu2 {
|
|||
private HttpClient myHttpClient;
|
||||
private HttpResponse myHttpResponse;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
myHttpClient = mock(HttpClient.class, new ReturnsDeepStubs());
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.apache.http.client.methods.HttpPost;
|
|||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.message.BasicStatusLine;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
@ -31,6 +32,7 @@ import ca.uhn.fhir.model.dstu2.resource.OperationOutcome;
|
|||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.IssueTypeEnum;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class ClientWithProfileDstu2Test {
|
||||
|
||||
|
@ -39,6 +41,12 @@ public class ClientWithProfileDstu2Test {
|
|||
private HttpClient ourHttpClient;
|
||||
private HttpResponse ourHttpResponse;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
ourCtx = FhirContext.forDstu2();
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.apache.http.client.methods.HttpUriRequest;
|
|||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.message.BasicStatusLine;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -35,6 +36,7 @@ import ca.uhn.fhir.model.primitive.InstantDt;
|
|||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.exceptions.NotModifiedException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
/**
|
||||
* Created by dsotnikov on 2/25/2014.
|
||||
|
@ -46,6 +48,12 @@ public class ETagClientDstu2Test {
|
|||
|
||||
private HttpResponse myHttpResponse;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.hl7.fhir.instance.model.api.IBase;
|
|||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -78,6 +79,7 @@ import ca.uhn.fhir.rest.method.SearchStyleEnum;
|
|||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class GenericClientDstu2Test {
|
||||
private static FhirContext ourCtx;
|
||||
|
@ -89,6 +91,12 @@ public class GenericClientDstu2Test {
|
|||
|
||||
private int myResponseCount = 0;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
myHttpClient = mock(HttpClient.class, new ReturnsDeepStubs());
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.apache.http.client.methods.HttpPost;
|
|||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.message.BasicStatusLine;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
@ -38,6 +39,7 @@ import ca.uhn.fhir.rest.annotation.Operation;
|
|||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
import ca.uhn.fhir.rest.client.api.IBasicClient;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class OperationClientDstu2Test {
|
||||
|
||||
|
@ -47,6 +49,12 @@ public class OperationClientDstu2Test {
|
|||
|
||||
private HttpResponse ourHttpResponse;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
ourCtx = FhirContext.forDstu2();
|
||||
|
|
|
@ -26,6 +26,7 @@ import ca.uhn.fhir.rest.server.FifoMemoryPagingProvider;
|
|||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class CompressOutgoingContentInterceptorTest {
|
||||
|
||||
|
@ -42,6 +43,7 @@ public class CompressOutgoingContentInterceptorTest {
|
|||
ourClient = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreate() throws Exception {
|
||||
ourClient.registerInterceptor(new GZipContentInterceptor());
|
||||
|
@ -56,9 +58,11 @@ public class CompressOutgoingContentInterceptorTest {
|
|||
assertEquals("gzip", ourLastResponseEncoding);
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
@ -40,6 +40,7 @@ import ca.uhn.fhir.rest.annotation.ResourceParam;
|
|||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
/**
|
||||
* Created by dsotnikov on 2/25/2014.
|
||||
|
@ -56,6 +57,13 @@ public class BinaryDstu2Test {
|
|||
|
||||
private static Server ourServer;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
ourLast = null;
|
||||
|
@ -207,11 +215,6 @@ public class BinaryDstu2Test {
|
|||
assertArrayEquals(new byte[] { 1, 2, 3, 4 }, bin.getContent());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
ourServer.stop();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
ourPort = PortUtil.findFreePort();
|
||||
|
|
|
@ -27,6 +27,7 @@ import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
|||
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
/**
|
||||
* Created by dsotnikov on 2/25/2014.
|
||||
|
@ -56,9 +57,11 @@ public class BundleTypeInResponseTest {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
@ -48,6 +48,7 @@ import ca.uhn.fhir.rest.annotation.ResourceParam;
|
|||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
/**
|
||||
* Created by dsotnikov on 2/25/2014.
|
||||
|
@ -62,6 +63,12 @@ public class CompartmentDstu2Test {
|
|||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static IdDt ourLastId;
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
ourLastMethod = null;
|
||||
|
|
|
@ -38,6 +38,7 @@ import ca.uhn.fhir.rest.annotation.ResourceParam;
|
|||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
/**
|
||||
* Created by dsotnikov on 2/25/2014.
|
||||
|
@ -45,17 +46,16 @@ import ca.uhn.fhir.util.PortUtil;
|
|||
public class CreateConditionalTest {
|
||||
private static CloseableHttpClient ourClient;
|
||||
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static String ourLastConditionalUrl;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CreateConditionalTest.class);
|
||||
private static int ourPort;
|
||||
private static Server ourServer;
|
||||
private static IdDt ourLastId;
|
||||
private static IdDt ourLastIdParam;
|
||||
private static boolean ourLastRequestWasSearch;
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CreateConditionalTest.class);
|
||||
private static int ourPort;
|
||||
private static Server ourServer;
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
ourLastId = null;
|
||||
|
@ -64,6 +64,8 @@ public class CreateConditionalTest {
|
|||
ourLastRequestWasSearch = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateWithConditionalUrl() throws Exception {
|
||||
|
||||
|
@ -141,8 +143,9 @@ public class CreateConditionalTest {
|
|||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
|
@ -170,17 +173,6 @@ public class CreateConditionalTest {
|
|||
|
||||
public static class PatientProvider implements IResourceProvider {
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
return Patient.class;
|
||||
}
|
||||
|
||||
@Search
|
||||
public List<IResource> search(@OptionalParam(name="foo") StringDt theString) {
|
||||
ourLastRequestWasSearch = true;
|
||||
return new ArrayList<IResource>();
|
||||
}
|
||||
|
||||
@Create()
|
||||
public MethodOutcome createPatient(@ResourceParam Patient thePatient, @ConditionalUrlParam String theConditional, @IdParam IdDt theIdParam) {
|
||||
ourLastConditionalUrl = theConditional;
|
||||
|
@ -189,6 +181,17 @@ public class CreateConditionalTest {
|
|||
return new MethodOutcome(new IdDt("Patient/001/_history/002"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
return Patient.class;
|
||||
}
|
||||
|
||||
@Search
|
||||
public List<IResource> search(@OptionalParam(name="foo") StringDt theString) {
|
||||
ourLastRequestWasSearch = true;
|
||||
return new ArrayList<IResource>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,18 +27,18 @@ import ca.uhn.fhir.rest.annotation.Delete;
|
|||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class DeleteDstu2Test {
|
||||
private static CloseableHttpClient ourClient;
|
||||
private static String ourLastConditionalUrl;
|
||||
private static int ourPort;
|
||||
private static final FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static Server ourServer;
|
||||
private static IdDt ourLastIdParam;
|
||||
private static boolean ourInvoked;
|
||||
private static String ourLastConditionalUrl;
|
||||
private static IdDt ourLastIdParam;
|
||||
private static int ourPort;
|
||||
private static Server ourServer;
|
||||
|
||||
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
ourLastConditionalUrl = null;
|
||||
|
@ -46,6 +46,8 @@ public class DeleteDstu2Test {
|
|||
ourInvoked = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testUpdateWithConditionalUrl() throws Exception {
|
||||
Patient patient = new Patient();
|
||||
|
@ -76,9 +78,11 @@ public class DeleteDstu2Test {
|
|||
assertNull(ourLastConditionalUrl);
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,12 +110,6 @@ public class DeleteDstu2Test {
|
|||
|
||||
public static class PatientProvider implements IResourceProvider {
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
return Patient.class;
|
||||
}
|
||||
|
||||
|
||||
@Delete()
|
||||
public MethodOutcome delete(@ConditionalUrlParam String theConditional, @IdParam IdDt theIdParam) {
|
||||
ourLastConditionalUrl = theConditional;
|
||||
|
@ -120,6 +118,12 @@ public class DeleteDstu2Test {
|
|||
return new MethodOutcome(new IdDt("Patient/001/_history/002"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
return Patient.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import ca.uhn.fhir.rest.annotation.Update;
|
|||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
/**
|
||||
* Created by dsotnikov on 2/25/2014.
|
||||
|
@ -47,12 +48,37 @@ import ca.uhn.fhir.util.PortUtil;
|
|||
public class ETagServerTest {
|
||||
|
||||
private static CloseableHttpClient ourClient;
|
||||
private static PoolingHttpClientConnectionManager ourConnectionManager;
|
||||
private static FhirContext ourCtx;
|
||||
private static IdDt ourLastId;
|
||||
|
||||
private static Date ourLastModifiedDate;
|
||||
private static int ourPort;
|
||||
|
||||
private static Server ourServer;
|
||||
private static PoolingHttpClientConnectionManager ourConnectionManager;
|
||||
|
||||
|
||||
@Before
|
||||
public void before() throws IOException {
|
||||
ourLastId = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutomaticNotModified() throws Exception {
|
||||
ourLastModifiedDate = new InstantDt("2012-11-25T02:34:45.2222Z").getValue();
|
||||
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/2");
|
||||
httpGet.addHeader(Constants.HEADER_IF_NONE_MATCH, "\"222\"");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
try {
|
||||
assertEquals(Constants.STATUS_HTTP_304_NOT_MODIFIED, status.getStatusLine().getStatusCode());
|
||||
} finally {
|
||||
if (status.getEntity() != null) {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testETagHeader() throws Exception {
|
||||
|
@ -76,23 +102,6 @@ public class ETagServerTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutomaticNotModified() throws Exception {
|
||||
ourLastModifiedDate = new InstantDt("2012-11-25T02:34:45.2222Z").getValue();
|
||||
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/2");
|
||||
httpGet.addHeader(Constants.HEADER_IF_NONE_MATCH, "\"222\"");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
try {
|
||||
assertEquals(Constants.STATUS_HTTP_304_NOT_MODIFIED, status.getStatusLine().getStatusCode());
|
||||
} finally {
|
||||
if (status.getEntity() != null) {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLastModifiedHeader() throws Exception {
|
||||
ourLastModifiedDate = new InstantDt("2012-11-25T02:34:45.2222Z").getValue();
|
||||
|
@ -117,32 +126,6 @@ public class ETagServerTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
public void before() throws IOException {
|
||||
ourLastId = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWithNoVersion() throws Exception {
|
||||
Patient p = new Patient();
|
||||
p.setId("2");
|
||||
p.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
String resBody = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
HttpPut http;
|
||||
http = new HttpPut("http://localhost:" + ourPort + "/Patient/2");
|
||||
http.setEntity(new StringEntity(resBody, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
HttpResponse status = ourClient.execute(http);
|
||||
try {
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
} finally {
|
||||
if (status.getEntity() != null) {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWithIfMatch() throws Exception {
|
||||
Patient p = new Patient();
|
||||
|
@ -187,9 +170,31 @@ public class ETagServerTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWithNoVersion() throws Exception {
|
||||
Patient p = new Patient();
|
||||
p.setId("2");
|
||||
p.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
String resBody = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
HttpPut http;
|
||||
http = new HttpPut("http://localhost:" + ourPort + "/Patient/2");
|
||||
http.setEntity(new StringEntity(resBody, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
HttpResponse status = ourClient.execute(http);
|
||||
try {
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
} finally {
|
||||
if (status.getEntity() != null) {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
@ -215,8 +220,6 @@ public class ETagServerTest {
|
|||
|
||||
}
|
||||
|
||||
private static IdDt ourLastId;
|
||||
|
||||
public static class PatientProvider implements IResourceProvider {
|
||||
|
||||
@Read(version = true)
|
||||
|
@ -228,6 +231,11 @@ public class ETagServerTest {
|
|||
return patient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
return Patient.class;
|
||||
}
|
||||
|
||||
@Update
|
||||
public MethodOutcome updatePatient(@IdParam IdDt theId, @ResourceParam Patient theResource) {
|
||||
ourLastId = theId;
|
||||
|
@ -239,11 +247,6 @@ public class ETagServerTest {
|
|||
return new MethodOutcome(theId.withVersion(theId.getVersionIdPart() + "0"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
return Patient.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import ca.uhn.fhir.rest.annotation.Read;
|
|||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.api.SummaryEnum;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class ElementsParamTest {
|
||||
|
||||
|
@ -47,6 +48,7 @@ public class ElementsParamTest {
|
|||
ourLastElements = null;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReadSummaryData() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/1?_elements=name,maritalStatus");
|
||||
|
@ -99,7 +101,6 @@ public class ElementsParamTest {
|
|||
assertThat(ourLastElements, containsInAnyOrder("name", "maritalStatus"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSearchSummaryText() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_elements=text");
|
||||
|
@ -117,9 +118,11 @@ public class ElementsParamTest {
|
|||
assertThat(ourLastElements, containsInAnyOrder("text"));
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
@ -31,6 +31,7 @@ import ca.uhn.fhir.model.dstu2.resource.Patient;
|
|||
import ca.uhn.fhir.rest.annotation.IncludeParam;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
/**
|
||||
* Created by dsotnikov on 2/25/2014.
|
||||
|
@ -38,19 +39,20 @@ import ca.uhn.fhir.util.PortUtil;
|
|||
public class IncludeAndRevincludeParameterTest {
|
||||
|
||||
private static CloseableHttpClient ourClient;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(IncludeAndRevincludeParameterTest.class);
|
||||
private static int ourPort;
|
||||
private static Server ourServer;
|
||||
private static FhirContext ourCtx;
|
||||
private static Set<Include> ourIncludes;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(IncludeAndRevincludeParameterTest.class);
|
||||
private static int ourPort;
|
||||
private static Set<Include> ourReverseIncludes;
|
||||
private static Server ourServer;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
ourIncludes = null;
|
||||
ourReverseIncludes = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testNoIncludes() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=normalInclude");
|
||||
|
@ -62,7 +64,7 @@ public class IncludeAndRevincludeParameterTest {
|
|||
assertThat(ourIncludes, hasSize(0));
|
||||
assertThat(ourReverseIncludes, hasSize(0));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWithBoth() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=normalInclude&_include=A.a&_include=B.b&_revinclude=C.c&_revinclude=D.d");
|
||||
|
@ -77,9 +79,11 @@ public class IncludeAndRevincludeParameterTest {
|
|||
assertThat(ourReverseIncludes, containsInAnyOrder(new Include("C.c"), new Include("D.d")));
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
@ -107,6 +111,11 @@ public class IncludeAndRevincludeParameterTest {
|
|||
|
||||
public static class DummyPatientResourceProvider implements IResourceProvider {
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
return Patient.class;
|
||||
}
|
||||
|
||||
@Search(queryName = "normalInclude")
|
||||
public List<Patient> normalInclude(
|
||||
@IncludeParam() Set<Include> theIncludes,
|
||||
|
@ -117,11 +126,6 @@ public class IncludeAndRevincludeParameterTest {
|
|||
return new ArrayList<Patient>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
return Patient.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ import ca.uhn.fhir.rest.annotation.RequiredParam;
|
|||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.util.ElementUtil;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
/**
|
||||
* Created by dsotnikov on 2/25/2014.
|
||||
|
@ -52,80 +53,18 @@ import ca.uhn.fhir.util.PortUtil;
|
|||
public class IncludeDstu2Test {
|
||||
|
||||
private static CloseableHttpClient ourClient;
|
||||
private static FhirContext ourCtx;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(IncludeDstu2Test.class);
|
||||
private static int ourPort;
|
||||
private static Server ourServer;
|
||||
private static FhirContext ourCtx;
|
||||
|
||||
@Test
|
||||
public void testNoIncludes() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello");
|
||||
public void testBadInclude() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo&_include=baz");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||
assertEquals(1, bundle.size());
|
||||
|
||||
Patient p = bundle.getResources(Patient.class).get(0);
|
||||
assertEquals(0, p.getName().size());
|
||||
assertEquals("Hello", p.getId().getIdPart());
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneIncludeXml() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
|
||||
ourLog.info(responseContent);
|
||||
|
||||
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||
assertEquals(1, bundle.size());
|
||||
|
||||
Patient p = bundle.getResources(Patient.class).get(0);
|
||||
assertEquals(1, p.getName().size());
|
||||
assertEquals("Hello", p.getId().getIdPart());
|
||||
assertEquals("foo", p.getName().get(0).getFamilyFirstRep().getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneIncludeJson() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo&_format=json");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
|
||||
ourLog.info(responseContent);
|
||||
|
||||
Bundle bundle = ourCtx.newJsonParser().parseBundle(responseContent);
|
||||
assertEquals(1, bundle.size());
|
||||
|
||||
Patient p = bundle.getResources(Patient.class).get(0);
|
||||
assertEquals(1, p.getName().size());
|
||||
assertEquals("Hello", p.getId().getIdPart());
|
||||
assertEquals("foo", p.getName().get(0).getFamilyFirstRep().getValue());
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void testMixedContainedAndNonContained() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/DiagnosticReport?_query=stitchedInclude&_pretty=true");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
ourLog.info(responseContent);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||
assertEquals(4, bundle.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIIncludedResourcesNonContained() throws Exception {
|
||||
|
@ -153,6 +92,34 @@ public class IncludeDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIIncludedResourcesNonContainedInDeclaredExtension() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=declaredExtInclude&_pretty=true");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||
|
||||
ourLog.info(responseContent);
|
||||
|
||||
assertEquals(4, bundle.size());
|
||||
assertEquals(new IdDt("Patient/p1"), bundle.toListOfResources().get(0).getId().toUnqualifiedVersionless());
|
||||
assertEquals(new IdDt("Patient/p2"), bundle.toListOfResources().get(1).getId().toUnqualifiedVersionless());
|
||||
assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless());
|
||||
assertEquals(new IdDt("Organization/o2"), bundle.toListOfResources().get(3).getId().toUnqualifiedVersionless());
|
||||
assertEquals(BundleEntrySearchModeEnum.INCLUDE, bundle.getEntries().get(2).getSearchMode().getValueAsEnum());
|
||||
assertEquals(BundleEntrySearchModeEnum.INCLUDE, bundle.getEntries().get(3).getSearchMode().getValueAsEnum());
|
||||
|
||||
Patient p1 = (Patient) bundle.toListOfResources().get(0);
|
||||
assertEquals(0, p1.getContained().getContainedResources().size());
|
||||
|
||||
Patient p2 = (Patient) bundle.toListOfResources().get(1);
|
||||
assertEquals(0, p2.getContained().getContainedResources().size());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIIncludedResourcesNonContainedInExtension() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=extInclude&_pretty=true");
|
||||
|
@ -205,32 +172,74 @@ public class IncludeDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void testMixedContainedAndNonContained() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/DiagnosticReport?_query=stitchedInclude&_pretty=true");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
ourLog.info(responseContent);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||
assertEquals(4, bundle.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIIncludedResourcesNonContainedInDeclaredExtension() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=declaredExtInclude&_pretty=true");
|
||||
public void testNoIncludes() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||
assertEquals(1, bundle.size());
|
||||
|
||||
Patient p = bundle.getResources(Patient.class).get(0);
|
||||
assertEquals(0, p.getName().size());
|
||||
assertEquals("Hello", p.getId().getIdPart());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneIncludeJson() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo&_format=json");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
|
||||
ourLog.info(responseContent);
|
||||
|
||||
assertEquals(4, bundle.size());
|
||||
assertEquals(new IdDt("Patient/p1"), bundle.toListOfResources().get(0).getId().toUnqualifiedVersionless());
|
||||
assertEquals(new IdDt("Patient/p2"), bundle.toListOfResources().get(1).getId().toUnqualifiedVersionless());
|
||||
assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless());
|
||||
assertEquals(new IdDt("Organization/o2"), bundle.toListOfResources().get(3).getId().toUnqualifiedVersionless());
|
||||
assertEquals(BundleEntrySearchModeEnum.INCLUDE, bundle.getEntries().get(2).getSearchMode().getValueAsEnum());
|
||||
assertEquals(BundleEntrySearchModeEnum.INCLUDE, bundle.getEntries().get(3).getSearchMode().getValueAsEnum());
|
||||
Bundle bundle = ourCtx.newJsonParser().parseBundle(responseContent);
|
||||
assertEquals(1, bundle.size());
|
||||
|
||||
Patient p1 = (Patient) bundle.toListOfResources().get(0);
|
||||
assertEquals(0, p1.getContained().getContainedResources().size());
|
||||
Patient p = bundle.getResources(Patient.class).get(0);
|
||||
assertEquals(1, p.getName().size());
|
||||
assertEquals("Hello", p.getId().getIdPart());
|
||||
assertEquals("foo", p.getName().get(0).getFamilyFirstRep().getValue());
|
||||
}
|
||||
|
||||
Patient p2 = (Patient) bundle.toListOfResources().get(1);
|
||||
assertEquals(0, p2.getContained().getContainedResources().size());
|
||||
@Test
|
||||
public void testOneIncludeXml() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
|
||||
ourLog.info(responseContent);
|
||||
|
||||
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||
assertEquals(1, bundle.size());
|
||||
|
||||
Patient p = bundle.getResources(Patient.class).get(0);
|
||||
assertEquals(1, p.getName().size());
|
||||
assertEquals("Hello", p.getId().getIdPart());
|
||||
assertEquals("foo", p.getName().get(0).getFamilyFirstRep().getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -257,16 +266,11 @@ public class IncludeDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBadInclude() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo&_include=baz");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
@ -294,30 +298,6 @@ public class IncludeDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
@ResourceDef(name = "Patient")
|
||||
public static class ExtPatient extends Patient {
|
||||
@Child(name = "secondOrg")
|
||||
@Extension(url = "http://foo#secondOrg", definedLocally = false, isModifier = false)
|
||||
private ResourceReferenceDt mySecondOrg;
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return super.isEmpty() && ElementUtil.isEmpty(mySecondOrg);
|
||||
}
|
||||
|
||||
public ResourceReferenceDt getSecondOrg() {
|
||||
if (mySecondOrg == null) {
|
||||
mySecondOrg = new ResourceReferenceDt();
|
||||
}
|
||||
return mySecondOrg;
|
||||
}
|
||||
|
||||
public void setSecondOrg(ResourceReferenceDt theSecondOrg) {
|
||||
mySecondOrg = theSecondOrg;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by dsotnikov on 2/25/2014.
|
||||
*/
|
||||
|
@ -371,11 +351,10 @@ public class IncludeDstu2Test {
|
|||
*/
|
||||
public static class DummyPatientResourceProvider implements IResourceProvider {
|
||||
|
||||
@Search(queryName = "normalInclude")
|
||||
public List<Patient> normalInclude() {
|
||||
@Search(queryName = "containedInclude")
|
||||
public List<Patient> containedInclude() {
|
||||
Organization o1 = new Organization();
|
||||
o1.getNameElement().setValue("o1");
|
||||
o1.setId("o1");
|
||||
|
||||
Patient p1 = new Patient();
|
||||
p1.setId("p1");
|
||||
|
@ -390,25 +369,6 @@ public class IncludeDstu2Test {
|
|||
return Arrays.asList(p1, p2);
|
||||
}
|
||||
|
||||
@Search(queryName = "extInclude")
|
||||
public List<Patient> extInclude() {
|
||||
Organization o1 = new Organization();
|
||||
o1.getNameElement().setValue("o1");
|
||||
o1.setId("o1");
|
||||
|
||||
Patient p1 = new Patient();
|
||||
p1.setId("p1");
|
||||
p1.addIdentifier().setValue("p1");
|
||||
p1.addUndeclaredExtension(false, "http://foo", new ResourceReferenceDt(o1));
|
||||
|
||||
Patient p2 = new Patient();
|
||||
p2.setId("p2");
|
||||
p2.addIdentifier().setValue("p2");
|
||||
p2.addUndeclaredExtension(false, "http://foo", new ResourceReferenceDt(o1));
|
||||
|
||||
return Arrays.asList(p1, p2);
|
||||
}
|
||||
|
||||
@Search(queryName = "declaredExtInclude")
|
||||
public List<ExtPatient> declaredExtInclude() {
|
||||
Organization o1 = new Organization();
|
||||
|
@ -433,20 +393,21 @@ public class IncludeDstu2Test {
|
|||
return Arrays.asList(p1, p2);
|
||||
}
|
||||
|
||||
@Search(queryName = "containedInclude")
|
||||
public List<Patient> containedInclude() {
|
||||
@Search(queryName = "extInclude")
|
||||
public List<Patient> extInclude() {
|
||||
Organization o1 = new Organization();
|
||||
o1.getNameElement().setValue("o1");
|
||||
o1.setId("o1");
|
||||
|
||||
Patient p1 = new Patient();
|
||||
p1.setId("p1");
|
||||
p1.addIdentifier().setValue("p1");
|
||||
p1.getManagingOrganization().setResource(o1);
|
||||
p1.addUndeclaredExtension(false, "http://foo", new ResourceReferenceDt(o1));
|
||||
|
||||
Patient p2 = new Patient();
|
||||
p2.setId("p2");
|
||||
p2.addIdentifier().setValue("p2");
|
||||
p2.getManagingOrganization().setResource(o1);
|
||||
p2.addUndeclaredExtension(false, "http://foo", new ResourceReferenceDt(o1));
|
||||
|
||||
return Arrays.asList(p1, p2);
|
||||
}
|
||||
|
@ -475,6 +436,49 @@ public class IncludeDstu2Test {
|
|||
return Patient.class;
|
||||
}
|
||||
|
||||
@Search(queryName = "normalInclude")
|
||||
public List<Patient> normalInclude() {
|
||||
Organization o1 = new Organization();
|
||||
o1.getNameElement().setValue("o1");
|
||||
o1.setId("o1");
|
||||
|
||||
Patient p1 = new Patient();
|
||||
p1.setId("p1");
|
||||
p1.addIdentifier().setValue("p1");
|
||||
p1.getManagingOrganization().setResource(o1);
|
||||
|
||||
Patient p2 = new Patient();
|
||||
p2.setId("p2");
|
||||
p2.addIdentifier().setValue("p2");
|
||||
p2.getManagingOrganization().setResource(o1);
|
||||
|
||||
return Arrays.asList(p1, p2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResourceDef(name = "Patient")
|
||||
public static class ExtPatient extends Patient {
|
||||
@Child(name = "secondOrg")
|
||||
@Extension(url = "http://foo#secondOrg", definedLocally = false, isModifier = false)
|
||||
private ResourceReferenceDt mySecondOrg;
|
||||
|
||||
public ResourceReferenceDt getSecondOrg() {
|
||||
if (mySecondOrg == null) {
|
||||
mySecondOrg = new ResourceReferenceDt();
|
||||
}
|
||||
return mySecondOrg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return super.isEmpty() && ElementUtil.isEmpty(mySecondOrg);
|
||||
}
|
||||
|
||||
public void setSecondOrg(ResourceReferenceDt theSecondOrg) {
|
||||
mySecondOrg = theSecondOrg;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import ca.uhn.fhir.model.primitive.StringDt;
|
|||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class OperationDuplicateServerDstu2Test {
|
||||
private static CloseableHttpClient ourClient;
|
||||
|
@ -76,9 +77,12 @@ public class OperationDuplicateServerDstu2Test {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
@ -48,21 +48,22 @@ import ca.uhn.fhir.rest.annotation.OperationParam;
|
|||
import ca.uhn.fhir.rest.annotation.Read;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class OperationServerDstu2Test {
|
||||
private static CloseableHttpClient ourClient;
|
||||
private static FhirContext ourCtx;
|
||||
|
||||
private static IdDt ourLastId;
|
||||
private static String ourLastMethod;
|
||||
private static StringDt ourLastParam1;
|
||||
private static Patient ourLastParam2;
|
||||
private static List<StringDt> ourLastParam3;
|
||||
private static MoneyDt ourLastParamMoney1;
|
||||
private static UnsignedIntDt ourLastParamUnsignedInt1;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(OperationServerDstu2Test.class);
|
||||
private static int ourPort;
|
||||
private static IdDt ourLastId;
|
||||
private static Server ourServer;
|
||||
private static String ourLastMethod;
|
||||
private static List<StringDt> ourLastParam3;
|
||||
private static UnsignedIntDt ourLastParamUnsignedInt1;
|
||||
private static MoneyDt ourLastParamMoney1;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
|
@ -75,22 +76,54 @@ public class OperationServerDstu2Test {
|
|||
ourLastMethod = "";
|
||||
}
|
||||
|
||||
public static void main(String[] theValue) {
|
||||
Parameters p = new Parameters();
|
||||
p.addParameter().setName("start").setValue(new DateTimeDt("2001-01-02"));
|
||||
p.addParameter().setName("end").setValue(new DateTimeDt("2015-07-10"));
|
||||
String inParamsStr = FhirContext.forDstu2().newXmlParser().encodeResourceToString(p);
|
||||
ourLog.info(inParamsStr.replace("\"", "\\\""));
|
||||
|
||||
@Test
|
||||
public void testConformance() throws Exception {
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort);
|
||||
Conformance p = client.fetchConformance().ofType(Conformance.class).execute();
|
||||
List<RestOperation> ops = p.getRest().get(0).getOperation();
|
||||
assertThat(ops.size(), greaterThan(1));
|
||||
assertNull(ops.get(0).getDefinition().getReference().getBaseUrl());
|
||||
assertThat(ops.get(0).getDefinition().getReference().getValue(), startsWith("OperationDefinition/"));
|
||||
|
||||
OperationDefinition def = client.read().resource(OperationDefinition.class).withId(ops.get(0).getDefinition().getReference()).execute();
|
||||
assertThat(def.getCode(), not(blankOrNullString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInstanceEverythingGet() throws Exception {
|
||||
|
||||
// Try with a GET
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/123/$everything");
|
||||
CloseableHttpResponse status = ourClient.execute(httpGet);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("instance $everything", ourLastMethod);
|
||||
assertThat(response, startsWith("<Bundle"));
|
||||
assertEquals("Patient/123", ourLastId.toUnqualifiedVersionless().getValue());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationOnType() throws Exception {
|
||||
Parameters p = new Parameters();
|
||||
p.addParameter().setName("PARAM1").setValue(new StringDt("PARAM1val"));
|
||||
p.addParameter().setName("PARAM2").setResource(new Patient().setActive(true));
|
||||
String inParamsStr = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
public void testInstanceEverythingHapiClient() throws Exception {
|
||||
Parameters p = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort).operation().onInstance(new IdDt("Patient/123")).named("$everything").withParameters(new Parameters()).execute();
|
||||
Bundle b = (Bundle) p.getParameterFirstRep().getResource();
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/$OP_TYPE");
|
||||
assertEquals("instance $everything", ourLastMethod);
|
||||
assertEquals("Patient/123", ourLastId.toUnqualifiedVersionless().getValue());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInstanceEverythingPost() throws Exception {
|
||||
String inParamsStr = ourCtx.newXmlParser().encodeResourceToString(new Parameters());
|
||||
|
||||
// Try with a POST
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/123/$everything");
|
||||
httpPost.setEntity(new StringEntity(inParamsStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
|
@ -98,52 +131,33 @@ public class OperationServerDstu2Test {
|
|||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("PARAM1val", ourLastParam1.getValue());
|
||||
assertEquals(true, ourLastParam2.getActive().booleanValue());
|
||||
assertEquals("$OP_TYPE", ourLastMethod);
|
||||
assertEquals("instance $everything", ourLastMethod);
|
||||
assertThat(response, startsWith("<Bundle"));
|
||||
assertEquals("Patient/123", ourLastId.toUnqualifiedVersionless().getValue());
|
||||
|
||||
Parameters resp = ourCtx.newXmlParser().parseResource(Parameters.class, response);
|
||||
assertEquals("RET1", resp.getParameter().get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithGetUsingParams() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/$OP_TYPE?PARAM1=PARAM1val");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
public void testOperationCantUseGetIfItIsntIdempotent() throws Exception {
|
||||
HttpGet httpPost = new HttpGet("http://localhost:" + ourPort + "/Patient/123/$OP_INSTANCE");
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("PARAM1val", ourLastParam1.getValue());
|
||||
assertNull(ourLastParam2);
|
||||
assertEquals("$OP_TYPE", ourLastMethod);
|
||||
|
||||
Parameters resp = ourCtx.newXmlParser().parseResource(Parameters.class, response);
|
||||
assertEquals("RET1", resp.getParameter().get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithGetUsingParamsFailsWithNonPrimitive() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/$OP_TYPE?PARAM1=PARAM1val&PARAM2=foo");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
|
||||
assertEquals(405, status.getStatusLine().getStatusCode());
|
||||
assertEquals(Constants.STATUS_HTTP_405_METHOD_NOT_ALLOWED, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("POST", status.getFirstHeader(Constants.HEADER_ALLOW).getValue());
|
||||
assertThat(response, containsString("Can not invoke operation $OP_TYPE using HTTP GET because parameter PARAM2 is not a primitive datatype"));
|
||||
assertThat(response, containsString("HTTP Method GET is not allowed"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationOnTypeReturnBundle() throws Exception {
|
||||
public void testOperationOnInstance() throws Exception {
|
||||
Parameters p = new Parameters();
|
||||
p.addParameter().setName("PARAM1").setValue(new StringDt("PARAM1val"));
|
||||
p.addParameter().setName("PARAM2").setResource(new Patient().setActive(true));
|
||||
String inParamsStr = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/$OP_TYPE_RET_BUNDLE");
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/123/$OP_INSTANCE");
|
||||
httpPost.setEntity(new StringEntity(inParamsStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
|
@ -153,10 +167,74 @@ public class OperationServerDstu2Test {
|
|||
|
||||
assertEquals("PARAM1val", ourLastParam1.getValue());
|
||||
assertEquals(true, ourLastParam2.getActive().booleanValue());
|
||||
assertEquals("$OP_TYPE_RET_BUNDLE", ourLastMethod);
|
||||
assertEquals("123", ourLastId.getIdPart());
|
||||
assertEquals("$OP_INSTANCE", ourLastMethod);
|
||||
|
||||
Bundle resp = ourCtx.newXmlParser().parseResource(Bundle.class, response);
|
||||
assertEquals("100", resp.getEntryFirstRep().getResponse().getStatus());
|
||||
Parameters resp = ourCtx.newXmlParser().parseResource(Parameters.class, response);
|
||||
assertEquals("RET1", resp.getParameter().get(0).getName());
|
||||
|
||||
/*
|
||||
* Against type should fail
|
||||
*/
|
||||
|
||||
httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/$OP_INSTANCE");
|
||||
httpPost.setEntity(new StringEntity(inParamsStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
status = ourClient.execute(httpPost);
|
||||
|
||||
response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(response);
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationOnInstanceAndType_Instance() throws Exception {
|
||||
Parameters p = new Parameters();
|
||||
p.addParameter().setName("PARAM1").setValue(new StringDt("PARAM1val"));
|
||||
p.addParameter().setName("PARAM2").setResource(new Patient().setActive(true));
|
||||
String inParamsStr = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/123/$OP_INSTANCE_OR_TYPE");
|
||||
httpPost.setEntity(new StringEntity(inParamsStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("PARAM1val", ourLastParam1.getValue());
|
||||
assertEquals(true, ourLastParam2.getActive().booleanValue());
|
||||
assertEquals("123", ourLastId.getIdPart());
|
||||
assertEquals("$OP_INSTANCE_OR_TYPE", ourLastMethod);
|
||||
|
||||
Parameters resp = ourCtx.newXmlParser().parseResource(Parameters.class, response);
|
||||
assertEquals("RET1", resp.getParameter().get(0).getName());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationOnInstanceAndType_Type() throws Exception {
|
||||
Parameters p = new Parameters();
|
||||
p.addParameter().setName("PARAM1").setValue(new StringDt("PARAM1val"));
|
||||
p.addParameter().setName("PARAM2").setResource(new Patient().setActive(true));
|
||||
String inParamsStr = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/$OP_INSTANCE_OR_TYPE");
|
||||
httpPost.setEntity(new StringEntity(inParamsStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
CloseableHttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("PARAM1val", ourLastParam1.getValue());
|
||||
assertEquals(true, ourLastParam2.getActive().booleanValue());
|
||||
assertEquals(null, ourLastId);
|
||||
assertEquals("$OP_INSTANCE_OR_TYPE", ourLastMethod);
|
||||
|
||||
Parameters resp = ourCtx.newXmlParser().parseResource(Parameters.class, response);
|
||||
assertEquals("RET1", resp.getParameter().get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -183,15 +261,120 @@ public class OperationServerDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithProfileDatatypeUrl() throws Exception {
|
||||
HttpGet httpPost = new HttpGet("http://localhost:" + ourPort + "/Patient/$OP_PROFILE_DT?PARAM1=123");
|
||||
public void testOperationOnType() throws Exception {
|
||||
Parameters p = new Parameters();
|
||||
p.addParameter().setName("PARAM1").setValue(new StringDt("PARAM1val"));
|
||||
p.addParameter().setName("PARAM2").setResource(new Patient().setActive(true));
|
||||
String inParamsStr = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/$OP_TYPE");
|
||||
httpPost.setEntity(new StringEntity(inParamsStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("$OP_PROFILE_DT", ourLastMethod);
|
||||
assertEquals("123", ourLastParamUnsignedInt1.getValueAsString());
|
||||
assertEquals("PARAM1val", ourLastParam1.getValue());
|
||||
assertEquals(true, ourLastParam2.getActive().booleanValue());
|
||||
assertEquals("$OP_TYPE", ourLastMethod);
|
||||
|
||||
Parameters resp = ourCtx.newXmlParser().parseResource(Parameters.class, response);
|
||||
assertEquals("RET1", resp.getParameter().get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationOnTypeReturnBundle() throws Exception {
|
||||
Parameters p = new Parameters();
|
||||
p.addParameter().setName("PARAM1").setValue(new StringDt("PARAM1val"));
|
||||
p.addParameter().setName("PARAM2").setResource(new Patient().setActive(true));
|
||||
String inParamsStr = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/$OP_TYPE_RET_BUNDLE");
|
||||
httpPost.setEntity(new StringEntity(inParamsStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("PARAM1val", ourLastParam1.getValue());
|
||||
assertEquals(true, ourLastParam2.getActive().booleanValue());
|
||||
assertEquals("$OP_TYPE_RET_BUNDLE", ourLastMethod);
|
||||
|
||||
Bundle resp = ourCtx.newXmlParser().parseResource(Bundle.class, response);
|
||||
assertEquals("100", resp.getEntryFirstRep().getResponse().getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithBundleProviderResponse() throws Exception {
|
||||
HttpGet httpPost = new HttpGet("http://localhost:" + ourPort + "/$OP_INSTANCE_BUNDLE_PROVIDER?_pretty=true");
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(response);
|
||||
|
||||
Bundle resp = ourCtx.newXmlParser().parseResource(Bundle.class, response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithGetUsingParams() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/$OP_TYPE?PARAM1=PARAM1val");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("PARAM1val", ourLastParam1.getValue());
|
||||
assertNull(ourLastParam2);
|
||||
assertEquals("$OP_TYPE", ourLastMethod);
|
||||
|
||||
Parameters resp = ourCtx.newXmlParser().parseResource(Parameters.class, response);
|
||||
assertEquals("RET1", resp.getParameter().get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithGetUsingParamsFailsWithNonPrimitive() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/$OP_TYPE?PARAM1=PARAM1val&PARAM2=foo");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
|
||||
assertEquals(405, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("POST", status.getFirstHeader(Constants.HEADER_ALLOW).getValue());
|
||||
assertThat(response, containsString("Can not invoke operation $OP_TYPE using HTTP GET because parameter PARAM2 is not a primitive datatype"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOperationWithListParam() throws Exception {
|
||||
Parameters p = new Parameters();
|
||||
p.addParameter().setName("PARAM2").setResource(new Patient().setActive(true));
|
||||
p.addParameter().setName("PARAM3").setValue(new StringDt("PARAM3val1"));
|
||||
p.addParameter().setName("PARAM3").setValue(new StringDt("PARAM3val2"));
|
||||
String inParamsStr = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/$OP_SERVER_LIST_PARAM");
|
||||
httpPost.setEntity(new StringEntity(inParamsStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("$OP_SERVER_LIST_PARAM", ourLastMethod);
|
||||
assertEquals(true, ourLastParam2.getActive().booleanValue());
|
||||
assertEquals(null, ourLastParam1);
|
||||
assertEquals(2, ourLastParam3.size());
|
||||
assertEquals("PARAM3val1", ourLastParam3.get(0).getValue());
|
||||
assertEquals("PARAM3val2", ourLastParam3.get(1).getValue());
|
||||
|
||||
Parameters resp = ourCtx.newXmlParser().parseResource(Parameters.class, response);
|
||||
assertEquals("RET1", resp.getParameter().get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -235,144 +418,15 @@ public class OperationServerDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithBundleProviderResponse() throws Exception {
|
||||
HttpGet httpPost = new HttpGet("http://localhost:" + ourPort + "/$OP_INSTANCE_BUNDLE_PROVIDER?_pretty=true");
|
||||
public void testOperationWithProfileDatatypeUrl() throws Exception {
|
||||
HttpGet httpPost = new HttpGet("http://localhost:" + ourPort + "/Patient/$OP_PROFILE_DT?PARAM1=123");
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(response);
|
||||
|
||||
Bundle resp = ourCtx.newXmlParser().parseResource(Bundle.class, response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithListParam() throws Exception {
|
||||
Parameters p = new Parameters();
|
||||
p.addParameter().setName("PARAM2").setResource(new Patient().setActive(true));
|
||||
p.addParameter().setName("PARAM3").setValue(new StringDt("PARAM3val1"));
|
||||
p.addParameter().setName("PARAM3").setValue(new StringDt("PARAM3val2"));
|
||||
String inParamsStr = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/$OP_SERVER_LIST_PARAM");
|
||||
httpPost.setEntity(new StringEntity(inParamsStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("$OP_SERVER_LIST_PARAM", ourLastMethod);
|
||||
assertEquals(true, ourLastParam2.getActive().booleanValue());
|
||||
assertEquals(null, ourLastParam1);
|
||||
assertEquals(2, ourLastParam3.size());
|
||||
assertEquals("PARAM3val1", ourLastParam3.get(0).getValue());
|
||||
assertEquals("PARAM3val2", ourLastParam3.get(1).getValue());
|
||||
|
||||
Parameters resp = ourCtx.newXmlParser().parseResource(Parameters.class, response);
|
||||
assertEquals("RET1", resp.getParameter().get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationOnInstanceAndType_Instance() throws Exception {
|
||||
Parameters p = new Parameters();
|
||||
p.addParameter().setName("PARAM1").setValue(new StringDt("PARAM1val"));
|
||||
p.addParameter().setName("PARAM2").setResource(new Patient().setActive(true));
|
||||
String inParamsStr = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/123/$OP_INSTANCE_OR_TYPE");
|
||||
httpPost.setEntity(new StringEntity(inParamsStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("PARAM1val", ourLastParam1.getValue());
|
||||
assertEquals(true, ourLastParam2.getActive().booleanValue());
|
||||
assertEquals("123", ourLastId.getIdPart());
|
||||
assertEquals("$OP_INSTANCE_OR_TYPE", ourLastMethod);
|
||||
|
||||
Parameters resp = ourCtx.newXmlParser().parseResource(Parameters.class, response);
|
||||
assertEquals("RET1", resp.getParameter().get(0).getName());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationOnInstanceAndType_Type() throws Exception {
|
||||
Parameters p = new Parameters();
|
||||
p.addParameter().setName("PARAM1").setValue(new StringDt("PARAM1val"));
|
||||
p.addParameter().setName("PARAM2").setResource(new Patient().setActive(true));
|
||||
String inParamsStr = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/$OP_INSTANCE_OR_TYPE");
|
||||
httpPost.setEntity(new StringEntity(inParamsStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
CloseableHttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("PARAM1val", ourLastParam1.getValue());
|
||||
assertEquals(true, ourLastParam2.getActive().booleanValue());
|
||||
assertEquals(null, ourLastId);
|
||||
assertEquals("$OP_INSTANCE_OR_TYPE", ourLastMethod);
|
||||
|
||||
Parameters resp = ourCtx.newXmlParser().parseResource(Parameters.class, response);
|
||||
assertEquals("RET1", resp.getParameter().get(0).getName());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOperationOnInstance() throws Exception {
|
||||
Parameters p = new Parameters();
|
||||
p.addParameter().setName("PARAM1").setValue(new StringDt("PARAM1val"));
|
||||
p.addParameter().setName("PARAM2").setResource(new Patient().setActive(true));
|
||||
String inParamsStr = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/123/$OP_INSTANCE");
|
||||
httpPost.setEntity(new StringEntity(inParamsStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("PARAM1val", ourLastParam1.getValue());
|
||||
assertEquals(true, ourLastParam2.getActive().booleanValue());
|
||||
assertEquals("123", ourLastId.getIdPart());
|
||||
assertEquals("$OP_INSTANCE", ourLastMethod);
|
||||
|
||||
Parameters resp = ourCtx.newXmlParser().parseResource(Parameters.class, response);
|
||||
assertEquals("RET1", resp.getParameter().get(0).getName());
|
||||
|
||||
/*
|
||||
* Against type should fail
|
||||
*/
|
||||
|
||||
httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/$OP_INSTANCE");
|
||||
httpPost.setEntity(new StringEntity(inParamsStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
status = ourClient.execute(httpPost);
|
||||
|
||||
response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(response);
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationCantUseGetIfItIsntIdempotent() throws Exception {
|
||||
HttpGet httpPost = new HttpGet("http://localhost:" + ourPort + "/Patient/123/$OP_INSTANCE");
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
assertEquals(Constants.STATUS_HTTP_405_METHOD_NOT_ALLOWED, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("POST", status.getFirstHeader(Constants.HEADER_ALLOW).getValue());
|
||||
assertThat(response, containsString("HTTP Method GET is not allowed"));
|
||||
assertEquals("$OP_PROFILE_DT", ourLastMethod);
|
||||
assertEquals("123", ourLastParamUnsignedInt1.getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -407,69 +461,11 @@ public class OperationServerDstu2Test {
|
|||
assertEquals("read", ourLastMethod);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInstanceEverythingPost() throws Exception {
|
||||
String inParamsStr = ourCtx.newXmlParser().encodeResourceToString(new Parameters());
|
||||
|
||||
// Try with a POST
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/123/$everything");
|
||||
httpPost.setEntity(new StringEntity(inParamsStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("instance $everything", ourLastMethod);
|
||||
assertThat(response, startsWith("<Bundle"));
|
||||
assertEquals("Patient/123", ourLastId.toUnqualifiedVersionless().getValue());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInstanceEverythingHapiClient() throws Exception {
|
||||
Parameters p = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort).operation().onInstance(new IdDt("Patient/123")).named("$everything").withParameters(new Parameters()).execute();
|
||||
Bundle b = (Bundle) p.getParameterFirstRep().getResource();
|
||||
|
||||
assertEquals("instance $everything", ourLastMethod);
|
||||
assertEquals("Patient/123", ourLastId.toUnqualifiedVersionless().getValue());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConformance() throws Exception {
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort);
|
||||
Conformance p = client.fetchConformance().ofType(Conformance.class).execute();
|
||||
List<RestOperation> ops = p.getRest().get(0).getOperation();
|
||||
assertThat(ops.size(), greaterThan(1));
|
||||
assertNull(ops.get(0).getDefinition().getReference().getBaseUrl());
|
||||
assertThat(ops.get(0).getDefinition().getReference().getValue(), startsWith("OperationDefinition/"));
|
||||
|
||||
OperationDefinition def = client.read().resource(OperationDefinition.class).withId(ops.get(0).getDefinition().getReference()).execute();
|
||||
assertThat(def.getCode(), not(blankOrNullString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInstanceEverythingGet() throws Exception {
|
||||
|
||||
// Try with a GET
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/123/$everything");
|
||||
CloseableHttpResponse status = ourClient.execute(httpGet);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals("instance $everything", ourLastMethod);
|
||||
assertThat(response, startsWith("<Bundle"));
|
||||
assertEquals("Patient/123", ourLastId.toUnqualifiedVersionless().getValue());
|
||||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
@ -498,6 +494,158 @@ public class OperationServerDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
public static void main(String[] theValue) {
|
||||
Parameters p = new Parameters();
|
||||
p.addParameter().setName("start").setValue(new DateTimeDt("2001-01-02"));
|
||||
p.addParameter().setName("end").setValue(new DateTimeDt("2015-07-10"));
|
||||
String inParamsStr = FhirContext.forDstu2().newXmlParser().encodeResourceToString(p);
|
||||
ourLog.info(inParamsStr.replace("\"", "\\\""));
|
||||
}
|
||||
|
||||
public static class PatientProvider implements IResourceProvider {
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
return Patient.class;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name="$OP_INSTANCE")
|
||||
public Parameters opInstance(
|
||||
@IdParam IdDt theId,
|
||||
@OperationParam(name="PARAM1") StringDt theParam1,
|
||||
@OperationParam(name="PARAM2") Patient theParam2
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
ourLastMethod = "$OP_INSTANCE";
|
||||
ourLastId = theId;
|
||||
ourLastParam1 = theParam1;
|
||||
ourLastParam2 = theParam2;
|
||||
|
||||
Parameters retVal = new Parameters();
|
||||
retVal.addParameter().setName("RET1").setValue(new StringDt("RETVAL1"));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name="$OP_INSTANCE_OR_TYPE")
|
||||
public Parameters opInstanceOrType(
|
||||
@IdParam(optional=true) IdDt theId,
|
||||
@OperationParam(name="PARAM1") StringDt theParam1,
|
||||
@OperationParam(name="PARAM2") Patient theParam2
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
ourLastMethod = "$OP_INSTANCE_OR_TYPE";
|
||||
ourLastId = theId;
|
||||
ourLastParam1 = theParam1;
|
||||
ourLastParam2 = theParam2;
|
||||
|
||||
Parameters retVal = new Parameters();
|
||||
retVal.addParameter().setName("RET1").setValue(new StringDt("RETVAL1"));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name="$OP_PROFILE_DT2", idempotent=true)
|
||||
public Bundle opProfileDt(
|
||||
@OperationParam(name="PARAM1") MoneyDt theParam1
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
ourLastMethod = "$OP_PROFILE_DT2";
|
||||
ourLastParamMoney1 = theParam1;
|
||||
|
||||
Bundle retVal = new Bundle();
|
||||
retVal.addEntry().getResponse().setStatus("100");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name="$OP_PROFILE_DT", idempotent=true)
|
||||
public Bundle opProfileDt(
|
||||
@OperationParam(name="PARAM1") UnsignedIntDt theParam1
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
ourLastMethod = "$OP_PROFILE_DT";
|
||||
ourLastParamUnsignedInt1 = theParam1;
|
||||
|
||||
Bundle retVal = new Bundle();
|
||||
retVal.addEntry().getResponse().setStatus("100");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name="$OP_TYPE", idempotent=true)
|
||||
public Parameters opType(
|
||||
@OperationParam(name="PARAM1") StringDt theParam1,
|
||||
@OperationParam(name="PARAM2") Patient theParam2
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
ourLastMethod = "$OP_TYPE";
|
||||
ourLastParam1 = theParam1;
|
||||
ourLastParam2 = theParam2;
|
||||
|
||||
Parameters retVal = new Parameters();
|
||||
retVal.addParameter().setName("RET1").setValue(new StringDt("RETVAL1"));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name="$OP_TYPE_ONLY_STRING", idempotent=true)
|
||||
public Parameters opTypeOnlyString(
|
||||
@OperationParam(name="PARAM1") StringDt theParam1
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
ourLastMethod = "$OP_TYPE";
|
||||
ourLastParam1 = theParam1;
|
||||
|
||||
Parameters retVal = new Parameters();
|
||||
retVal.addParameter().setName("RET1").setValue(new StringDt("RETVAL1"));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name="$OP_TYPE_RET_BUNDLE")
|
||||
public Bundle opTypeRetBundle(
|
||||
@OperationParam(name="PARAM1") StringDt theParam1,
|
||||
@OperationParam(name="PARAM2") Patient theParam2
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
ourLastMethod = "$OP_TYPE_RET_BUNDLE";
|
||||
ourLastParam1 = theParam1;
|
||||
ourLastParam2 = theParam2;
|
||||
|
||||
Bundle retVal = new Bundle();
|
||||
retVal.addEntry().getResponse().setStatus("100");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Operation(name = "$everything", idempotent=true)
|
||||
public Bundle patientEverything(@IdParam IdDt thePatientId) {
|
||||
ourLastMethod = "instance $everything";
|
||||
ourLastId = thePatientId;
|
||||
return new Bundle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Just to make sure this method doesn't "steal" calls
|
||||
*/
|
||||
@Read
|
||||
public Patient read(@IdParam IdDt theId) {
|
||||
ourLastMethod = "read";
|
||||
Patient retVal = new Patient();
|
||||
retVal.setId(theId);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class PlainProvider {
|
||||
|
||||
//@formatter:off
|
||||
|
@ -552,148 +700,4 @@ public class OperationServerDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
public static class PatientProvider implements IResourceProvider {
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
return Patient.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Just to make sure this method doesn't "steal" calls
|
||||
*/
|
||||
@Read
|
||||
public Patient read(@IdParam IdDt theId) {
|
||||
ourLastMethod = "read";
|
||||
Patient retVal = new Patient();
|
||||
retVal.setId(theId);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Operation(name = "$everything", idempotent=true)
|
||||
public Bundle patientEverything(@IdParam IdDt thePatientId) {
|
||||
ourLastMethod = "instance $everything";
|
||||
ourLastId = thePatientId;
|
||||
return new Bundle();
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name="$OP_TYPE", idempotent=true)
|
||||
public Parameters opType(
|
||||
@OperationParam(name="PARAM1") StringDt theParam1,
|
||||
@OperationParam(name="PARAM2") Patient theParam2
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
ourLastMethod = "$OP_TYPE";
|
||||
ourLastParam1 = theParam1;
|
||||
ourLastParam2 = theParam2;
|
||||
|
||||
Parameters retVal = new Parameters();
|
||||
retVal.addParameter().setName("RET1").setValue(new StringDt("RETVAL1"));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name="$OP_TYPE_ONLY_STRING", idempotent=true)
|
||||
public Parameters opTypeOnlyString(
|
||||
@OperationParam(name="PARAM1") StringDt theParam1
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
ourLastMethod = "$OP_TYPE";
|
||||
ourLastParam1 = theParam1;
|
||||
|
||||
Parameters retVal = new Parameters();
|
||||
retVal.addParameter().setName("RET1").setValue(new StringDt("RETVAL1"));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name="$OP_TYPE_RET_BUNDLE")
|
||||
public Bundle opTypeRetBundle(
|
||||
@OperationParam(name="PARAM1") StringDt theParam1,
|
||||
@OperationParam(name="PARAM2") Patient theParam2
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
ourLastMethod = "$OP_TYPE_RET_BUNDLE";
|
||||
ourLastParam1 = theParam1;
|
||||
ourLastParam2 = theParam2;
|
||||
|
||||
Bundle retVal = new Bundle();
|
||||
retVal.addEntry().getResponse().setStatus("100");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name="$OP_PROFILE_DT", idempotent=true)
|
||||
public Bundle opProfileDt(
|
||||
@OperationParam(name="PARAM1") UnsignedIntDt theParam1
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
ourLastMethod = "$OP_PROFILE_DT";
|
||||
ourLastParamUnsignedInt1 = theParam1;
|
||||
|
||||
Bundle retVal = new Bundle();
|
||||
retVal.addEntry().getResponse().setStatus("100");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name="$OP_PROFILE_DT2", idempotent=true)
|
||||
public Bundle opProfileDt(
|
||||
@OperationParam(name="PARAM1") MoneyDt theParam1
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
ourLastMethod = "$OP_PROFILE_DT2";
|
||||
ourLastParamMoney1 = theParam1;
|
||||
|
||||
Bundle retVal = new Bundle();
|
||||
retVal.addEntry().getResponse().setStatus("100");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name="$OP_INSTANCE")
|
||||
public Parameters opInstance(
|
||||
@IdParam IdDt theId,
|
||||
@OperationParam(name="PARAM1") StringDt theParam1,
|
||||
@OperationParam(name="PARAM2") Patient theParam2
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
ourLastMethod = "$OP_INSTANCE";
|
||||
ourLastId = theId;
|
||||
ourLastParam1 = theParam1;
|
||||
ourLastParam2 = theParam2;
|
||||
|
||||
Parameters retVal = new Parameters();
|
||||
retVal.addParameter().setName("RET1").setValue(new StringDt("RETVAL1"));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name="$OP_INSTANCE_OR_TYPE")
|
||||
public Parameters opInstanceOrType(
|
||||
@IdParam(optional=true) IdDt theId,
|
||||
@OperationParam(name="PARAM1") StringDt theParam1,
|
||||
@OperationParam(name="PARAM2") Patient theParam2
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
ourLastMethod = "$OP_INSTANCE_OR_TYPE";
|
||||
ourLastId = theId;
|
||||
ourLastParam1 = theParam1;
|
||||
ourLastParam2 = theParam2;
|
||||
|
||||
Parameters retVal = new Parameters();
|
||||
retVal.addParameter().setName("RET1").setValue(new StringDt("RETVAL1"));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ import ca.uhn.fhir.rest.param.TokenParam;
|
|||
import ca.uhn.fhir.rest.param.TokenParamModifier;
|
||||
import ca.uhn.fhir.rest.server.provider.dstu2.ServerConformanceProvider;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
|
||||
public class OperationServerWithSearchParamTypesDstu2Test {
|
||||
|
@ -70,6 +71,7 @@ public class OperationServerWithSearchParamTypesDstu2Test {
|
|||
ourLastParamValTok = null;
|
||||
}
|
||||
|
||||
|
||||
private HttpServletRequest createHttpServletRequest() {
|
||||
HttpServletRequest req = mock(HttpServletRequest.class);
|
||||
when(req.getRequestURI()).thenReturn("/FhirStorm/fhir/Patient/_search");
|
||||
|
@ -324,8 +326,9 @@ public class OperationServerWithSearchParamTypesDstu2Test {
|
|||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
@ -35,39 +35,17 @@ import ca.uhn.fhir.rest.annotation.ResourceParam;
|
|||
import ca.uhn.fhir.rest.annotation.Update;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class PreferTest {
|
||||
private static CloseableHttpClient ourClient;
|
||||
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(PreferTest.class);
|
||||
private static int ourPort;
|
||||
private static Server ourServer;
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateWithNoPrefer() throws Exception {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setValue("002");
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient");
|
||||
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
ourLog.info("Response was:\n{}", responseContent);
|
||||
|
||||
assertEquals(201, status.getStatusLine().getStatusCode());
|
||||
assertEquals("http://localhost:" + ourPort + "/Patient/001/_history/002", status.getFirstHeader("location").getValue());
|
||||
assertEquals("http://localhost:" + ourPort + "/Patient/001/_history/002", status.getFirstHeader("content-location").getValue());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreatePreferMinimal() throws Exception {
|
||||
|
||||
|
@ -93,6 +71,7 @@ public class PreferTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreatePreferRepresentation() throws Exception {
|
||||
|
||||
|
@ -119,9 +98,33 @@ public class PreferTest {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateWithNoPrefer() throws Exception {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setValue("002");
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient");
|
||||
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
ourLog.info("Response was:\n{}", responseContent);
|
||||
|
||||
assertEquals(201, status.getStatusLine().getStatusCode());
|
||||
assertEquals("http://localhost:" + ourPort + "/Patient/001/_history/002", status.getFirstHeader("location").getValue());
|
||||
assertEquals("http://localhost:" + ourPort + "/Patient/001/_history/002", status.getFirstHeader("content-location").getValue());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
|
@ -149,11 +152,6 @@ public class PreferTest {
|
|||
|
||||
public static class PatientProvider implements IResourceProvider {
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
return Patient.class;
|
||||
}
|
||||
|
||||
@Create()
|
||||
public MethodOutcome createPatient(@ResourceParam Patient thePatient) {
|
||||
IdDt id = new IdDt("Patient/001/_history/002");
|
||||
|
@ -166,6 +164,11 @@ public class PreferTest {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
return Patient.class;
|
||||
}
|
||||
|
||||
@Update()
|
||||
public MethodOutcome updatePatient(@ResourceParam Patient thePatient, @IdParam IdDt theIdParam) {
|
||||
IdDt id = new IdDt("Patient/001/_history/002");
|
||||
|
|
|
@ -34,17 +34,18 @@ import ca.uhn.fhir.rest.server.AddProfileTagEnum;
|
|||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class ReadDstu2Test {
|
||||
|
||||
private static CloseableHttpClient ourClient;
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static boolean ourInitializeProfileList;
|
||||
private static IdDt ourLastId;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ReadDstu2Test.class);
|
||||
private static int ourPort;
|
||||
private static Server ourServer;
|
||||
private static RestfulServer ourServlet;
|
||||
private static IdDt ourLastId;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
|
@ -53,6 +54,7 @@ public class ReadDstu2Test {
|
|||
ourLastId = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* See #302
|
||||
*/
|
||||
|
@ -75,27 +77,6 @@ public class ReadDstu2Test {
|
|||
assertEquals("Patient/123", ourLastId.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVread() throws Exception {
|
||||
ourCtx.setAddProfileTagWhenEncoding(AddProfileTagEnum.ONLY_FOR_CUSTOM);
|
||||
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/123/_history/1");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertThat(responseContent, containsString("p1ReadValue"));
|
||||
assertThat(responseContent, containsString("p1ReadId"));
|
||||
assertEquals("<Patient xmlns=\"http://hl7.org/fhir\"><id value=\"p1ReadId\"/><meta><profile value=\"http://foo_profile\"/></meta><identifier><value value=\"p1ReadValue\"/></identifier></Patient>", responseContent);
|
||||
|
||||
ourLog.info(responseContent);
|
||||
|
||||
assertEquals("Patient/123/_history/1", ourLastId.getValue());
|
||||
assertEquals("123", ourLastId.getIdPart());
|
||||
assertEquals("1", ourLastId.getVersionIdPart());
|
||||
}
|
||||
|
||||
/**
|
||||
* See #302 and #268
|
||||
*/
|
||||
|
@ -116,7 +97,7 @@ public class ReadDstu2Test {
|
|||
assertThat(responseContent, containsString("p1ReadId"));
|
||||
assertEquals("<Patient xmlns=\"http://hl7.org/fhir\"><id value=\"p1ReadId\"/><meta><profile value=\"http://foo\"/><profile value=\"http://foo_profile\"/></meta><identifier><value value=\"p1ReadValue\"/></identifier></Patient>", responseContent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* In DSTU2+ the resource ID appears in the resource body
|
||||
*/
|
||||
|
@ -135,7 +116,7 @@ public class ReadDstu2Test {
|
|||
assertThat(responseContent, containsString("p1ReadId"));
|
||||
assertThat(responseContent, containsString("\"meta\":{\"profile\":[\"http://foo_profile\"]}"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* In DSTU2+ the resource ID appears in the resource body
|
||||
*/
|
||||
|
@ -152,10 +133,32 @@ public class ReadDstu2Test {
|
|||
|
||||
ourLog.info(responseContent);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVread() throws Exception {
|
||||
ourCtx.setAddProfileTagWhenEncoding(AddProfileTagEnum.ONLY_FOR_CUSTOM);
|
||||
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/123/_history/1");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertThat(responseContent, containsString("p1ReadValue"));
|
||||
assertThat(responseContent, containsString("p1ReadId"));
|
||||
assertEquals("<Patient xmlns=\"http://hl7.org/fhir\"><id value=\"p1ReadId\"/><meta><profile value=\"http://foo_profile\"/></meta><identifier><value value=\"p1ReadValue\"/></identifier></Patient>", responseContent);
|
||||
|
||||
ourLog.info(responseContent);
|
||||
|
||||
assertEquals("Patient/123/_history/1", ourLastId.getValue());
|
||||
assertEquals("123", ourLastId.getIdPart());
|
||||
assertEquals("1", ourLastId.getVersionIdPart());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
@ -49,19 +49,20 @@ import ca.uhn.fhir.rest.param.ReferenceParam;
|
|||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.util.PatternMatcher;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class SearchDstu2Test {
|
||||
|
||||
private static CloseableHttpClient ourClient;
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static DateAndListParam ourLastDateAndList;
|
||||
private static String ourLastMethod;
|
||||
private static QuantityParam ourLastQuantity;
|
||||
private static ReferenceParam ourLastRef;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchDstu2Test.class);
|
||||
private static int ourPort;
|
||||
private static InstantDt ourReturnPublished;
|
||||
private static Server ourServer;
|
||||
private static String ourLastMethod;
|
||||
private static DateAndListParam ourLastDateAndList;
|
||||
private static ReferenceParam ourLastRef;
|
||||
private static QuantityParam ourLastQuantity;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
|
@ -71,9 +72,69 @@ public class SearchDstu2Test {
|
|||
ourLastQuantity = null;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSearchWhitelist01Failing() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchWhitelist01&ref=value");
|
||||
public void testEncodeConvertsReferencesToRelative() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchWithRef");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
|
||||
assertThat(responseContent, not(containsString("text")));
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
Patient patient = (Patient) ourCtx.newXmlParser().parseResource(Bundle.class, responseContent).getEntry().get(0).getResource();
|
||||
String ref = patient.getManagingOrganization().getReference().getValue();
|
||||
assertEquals("Organization/555", ref);
|
||||
assertNull(status.getFirstHeader(Constants.HEADER_CONTENT_LOCATION));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeConvertsReferencesToRelativeJson() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchWithRef&_format=json");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
|
||||
assertThat(responseContent, not(containsString("text")));
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
Patient patient = (Patient) ourCtx.newJsonParser().parseResource(Bundle.class, responseContent).getEntry().get(0).getResource();
|
||||
String ref = patient.getManagingOrganization().getReference().getValue();
|
||||
assertEquals("Organization/555", ref);
|
||||
assertNull(status.getFirstHeader(Constants.HEADER_CONTENT_LOCATION));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultBundleHasUpdateTime() throws Exception {
|
||||
ourReturnPublished = new InstantDt("2011-02-03T11:22:33Z");
|
||||
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchWithBundleProvider&_pretty=true");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
|
||||
assertThat(responseContent, stringContainsInOrder("<lastUpdated value=\"2011-02-03T11:22:33Z\"/>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultBundleHasUuid() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchWithRef");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertThat(responseContent, PatternMatcher.pattern("id value..[0-9a-f-]+\\\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchBlacklist01Failing() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchBlacklist01&ref.black1=value");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
@ -81,6 +142,132 @@ public class SearchDstu2Test {
|
|||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchBlacklist01Passing() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchBlacklist01&ref.white1=value");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertEquals("searchBlacklist01", ourLastMethod);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPost() throws Exception {
|
||||
HttpPost httpGet = new HttpPost("http://localhost:" + ourPort + "/Patient/_search");
|
||||
StringEntity entity = new StringEntity("searchDateAndList=2001,2002&searchDateAndList=2003,2004", ContentType.APPLICATION_FORM_URLENCODED);
|
||||
httpGet.setEntity(entity);
|
||||
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
assertEquals("searchDateAndList", ourLastMethod);
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().size());
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().size());
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().get(1).getValuesAsQueryTokens().size());
|
||||
assertEquals("2001", ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(0).getValueAsString());
|
||||
assertEquals("2002", ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(1).getValueAsString());
|
||||
assertThat(responseContent, containsString("SYSTEM"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPostWithBodyAndUrlParams() throws Exception {
|
||||
|
||||
HttpPost httpGet = new HttpPost("http://localhost:" + ourPort + "/Patient/_search?_format=json");
|
||||
StringEntity entity = new StringEntity("searchDateAndList=2001,2002&searchDateAndList=2003,2004", ContentType.APPLICATION_FORM_URLENCODED);
|
||||
httpGet.setEntity(entity);
|
||||
|
||||
CloseableHttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
assertEquals("searchDateAndList", ourLastMethod);
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().size());
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().size());
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().get(1).getValuesAsQueryTokens().size());
|
||||
assertEquals("2001", ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(0).getValueAsString());
|
||||
assertEquals("2002", ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(1).getValueAsString());
|
||||
assertThat(responseContent, containsString(":\"SYSTEM\""));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPut() throws Exception {
|
||||
HttpPut httpGet = new HttpPut("http://localhost:" + ourPort + "/Patient/_search");
|
||||
StringEntity entity = new StringEntity("searchDateAndList=2001,2002&searchDateAndList=2003,2004", ContentType.APPLICATION_FORM_URLENCODED);
|
||||
httpGet.setEntity(entity);
|
||||
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchDateAndList() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?searchDateAndList=2001,2002&searchDateAndList=2003,2004");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
assertEquals("searchDateAndList", ourLastMethod);
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().size());
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().size());
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().get(1).getValuesAsQueryTokens().size());
|
||||
assertEquals("2001", ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(0).getValueAsString());
|
||||
assertEquals("2002", ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(1).getValueAsString());
|
||||
}
|
||||
|
||||
/**
|
||||
* See #247
|
||||
*/
|
||||
@Test
|
||||
public void testSearchPagesAllHaveCorrectBundleType() throws Exception {
|
||||
Bundle resp;
|
||||
{
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?searchHugeResults=yes&_count=10&_pretty=true");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
resp = ourCtx.newXmlParser().parseResource(Bundle.class, responseContent);
|
||||
assertEquals("searchset", resp.getType());
|
||||
assertEquals(100, resp.getTotal().intValue());
|
||||
}
|
||||
Link nextLink = resp.getLink("next");
|
||||
assertThat(nextLink.getUrl(), startsWith("http://"));
|
||||
|
||||
// Now try the next page
|
||||
{
|
||||
HttpGet httpGet = new HttpGet(nextLink.getUrl());
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
resp = ourCtx.newXmlParser().parseResource(Bundle.class, responseContent);
|
||||
assertEquals("searchset", resp.getType());
|
||||
assertEquals(100, resp.getTotal().intValue());
|
||||
}
|
||||
|
||||
nextLink = resp.getLink("next");
|
||||
assertThat(nextLink.getUrl(), startsWith("http://"));
|
||||
|
||||
// Now try a third page
|
||||
{
|
||||
HttpGet httpGet = new HttpGet(nextLink.getUrl());
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
resp = ourCtx.newXmlParser().parseResource(Bundle.class, responseContent);
|
||||
assertEquals("searchset", resp.getType());
|
||||
assertEquals(100, resp.getTotal().intValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See #296
|
||||
*/
|
||||
|
@ -164,92 +351,8 @@ public class SearchDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchDateAndList() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?searchDateAndList=2001,2002&searchDateAndList=2003,2004");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
assertEquals("searchDateAndList", ourLastMethod);
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().size());
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().size());
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().get(1).getValuesAsQueryTokens().size());
|
||||
assertEquals("2001", ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(0).getValueAsString());
|
||||
assertEquals("2002", ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(1).getValueAsString());
|
||||
}
|
||||
|
||||
/**
|
||||
* See #247
|
||||
*/
|
||||
@Test
|
||||
public void testSearchPagesAllHaveCorrectBundleType() throws Exception {
|
||||
Bundle resp;
|
||||
{
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?searchHugeResults=yes&_count=10&_pretty=true");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
resp = ourCtx.newXmlParser().parseResource(Bundle.class, responseContent);
|
||||
assertEquals("searchset", resp.getType());
|
||||
assertEquals(100, resp.getTotal().intValue());
|
||||
}
|
||||
Link nextLink = resp.getLink("next");
|
||||
assertThat(nextLink.getUrl(), startsWith("http://"));
|
||||
|
||||
// Now try the next page
|
||||
{
|
||||
HttpGet httpGet = new HttpGet(nextLink.getUrl());
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
resp = ourCtx.newXmlParser().parseResource(Bundle.class, responseContent);
|
||||
assertEquals("searchset", resp.getType());
|
||||
assertEquals(100, resp.getTotal().intValue());
|
||||
}
|
||||
|
||||
nextLink = resp.getLink("next");
|
||||
assertThat(nextLink.getUrl(), startsWith("http://"));
|
||||
|
||||
// Now try a third page
|
||||
{
|
||||
HttpGet httpGet = new HttpGet(nextLink.getUrl());
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
resp = ourCtx.newXmlParser().parseResource(Bundle.class, responseContent);
|
||||
assertEquals("searchset", resp.getType());
|
||||
assertEquals(100, resp.getTotal().intValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPost() throws Exception {
|
||||
HttpPost httpGet = new HttpPost("http://localhost:" + ourPort + "/Patient/_search");
|
||||
StringEntity entity = new StringEntity("searchDateAndList=2001,2002&searchDateAndList=2003,2004", ContentType.APPLICATION_FORM_URLENCODED);
|
||||
httpGet.setEntity(entity);
|
||||
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
assertEquals("searchDateAndList", ourLastMethod);
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().size());
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().size());
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().get(1).getValuesAsQueryTokens().size());
|
||||
assertEquals("2001", ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(0).getValueAsString());
|
||||
assertEquals("2002", ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(1).getValueAsString());
|
||||
assertThat(responseContent, containsString("SYSTEM"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPut() throws Exception {
|
||||
HttpPut httpGet = new HttpPut("http://localhost:" + ourPort + "/Patient/_search");
|
||||
StringEntity entity = new StringEntity("searchDateAndList=2001,2002&searchDateAndList=2003,2004", ContentType.APPLICATION_FORM_URLENCODED);
|
||||
httpGet.setEntity(entity);
|
||||
|
||||
public void testSearchWhitelist01Failing() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchWhitelist01&ref=value");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
@ -257,48 +360,6 @@ public class SearchDstu2Test {
|
|||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPostWithBodyAndUrlParams() throws Exception {
|
||||
|
||||
HttpPost httpGet = new HttpPost("http://localhost:" + ourPort + "/Patient/_search?_format=json");
|
||||
StringEntity entity = new StringEntity("searchDateAndList=2001,2002&searchDateAndList=2003,2004", ContentType.APPLICATION_FORM_URLENCODED);
|
||||
httpGet.setEntity(entity);
|
||||
|
||||
CloseableHttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
assertEquals("searchDateAndList", ourLastMethod);
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().size());
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().size());
|
||||
assertEquals(2, ourLastDateAndList.getValuesAsQueryTokens().get(1).getValuesAsQueryTokens().size());
|
||||
assertEquals("2001", ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(0).getValueAsString());
|
||||
assertEquals("2002", ourLastDateAndList.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(1).getValueAsString());
|
||||
assertThat(responseContent, containsString(":\"SYSTEM\""));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchBlacklist01Failing() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchBlacklist01&ref.black1=value");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchBlacklist01Passing() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchBlacklist01&ref.white1=value");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertEquals("searchBlacklist01", ourLastMethod);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWhitelist01Passing() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchWhitelist01&ref.white1=value");
|
||||
|
@ -310,68 +371,11 @@ public class SearchDstu2Test {
|
|||
assertEquals("searchWhitelist01", ourLastMethod);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeConvertsReferencesToRelative() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchWithRef");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
|
||||
assertThat(responseContent, not(containsString("text")));
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
Patient patient = (Patient) ourCtx.newXmlParser().parseResource(Bundle.class, responseContent).getEntry().get(0).getResource();
|
||||
String ref = patient.getManagingOrganization().getReference().getValue();
|
||||
assertEquals("Organization/555", ref);
|
||||
assertNull(status.getFirstHeader(Constants.HEADER_CONTENT_LOCATION));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeConvertsReferencesToRelativeJson() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchWithRef&_format=json");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
|
||||
assertThat(responseContent, not(containsString("text")));
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
Patient patient = (Patient) ourCtx.newJsonParser().parseResource(Bundle.class, responseContent).getEntry().get(0).getResource();
|
||||
String ref = patient.getManagingOrganization().getReference().getValue();
|
||||
assertEquals("Organization/555", ref);
|
||||
assertNull(status.getFirstHeader(Constants.HEADER_CONTENT_LOCATION));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultBundleHasUuid() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchWithRef");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertThat(responseContent, PatternMatcher.pattern("id value..[0-9a-f-]+\\\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultBundleHasUpdateTime() throws Exception {
|
||||
ourReturnPublished = new InstantDt("2011-02-03T11:22:33Z");
|
||||
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchWithBundleProvider&_pretty=true");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
|
||||
assertThat(responseContent, stringContainsInOrder("<lastUpdated value=\"2011-02-03T11:22:33Z\"/>"));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
@ -409,30 +413,10 @@ public class SearchDstu2Test {
|
|||
}
|
||||
|
||||
//@formatter:off
|
||||
@Search(queryName="searchWhitelist01")
|
||||
public List<Patient> searchWhitelist01(
|
||||
@RequiredParam(chainWhitelist="white1", name = "ref") ReferenceParam theParam) {
|
||||
ourLastMethod = "searchWhitelist01";
|
||||
return Collections.emptyList();
|
||||
}
|
||||
//@formatter:on
|
||||
|
||||
//@formatter:off
|
||||
@Search()
|
||||
public List<Patient> searchQuantity(
|
||||
@RequiredParam(name="quantity") QuantityParam theParam) {
|
||||
ourLastMethod = "searchQuantity";
|
||||
ourLastQuantity = theParam;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
//@formatter:on
|
||||
|
||||
//@formatter:off
|
||||
@Search(queryName="searchNoList")
|
||||
public List<Patient> searchNoList(
|
||||
@RequiredParam(name = "ref") ReferenceParam theParam) {
|
||||
ourLastMethod = "searchNoList";
|
||||
ourLastRef = theParam;
|
||||
@Search(queryName="searchBlacklist01")
|
||||
public List<Patient> searchBlacklist01(
|
||||
@RequiredParam(chainBlacklist="black1", name = "ref") ReferenceParam theParam) {
|
||||
ourLastMethod = "searchBlacklist01";
|
||||
return Collections.emptyList();
|
||||
}
|
||||
//@formatter:on
|
||||
|
@ -467,10 +451,30 @@ public class SearchDstu2Test {
|
|||
//@formatter:on
|
||||
|
||||
//@formatter:off
|
||||
@Search(queryName="searchBlacklist01")
|
||||
public List<Patient> searchBlacklist01(
|
||||
@RequiredParam(chainBlacklist="black1", name = "ref") ReferenceParam theParam) {
|
||||
ourLastMethod = "searchBlacklist01";
|
||||
@Search(queryName="searchNoList")
|
||||
public List<Patient> searchNoList(
|
||||
@RequiredParam(name = "ref") ReferenceParam theParam) {
|
||||
ourLastMethod = "searchNoList";
|
||||
ourLastRef = theParam;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
//@formatter:on
|
||||
|
||||
//@formatter:off
|
||||
@Search()
|
||||
public List<Patient> searchQuantity(
|
||||
@RequiredParam(name="quantity") QuantityParam theParam) {
|
||||
ourLastMethod = "searchQuantity";
|
||||
ourLastQuantity = theParam;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
//@formatter:on
|
||||
|
||||
//@formatter:off
|
||||
@Search(queryName="searchWhitelist01")
|
||||
public List<Patient> searchWhitelist01(
|
||||
@RequiredParam(chainWhitelist="white1", name = "ref") ReferenceParam theParam) {
|
||||
ourLastMethod = "searchWhitelist01";
|
||||
return Collections.emptyList();
|
||||
}
|
||||
//@formatter:on
|
||||
|
|
|
@ -24,14 +24,15 @@ import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
|||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class SearchWithDstu2BundleTest {
|
||||
|
||||
private static CloseableHttpClient ourClient;
|
||||
private static int ourPort;
|
||||
private static Server ourServer;
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchWithDstu2BundleTest.class);
|
||||
private static int ourPort;
|
||||
private static Server ourServer;
|
||||
|
||||
@Test
|
||||
public void testSearch() throws Exception {
|
||||
|
@ -61,9 +62,11 @@ public class SearchWithDstu2BundleTest {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
@ -95,6 +98,11 @@ public class SearchWithDstu2BundleTest {
|
|||
*/
|
||||
public static class DummyPatientResourceProvider implements IResourceProvider {
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
return Patient.class;
|
||||
}
|
||||
|
||||
@Search
|
||||
public Bundle search() {
|
||||
Bundle retVal = new Bundle();
|
||||
|
@ -108,11 +116,6 @@ public class SearchWithDstu2BundleTest {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
return Patient.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,15 +37,16 @@ import ca.uhn.fhir.rest.param.ReferenceParam;
|
|||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.param.TokenParam;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class SearchWithGenericListDstu2Test {
|
||||
|
||||
private static CloseableHttpClient ourClient;
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static String ourLastMethod;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchWithGenericListDstu2Test.class);
|
||||
private static int ourPort;
|
||||
private static Server ourServer;
|
||||
private static String ourLastMethod;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
|
@ -68,9 +69,11 @@ public class SearchWithGenericListDstu2Test {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
@ -18,6 +18,7 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -65,6 +66,7 @@ import ca.uhn.fhir.rest.param.DateRangeParam;
|
|||
import ca.uhn.fhir.rest.param.ReferenceAndListParam;
|
||||
import ca.uhn.fhir.rest.param.TokenOrListParam;
|
||||
import ca.uhn.fhir.rest.server.provider.dstu2.ServerConformanceProvider;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.validation.ValidationResult;
|
||||
|
||||
public class ServerConformanceProviderDstu2Test {
|
||||
|
@ -72,6 +74,13 @@ public class ServerConformanceProviderDstu2Test {
|
|||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServerConformanceProviderDstu2Test.class);
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
private HttpServletRequest createHttpServletRequest() {
|
||||
HttpServletRequest req = mock(HttpServletRequest.class);
|
||||
when(req.getRequestURI()).thenReturn("/FhirStorm/fhir/Patient/_search");
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue