Fix tests
This commit is contained in:
parent
20b6994cc8
commit
de65184afb
|
@ -32,7 +32,6 @@ import org.apache.commons.lang3.Validate;
|
|||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import ca.uhn.fhir.i18n.HapiLocalizer;
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
|
@ -497,7 +496,7 @@ public class FhirContext {
|
|||
* The custom type to add (must not be <code>null</code>)
|
||||
*/
|
||||
public void registerCustomType(Class<? extends IBase> theType) {
|
||||
Assert.notNull(theType, "theType must not be null");
|
||||
Validate.notNull(theType, "theType must not be null");
|
||||
|
||||
ensureCustomTypeList();
|
||||
myCustomTypes.add(theType);
|
||||
|
@ -517,8 +516,8 @@ public class FhirContext {
|
|||
* The custom types to add (must not be <code>null</code> or contain null elements in the collection)
|
||||
*/
|
||||
public void registerCustomTypes(Collection<Class<? extends IBase>> theTypes) {
|
||||
Assert.notNull(theTypes, "theTypes must not be null");
|
||||
Assert.noNullElements(theTypes.toArray(), "theTypes must not contain any null elements");
|
||||
Validate.notNull(theTypes, "theTypes must not be null");
|
||||
Validate.noNullElements(theTypes.toArray(), "theTypes must not contain any null elements");
|
||||
|
||||
ensureCustomTypeList();
|
||||
|
||||
|
|
|
@ -1261,18 +1261,9 @@ public class FhirResourceDaoDstu2SearchNoFtTest extends BaseJpaDstu2Test {
|
|||
assertEquals(1, result.size());
|
||||
assertEquals(obsId01.getIdPart(), result.get(0).getId().getIdPart());
|
||||
|
||||
try {
|
||||
myObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam("testSearchResourceLinkWithTextLogicalId99"));
|
||||
fail();
|
||||
} catch (ResourceNotFoundException e) {
|
||||
// good
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: it's kind of weird that we throw a 404 for textual IDs that don't exist, but just return an empty list
|
||||
* for numeric IDs that don't exist
|
||||
*/
|
||||
|
||||
result = toList(myObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam("testSearchResourceLinkWithTextLogicalId99")));
|
||||
assertEquals(0, result.size());
|
||||
|
||||
result = toList(myObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam("999999999999999")));
|
||||
assertEquals(0, result.size());
|
||||
|
||||
|
|
|
@ -8,9 +8,12 @@ import java.io.IOException;
|
|||
import java.util.Arrays;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
|
@ -29,7 +32,6 @@ import ca.uhn.fhir.rest.server.EncodingEnum;
|
|||
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 {
|
||||
|
@ -40,6 +42,16 @@ public class FhirResourceDaoDstu2ValidateTest extends BaseJpaDstu2Test {
|
|||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
myDaoConfig.setAllowExternalReferences(true);
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
myDaoConfig.setAllowExternalReferences(new DaoConfig().isAllowExternalReferences());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateResourceContainingProfileDeclarationJson() throws Exception {
|
||||
|
|
|
@ -1376,17 +1376,8 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
|||
assertEquals(1, result.size());
|
||||
assertEquals(obsId01.getIdPart(), result.get(0).getIdElement().getIdPart());
|
||||
|
||||
try {
|
||||
myObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam("testSearchResourceLinkWithTextLogicalId99"));
|
||||
fail();
|
||||
} catch (ResourceNotFoundException e) {
|
||||
// good
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: it's kind of weird that we throw a 404 for textual IDs that don't exist, but just return an empty list
|
||||
* for numeric IDs that don't exist
|
||||
*/
|
||||
result = toList(myObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam("testSearchResourceLinkWithTextLogicalId99")));
|
||||
assertEquals(0, result.size());
|
||||
|
||||
result = toList(myObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam("999999999999999")));
|
||||
assertEquals(0, result.size());
|
||||
|
|
|
@ -160,7 +160,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
IIdType id0 = myConditionDao.create(c0, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
Condition c1 = new Condition();
|
||||
c1.setOnset(new Age().setValue(100l).setCode("AGECODE"));
|
||||
c1.setOnset(new Age().setValue(100L).setCode("AGECODE"));
|
||||
IIdType id1 = myConditionDao.create(c1, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
Condition c2 = new Condition();
|
||||
|
@ -212,8 +212,10 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
myPatientDao.read(theId, mySrd);
|
||||
} else if ("Organization".equals(theId.getResourceType())) {
|
||||
myOrganizationDao.read(theId, mySrd);
|
||||
} else if ("CodeSystem".equals(theId.getResourceType())) {
|
||||
myCodeSystemDao.read(theId, mySrd);
|
||||
} else {
|
||||
fail("No type");
|
||||
fail("Can't handle type: " + theId.getResourceType());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -362,12 +362,12 @@ public class ResourceProviderDstu1Test extends BaseJpaTest {
|
|||
|
||||
Organization o1 = new Organization();
|
||||
o1.setName("testSearchByResourceChainName01");
|
||||
IIdType o1id = ourClient.create().resource(o1).execute().getId();
|
||||
IIdType o1id = ourClient.create().resource(o1).execute().getId().toUnqualifiedVersionless();
|
||||
|
||||
Patient p1 = new Patient();
|
||||
p1.addIdentifier().setSystem("urn:system").setValue("testSearchByResourceChain01");
|
||||
p1.addName().addFamily("testSearchByResourceChainFamily01").addGiven("testSearchByResourceChainGiven01");
|
||||
p1.setManagingOrganization(new ResourceReferenceDt(o1id));
|
||||
p1.setManagingOrganization(new ResourceReferenceDt(o1id.toUnqualifiedVersionless()));
|
||||
IIdType p1Id = ourClient.create().resource(p1).execute().getId();
|
||||
|
||||
//@formatter:off
|
||||
|
@ -398,7 +398,7 @@ public class ResourceProviderDstu1Test extends BaseJpaTest {
|
|||
|
||||
Patient pat = new Patient();
|
||||
pat.addIdentifier().setSystem("urn:system").setValue("testSearchWithInclude02");
|
||||
pat.getManagingOrganization().setReference(orgId);
|
||||
pat.getManagingOrganization().setReference(orgId.toUnqualifiedVersionless());
|
||||
ourClient.create().resource(pat).prettyPrint().encodedXml().execute().getId();
|
||||
|
||||
//@formatter:off
|
||||
|
|
|
@ -1526,12 +1526,12 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
|
||||
Organization o1 = new Organization();
|
||||
o1.setName("testSearchByResourceChainName01");
|
||||
IdDt o1id = (IdDt) ourClient.create().resource(o1).execute().getId();
|
||||
IdDt o1id = (IdDt) ourClient.create().resource(o1).execute().getId().toUnqualifiedVersionless();
|
||||
|
||||
Patient p1 = new Patient();
|
||||
p1.addIdentifier().setSystem("urn:system").setValue("testSearchByResourceChain01");
|
||||
p1.addName().addFamily("testSearchByResourceChainFamily01").addGiven("testSearchByResourceChainGiven01");
|
||||
p1.setManagingOrganization(new ResourceReferenceDt(o1id));
|
||||
p1.setManagingOrganization(new ResourceReferenceDt(o1id.toUnqualifiedVersionless()));
|
||||
IdDt p1Id = (IdDt) ourClient.create().resource(p1).execute().getId();
|
||||
|
||||
//@formatter:off
|
||||
|
@ -1696,7 +1696,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
|
||||
Patient pat = new Patient();
|
||||
pat.addIdentifier().setSystem("urn:system:rpdstu2").setValue("testSearchWithInclude02");
|
||||
pat.getManagingOrganization().setReference(orgId);
|
||||
pat.getManagingOrganization().setReference(orgId.toUnqualifiedVersionless());
|
||||
ourClient.create().resource(pat).prettyPrint().encodedXml().execute().getId();
|
||||
|
||||
//@formatter:off
|
||||
|
|
|
@ -1703,12 +1703,12 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
|||
|
||||
Organization o1 = new Organization();
|
||||
o1.setName("testSearchByResourceChainName01");
|
||||
IdType o1id = (IdType) ourClient.create().resource(o1).execute().getId();
|
||||
IdType o1id = (IdType) ourClient.create().resource(o1).execute().getId().toUnqualifiedVersionless();
|
||||
|
||||
Patient p1 = new Patient();
|
||||
p1.addIdentifier().setSystem("urn:system").setValue("testSearchByResourceChain01");
|
||||
p1.addName().addFamily("testSearchByResourceChainFamily01").addGiven("testSearchByResourceChainGiven01");
|
||||
p1.setManagingOrganization(new Reference(o1id));
|
||||
p1.setManagingOrganization(new Reference(o1id.toUnqualifiedVersionless()));
|
||||
IdType p1Id = (IdType) ourClient.create().resource(p1).execute().getId();
|
||||
|
||||
//@formatter:off
|
||||
|
@ -1949,7 +1949,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
|||
|
||||
Patient pat = new Patient();
|
||||
pat.addIdentifier().setSystem("urn:system:rpdstu2").setValue("testSearchWithInclude02");
|
||||
pat.getManagingOrganization().setReferenceElement(orgId);
|
||||
pat.getManagingOrganization().setReferenceElement(orgId.toUnqualifiedVersionless());
|
||||
ourClient.create().resource(pat).prettyPrint().encodedXml().execute().getId();
|
||||
|
||||
//@formatter:off
|
||||
|
|
|
@ -19,7 +19,7 @@ public class RandomServerPortProvider {
|
|||
int port = server.getLocalPort();
|
||||
ourPorts.add(port);
|
||||
server.close();
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(2000);
|
||||
return port;
|
||||
} catch (IOException e) {
|
||||
throw new Error(e);
|
||||
|
|
Loading…
Reference in New Issue