|
23 | 23 | import org.hl7.fhir.r4.model.Bundle;
|
24 | 24 | import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent;
|
25 | 25 | import org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent;
|
26 |
| -import org.hl7.fhir.r4.model.Bundle.BundleEntryResponseComponent; |
27 | 26 | import org.hl7.fhir.r4.model.Bundle.BundleLinkComponent;
|
28 | 27 | import org.hl7.fhir.r4.model.Bundle.BundleType;
|
29 | 28 | import org.hl7.fhir.r4.model.Bundle.HTTPVerb;
|
@@ -359,29 +358,50 @@ private Bundle createFailingTestBundle(BundleType type, IdType resourceToDelete)
|
359 | 358 | }
|
360 | 359 |
|
361 | 360 | @Test
|
362 |
| - public void createBundleInBundle() throws Exception |
| 361 | + public void createBundleInBundle1() throws Exception |
363 | 362 | {
|
364 |
| - StructureDefinition sd = readTestBundleProfile(); |
| 363 | + StructureDefinition sd = readTestBundleProfile("test-bundle-profile1.xml"); |
365 | 364 | getWebserviceClient().create(sd);
|
366 | 365 |
|
367 | 366 | Bundle b = new Bundle().setType(BundleType.BATCH);
|
368 | 367 | b.getMeta().addProfile(sd.getUrl() + "|" + sd.getVersion());
|
369 |
| - b.addEntry() |
370 |
| - .setResource(new Bundle().setType(BundleType.SEARCHSET) |
371 |
| - .addLink(new BundleLinkComponent().setRelation("self").setUrl("Medication")).setTotal(0)) |
372 |
| - .setResponse(new BundleEntryResponseComponent().setStatus("200")); |
| 368 | + |
| 369 | + b.addEntry().setRequest(new BundleEntryRequestComponent().setMethod(HTTPVerb.GET).setUrl("Conset")); |
| 370 | + b.addEntry().setRequest(new BundleEntryRequestComponent().setMethod(HTTPVerb.GET).setUrl("Condition")); |
| 371 | + |
373 | 372 | getReadAccessHelper().addAll(b);
|
| 373 | + Bundle created = getWebserviceClient().create(b); |
374 | 374 |
|
| 375 | + assertNotNull(created); |
| 376 | + assertNotNull(created.getIdElement()); |
| 377 | + assertNotNull(created.getIdElement().getIdPart()); |
| 378 | + } |
| 379 | + |
| 380 | + @Test |
| 381 | + public void createBundleInBundle2() throws Exception |
| 382 | + { |
| 383 | + StructureDefinition sd = readTestBundleProfile("test-bundle-profile2.xml"); |
| 384 | + getWebserviceClient().create(sd); |
| 385 | + |
| 386 | + Bundle b = new Bundle().setType(BundleType.BATCHRESPONSE); |
| 387 | + b.getMeta().addProfile(sd.getUrl() + "|" + sd.getVersion()); |
| 388 | + |
| 389 | + BundleEntryComponent e = b.addEntry(); |
| 390 | + e.setResource(new Bundle().setType(BundleType.SEARCHSET).setTotal(0) |
| 391 | + .addLink(new BundleLinkComponent().setRelation("self").setUrl("Medication"))); |
| 392 | + e.getResponse().setStatus("200"); |
| 393 | + |
| 394 | + getReadAccessHelper().addAll(b); |
375 | 395 | Bundle created = getWebserviceClient().create(b);
|
| 396 | + |
376 | 397 | assertNotNull(created);
|
377 | 398 | assertNotNull(created.getIdElement());
|
378 | 399 | assertNotNull(created.getIdElement().getIdPart());
|
379 | 400 | }
|
380 | 401 |
|
381 |
| - private StructureDefinition readTestBundleProfile() throws IOException |
| 402 | + private StructureDefinition readTestBundleProfile(String bundleFile) throws IOException |
382 | 403 | {
|
383 |
| - try (InputStream in = Files |
384 |
| - .newInputStream(Paths.get("src/test/resources/integration/bundle/test-bundle-profile.xml"))) |
| 404 | + try (InputStream in = Files.newInputStream(Paths.get("src/test/resources/integration/bundle", bundleFile))) |
385 | 405 | {
|
386 | 406 | return fhirContext.newXmlParser().parseResource(StructureDefinition.class, in);
|
387 | 407 | }
|
|
0 commit comments