fixed Test if maxThreads >= 2

This commit is contained in:
patrick-werner 2018-06-19 14:50:04 +02:00
parent c2b2a7eaa7
commit 627491ad95
2 changed files with 17 additions and 30 deletions

View File

@ -53,22 +53,19 @@ public class FhirResourceDaoCompositionDstu3 extends FhirResourceDaoDstu3<Compos
if (theCount != null) { if (theCount != null) {
paramMap.setCount(theCount.getValue()); paramMap.setCount(theCount.getValue());
} }
// paramMap.setRevIncludes(Collections.singleton(IResource.INCLUDE_ALL.asRecursive()));
paramMap.setIncludes(Collections.singleton(IResource.INCLUDE_ALL.asRecursive())); paramMap.setIncludes(Collections.singleton(IResource.INCLUDE_ALL.asRecursive()));
// paramMap.setEverythingMode(theId != null ? EverythingModeEnum.ENCOUNTER_INSTANCE : EverythingModeEnum.ENCOUNTER_TYPE);
paramMap.setSort(theSort); paramMap.setSort(theSort);
paramMap.setLastUpdated(theLastUpdate); paramMap.setLastUpdated(theLastUpdate);
if (theId != null) { if (theId != null) {
paramMap.add("_id", new StringParam(theId.getIdPart())); paramMap.add("_id", new StringParam(theId.getIdPart()));
} }
IBundleProvider retVal = search(paramMap); //TODO: check if the search actually only returns one Composition, otherwise throw error
List<IBaseResource> resourceList = retVal.getResources(0, retVal.size()); IBundleProvider bundleProvider = search(paramMap);
List<IBaseResource> resourceList = bundleProvider.getResources(0, bundleProvider.size());
Bundle bundle = new Bundle().setType(Bundle.BundleType.DOCUMENT); Bundle bundle = new Bundle().setType(Bundle.BundleType.DOCUMENT);
for (IBaseResource resource : resourceList) for (IBaseResource resource : resourceList)
bundle.addEntry(new Bundle.BundleEntryComponent().setResource((Resource) resource)); bundle.addEntry(new Bundle.BundleEntryComponent().setResource((Resource) resource));
return bundle; return bundle;
} }
} }

View File

@ -16,9 +16,7 @@ import org.hl7.fhir.dstu3.model.Observation.ObservationStatus;
import org.junit.*; import org.junit.*;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.*;
import java.util.Set;
import java.util.TreeSet;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -28,7 +26,7 @@ public class CompositionDocumentDstu3Test extends BaseResourceProviderDstu3Test
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CompositionDocumentDstu3Test.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CompositionDocumentDstu3Test.class);
private String orgId; private String orgId;
private String patId; private String patId;
private ArrayList<String> myObsIds; private List<String> myObsIds;
private String encId; private String encId;
private String listId; private String listId;
private String compId; private String compId;
@ -85,25 +83,23 @@ public class CompositionDocumentDstu3Test extends BaseResourceProviderDstu3Test
listId = ourClient.create().resource(listResource).execute().getId().toUnqualifiedVersionless().getValue(); listId = ourClient.create().resource(listResource).execute().getId().toUnqualifiedVersionless().getValue();
Composition composition = new Composition(); Composition composition = new Composition();
composition.setSubject(new Reference(patient)); composition.setSubject(new Reference(patId));
composition.addSection().addEntry(new Reference(patient)); composition.addSection().addEntry(new Reference(patId));
composition.addSection().addEntry(new Reference(org)); composition.addSection().addEntry(new Reference(orgId));
composition.addSection().addEntry(new Reference(enc)); composition.addSection().addEntry(new Reference(encId));
composition.addSection().addEntry(new Reference(listResource)); composition.addSection().addEntry(new Reference(listId));
composition.addSection().addEntry(new Reference(listResource));
for (Observation obs : myObs) { for (String obsId : myObsIds) {
composition.addSection().addEntry(new Reference(obs)); composition.addSection().addEntry(new Reference(obsId));
} }
compId = ourClient.create().resource(composition).execute().getId().toUnqualifiedVersionless().getValue(); compId = ourClient.create().resource(composition).execute().getId().toUnqualifiedVersionless().getValue();
} }
@Test @Test
public void testDocumentBundleReturnedCorrect() throws Exception { public void testDocumentBundleReturnedCorrect() throws Exception {
myDaoConfig.setEverythingIncludesFetchPageSize(1); // myDaoConfig.setEverythingIncludesFetchPageSize(1);
String theUrl = ourServerBase + "/" + compId + "/$document?_format=json&_count=100"; String theUrl = ourServerBase + "/" + compId + "/$document?_format=json";
System.out.println(theUrl); System.out.println(theUrl);
Bundle bundle = fetchBundle(theUrl, EncodingEnum.JSON); Bundle bundle = fetchBundle(theUrl, EncodingEnum.JSON);
@ -115,11 +111,10 @@ public class CompositionDocumentDstu3Test extends BaseResourceProviderDstu3Test
} }
ourLog.info("Found IDs: {}", actual); ourLog.info("Found IDs: {}", actual);
assertThat(actual, hasItem(patId)); assertThat(actual, hasItem(patId));
assertThat(actual, hasItem(encId));
assertThat(actual, hasItem(encId));
assertThat(actual, hasItem(orgId)); assertThat(actual, hasItem(orgId));
assertThat(actual, hasItem(encId));
assertThat(actual, hasItem(listId));
assertThat(actual, hasItems(myObsIds.toArray(new String[0]))); assertThat(actual, hasItems(myObsIds.toArray(new String[0])));
} }
@ -127,13 +122,9 @@ public class CompositionDocumentDstu3Test extends BaseResourceProviderDstu3Test
Bundle bundle; Bundle bundle;
HttpGet get = new HttpGet(theUrl); HttpGet get = new HttpGet(theUrl);
CloseableHttpResponse resp = ourHttpClient.execute(get); CloseableHttpResponse resp = ourHttpClient.execute(get);
try { try {
String test = IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8);
System.out.println(test);
assertEquals(theEncoding.getResourceContentTypeNonLegacy(), resp.getFirstHeader(ca.uhn.fhir.rest.api.Constants.HEADER_CONTENT_TYPE).getValue().replaceAll(";.*", "")); assertEquals(theEncoding.getResourceContentTypeNonLegacy(), resp.getFirstHeader(ca.uhn.fhir.rest.api.Constants.HEADER_CONTENT_TYPE).getValue().replaceAll(";.*", ""));
bundle = theEncoding.newParser(myFhirCtx).parseResource(Bundle.class, test); bundle = theEncoding.newParser(myFhirCtx).parseResource(Bundle.class, IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8));
} finally { } finally {
IOUtils.closeQuietly(resp); IOUtils.closeQuietly(resp);
} }
@ -145,5 +136,4 @@ public class CompositionDocumentDstu3Test extends BaseResourceProviderDstu3Test
public static void afterClassClearContext() { public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest(); TestUtil.clearAllStaticFieldsForUnitTest();
} }
} }