Add test for #438
This commit is contained in:
parent
173d40496d
commit
27208127e0
|
@ -100,7 +100,6 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void before() throws Exception {
|
||||
super.before();
|
||||
|
@ -115,6 +114,25 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
assertEquals(200, resp.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* See #438
|
||||
*/
|
||||
@Test
|
||||
public void testCreateAndUpdateBinary() {
|
||||
byte[] arr = { 23, 21, 74, 123, -44 };
|
||||
Binary binary = new Binary();
|
||||
binary.setContent(arr);
|
||||
binary.setContentType("dansk");
|
||||
binary.addUndeclaredExtension(true, "bobobo", new StringDt("hey there"));
|
||||
|
||||
|
||||
IIdType resource = ourClient.create().resource(binary).execute().getId();
|
||||
Binary fromDB = ourClient.read().resource(Binary.class).withId(resource.toVersionless()).execute();
|
||||
fromDB.setContentType("test");
|
||||
|
||||
ourClient.update().resource(fromDB).execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* See #441
|
||||
*/
|
||||
|
@ -140,8 +158,6 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testEverythingInstanceWithContentFilter() {
|
||||
Patient pt1 = new Patient();
|
||||
|
@ -183,7 +199,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
List<IIdType> actual;
|
||||
StringAndListParam param;
|
||||
|
||||
ourLog.info("Pt1:{} Pt2:{} Obs1:{} Obs2:{} Obs3:{}", new Object[] {ptId1.getIdPart(), ptId2.getIdPart(), obsId1.getIdPart(), obsId2.getIdPart(), obsId3.getIdPart()});
|
||||
ourLog.info("Pt1:{} Pt2:{} Obs1:{} Obs2:{} Obs3:{}", new Object[] { ptId1.getIdPart(), ptId2.getIdPart(), obsId1.getIdPart(), obsId2.getIdPart(), obsId3.getIdPart() });
|
||||
|
||||
param = new StringAndListParam();
|
||||
param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1")));
|
||||
|
@ -197,12 +213,11 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
actual = toUnqualifiedVersionlessIds((ca.uhn.fhir.model.dstu2.resource.Bundle)response.getParameter().get(0).getResource());
|
||||
actual = toUnqualifiedVersionlessIds((ca.uhn.fhir.model.dstu2.resource.Bundle) response.getParameter().get(0).getResource());
|
||||
assertThat(actual, containsInAnyOrder(ptId1, obsId1, devId1));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBundleCreate() throws Exception {
|
||||
IGenericClient client = ourClient;
|
||||
|
@ -231,7 +246,6 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// private void delete(String theResourceType, String theParamName, String theParamValue) {
|
||||
// Bundle resources;
|
||||
// do {
|
||||
|
@ -512,7 +526,8 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
ourLog.info(responseString);
|
||||
assertEquals(400, response.getStatusLine().getStatusCode());
|
||||
OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString);
|
||||
assertEquals("Can not create resource with ID \"2\", ID must not be supplied on a create (POST) operation (use an HTTP PUT / update operation if you wish to supply an ID)", oo.getIssue().get(0).getDiagnostics());
|
||||
assertEquals("Can not create resource with ID \"2\", ID must not be supplied on a create (POST) operation (use an HTTP PUT / update operation if you wish to supply an ID)",
|
||||
oo.getIssue().get(0).getDiagnostics());
|
||||
} finally {
|
||||
response.getEntity().getContent().close();
|
||||
response.close();
|
||||
|
@ -593,7 +608,8 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
//@formatter:on
|
||||
fail();
|
||||
} catch (PreconditionFailedException e) {
|
||||
assertEquals("HTTP 412 Precondition Failed: Failed to DELETE resource with match URL \"Patient?identifier=testDeleteConditionalMultiple\" because this search matched 2 resources", e.getMessage());
|
||||
assertEquals("HTTP 412 Precondition Failed: Failed to DELETE resource with match URL \"Patient?identifier=testDeleteConditionalMultiple\" because this search matched 2 resources",
|
||||
e.getMessage());
|
||||
}
|
||||
|
||||
// Not deleted yet..
|
||||
|
@ -833,7 +849,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
IIdType devId = ourClient.create().resource(dev).execute().getId().toUnqualifiedVersionless();
|
||||
|
||||
Location locParent = new Location();
|
||||
locParent.setName(methodName+"Parent");
|
||||
locParent.setName(methodName + "Parent");
|
||||
IIdType locPId = ourClient.create().resource(locParent).execute().getId().toUnqualifiedVersionless();
|
||||
|
||||
Location locChild = new Location();
|
||||
|
@ -897,7 +913,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
IIdType devId = ourClient.create().resource(dev).execute().getId().toUnqualifiedVersionless();
|
||||
|
||||
Location locParent = new Location();
|
||||
locParent.setName(methodName+"Parent");
|
||||
locParent.setName(methodName + "Parent");
|
||||
IIdType locPId = ourClient.create().resource(locParent).execute().getId().toUnqualifiedVersionless();
|
||||
|
||||
Location locChild = new Location();
|
||||
|
@ -1049,8 +1065,6 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testEverythingPatientOperation() throws Exception {
|
||||
String methodName = "testEverythingOperation";
|
||||
|
@ -1101,18 +1115,18 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
String methodName = "testEverythingPatientType";
|
||||
|
||||
Organization o1 = new Organization();
|
||||
o1.setName(methodName+"1");
|
||||
o1.setName(methodName + "1");
|
||||
IIdType o1Id = ourClient.create().resource(o1).execute().getId().toUnqualifiedVersionless();
|
||||
Organization o2 = new Organization();
|
||||
o2.setName(methodName+"2");
|
||||
o2.setName(methodName + "2");
|
||||
IIdType o2Id = ourClient.create().resource(o2).execute().getId().toUnqualifiedVersionless();
|
||||
|
||||
Patient p1 = new Patient();
|
||||
p1.addName().addFamily(methodName+"1");
|
||||
p1.addName().addFamily(methodName + "1");
|
||||
p1.getManagingOrganization().setReference(o1Id);
|
||||
IIdType p1Id = ourClient.create().resource(p1).execute().getId().toUnqualifiedVersionless();
|
||||
Patient p2 = new Patient();
|
||||
p2.addName().addFamily(methodName+"2");
|
||||
p2.addName().addFamily(methodName + "2");
|
||||
p2.getManagingOrganization().setReference(o2Id);
|
||||
IIdType p2Id = ourClient.create().resource(p2).execute().getId().toUnqualifiedVersionless();
|
||||
|
||||
|
@ -1124,7 +1138,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
IIdType c2Id = ourClient.create().resource(c2).execute().getId().toUnqualifiedVersionless();
|
||||
|
||||
Condition c3 = new Condition();
|
||||
c3.addIdentifier().setValue(methodName+"3");
|
||||
c3.addIdentifier().setValue(methodName + "3");
|
||||
IIdType c3Id = ourClient.create().resource(c3).execute().getId().toUnqualifiedVersionless();
|
||||
|
||||
Parameters output = ourClient.operation().onType(Patient.class).named("everything").withNoParameters(Parameters.class).execute();
|
||||
|
@ -1179,7 +1193,8 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
response.close();
|
||||
}
|
||||
|
||||
get = new HttpGet(ourServerBase + "/Patient/" + pId.getIdPart() + "/$everything?_lastUpdated=%3E" + new InstantDt(new Date(time2)).getValueAsString() + "&_lastUpdated=%3C" + new InstantDt(new Date(time3)).getValueAsString());
|
||||
get = new HttpGet(ourServerBase + "/Patient/" + pId.getIdPart() + "/$everything?_lastUpdated=%3E" + new InstantDt(new Date(time2)).getValueAsString() + "&_lastUpdated=%3C"
|
||||
+ new InstantDt(new Date(time3)).getValueAsString());
|
||||
response = ourHttpClient.execute(get);
|
||||
try {
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
|
@ -1255,7 +1270,8 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
patient.setId(id);
|
||||
ourClient.update().resource(patient).execute();
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle history = ourClient.history().onInstance(id).andReturnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class).prettyPrint().summaryMode(SummaryEnum.DATA).execute();
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle history = ourClient.history().onInstance(id).andReturnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class).prettyPrint().summaryMode(SummaryEnum.DATA)
|
||||
.execute();
|
||||
assertEquals(3, history.getEntry().size());
|
||||
assertEquals(id.withVersion("3"), history.getEntry().get(0).getResource().getId());
|
||||
assertEquals(1, ((Patient) history.getEntry().get(0).getResource()).getName().size());
|
||||
|
@ -1502,7 +1518,8 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
p1.addIdentifier().setValue("testSearchByIdentifierWithoutSystem01");
|
||||
IdDt p1Id = (IdDt) ourClient.create().resource(p1).execute().getId();
|
||||
|
||||
Bundle actual = ourClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndCode(null, "testSearchByIdentifierWithoutSystem01")).encodedJson().prettyPrint().execute();
|
||||
Bundle actual = ourClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndCode(null, "testSearchByIdentifierWithoutSystem01")).encodedJson().prettyPrint()
|
||||
.execute();
|
||||
assertEquals(1, actual.size());
|
||||
assertEquals(p1Id.getIdPart(), actual.getEntries().get(0).getResource().getId().getIdPart());
|
||||
|
||||
|
@ -2422,5 +2439,4 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue