Add failing test
This commit is contained in:
parent
281596d5f2
commit
7534ab58f3
|
@ -261,7 +261,7 @@ public class TransactionProcessor extends BaseTransactionProcessor {
|
||||||
// No matches
|
// No matches
|
||||||
.filter(match -> !match.myResolved)
|
.filter(match -> !match.myResolved)
|
||||||
.forEach(match -> {
|
.forEach(match -> {
|
||||||
ourLog.warn("Was unable to match url {} from database", match.myRequestUrl);
|
ourLog.debug("Was unable to match url {} from database", match.myRequestUrl);
|
||||||
theTransactionDetails.addResolvedMatchUrl(match.myRequestUrl, TransactionDetails.NOT_FOUND);
|
theTransactionDetails.addResolvedMatchUrl(match.myRequestUrl, TransactionDetails.NOT_FOUND);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ public class TransactionProcessor extends BaseTransactionProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSearchToResolvedAndPrefetchFoundResourcePid(TransactionDetails theTransactionDetails, List<Long> idsToPreFetch, ResourceIndexedSearchParamToken nextResult, MatchUrlToResolve nextSearchParameterMap) {
|
private void setSearchToResolvedAndPrefetchFoundResourcePid(TransactionDetails theTransactionDetails, List<Long> idsToPreFetch, ResourceIndexedSearchParamToken nextResult, MatchUrlToResolve nextSearchParameterMap) {
|
||||||
ourLog.warn("Matched url {} from database", nextSearchParameterMap.myRequestUrl);
|
ourLog.debug("Matched url {} from database", nextSearchParameterMap.myRequestUrl);
|
||||||
idsToPreFetch.add(nextResult.getResourcePid());
|
idsToPreFetch.add(nextResult.getResourcePid());
|
||||||
myMatchResourceUrlService.matchUrlResolved(theTransactionDetails, nextSearchParameterMap.myResourceDefinition.getName(), nextSearchParameterMap.myRequestUrl, new ResourcePersistentId(nextResult.getResourcePid()));
|
myMatchResourceUrlService.matchUrlResolved(theTransactionDetails, nextSearchParameterMap.myResourceDefinition.getName(), nextSearchParameterMap.myRequestUrl, new ResourcePersistentId(nextResult.getResourcePid()));
|
||||||
theTransactionDetails.addResolvedMatchUrl(nextSearchParameterMap.myRequestUrl, new ResourcePersistentId(nextResult.getResourcePid()));
|
theTransactionDetails.addResolvedMatchUrl(nextSearchParameterMap.myRequestUrl, new ResourcePersistentId(nextResult.getResourcePid()));
|
||||||
|
|
|
@ -20,6 +20,7 @@ import ca.uhn.fhir.jpa.model.entity.ResourceLink;
|
||||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||||
import ca.uhn.fhir.jpa.model.search.StorageProcessingMessage;
|
import ca.uhn.fhir.jpa.model.search.StorageProcessingMessage;
|
||||||
import ca.uhn.fhir.jpa.model.util.UcumServiceUtil;
|
import ca.uhn.fhir.jpa.model.util.UcumServiceUtil;
|
||||||
|
import ca.uhn.fhir.jpa.partition.SystemRequestDetails;
|
||||||
import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
|
import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
|
||||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap.EverythingModeEnum;
|
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap.EverythingModeEnum;
|
||||||
|
@ -150,12 +151,14 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static ca.uhn.fhir.rest.api.Constants.PARAM_TYPE;
|
import static ca.uhn.fhir.rest.api.Constants.PARAM_TYPE;
|
||||||
import static org.apache.commons.lang3.StringUtils.countMatches;
|
import static org.apache.commons.lang3.StringUtils.countMatches;
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.contains;
|
import static org.hamcrest.Matchers.contains;
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.empty;
|
import static org.hamcrest.Matchers.empty;
|
||||||
import static org.hamcrest.Matchers.endsWith;
|
import static org.hamcrest.Matchers.endsWith;
|
||||||
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.hasItem;
|
import static org.hamcrest.Matchers.hasItem;
|
||||||
import static org.hamcrest.Matchers.hasItems;
|
import static org.hamcrest.Matchers.hasItems;
|
||||||
import static org.hamcrest.Matchers.hasSize;
|
import static org.hamcrest.Matchers.hasSize;
|
||||||
|
@ -1356,6 +1359,83 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
||||||
assertThat(actual, contains(id));
|
assertThat(actual, contains(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDuplicateConditionalCreatesOnToken() {
|
||||||
|
String bundle = "{\n" +
|
||||||
|
" \"resourceType\": \"Bundle\",\n" +
|
||||||
|
" \"type\": \"transaction\",\n" +
|
||||||
|
" \"entry\": [ {\n" +
|
||||||
|
" \"fullUrl\": \"urn:uuid:33b76421-1c91-471f-ae1c-e7486e804f18\",\n" +
|
||||||
|
" \"resource\": {\n" +
|
||||||
|
" \"resourceType\": \"Organization\",\n" +
|
||||||
|
" \"identifier\": [ {\n" +
|
||||||
|
" \"system\": \"https://fhir.infoway-inforoute.ca/NamingSystem/ca-on-health-care-facility-id\",\n" +
|
||||||
|
" \"value\": \"3972\"\n" +
|
||||||
|
" } ]\n" +
|
||||||
|
" },\n" +
|
||||||
|
" \"request\": {\n" +
|
||||||
|
" \"method\": \"POST\",\n" +
|
||||||
|
" \"url\": \"/Organization\",\n" +
|
||||||
|
" \"ifNoneExist\": \"Organization?identifier=https%3A%2F%2Ffhir.infoway-inforoute.ca%2FNamingSystem%2Fca-on-health-care-facility-id|3972\"\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }, {\n" +
|
||||||
|
" \"fullUrl\": \"urn:uuid:65d2bf18-543e-4d05-b66b-07cee541172f\",\n" +
|
||||||
|
" \"resource\": {\n" +
|
||||||
|
" \"resourceType\": \"Organization\",\n" +
|
||||||
|
" \"identifier\": [ {\n" +
|
||||||
|
" \"system\": \"https://fhir.infoway-inforoute.ca/NamingSystem/ca-on-health-care-facility-id\",\n" +
|
||||||
|
" \"value\": \"3972\"\n" +
|
||||||
|
" } ]\n" +
|
||||||
|
" },\n" +
|
||||||
|
" \"request\": {\n" +
|
||||||
|
" \"method\": \"POST\",\n" +
|
||||||
|
" \"url\": \"/Organization\",\n" +
|
||||||
|
" \"ifNoneExist\": \"Organization?identifier=https%3A%2F%2Ffhir.infoway-inforoute.ca%2FNamingSystem%2Fca-on-health-care-facility-id|3972\"\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }, {\n" +
|
||||||
|
" \"fullUrl\": \"urn:uuid:2a4635e2-e678-4ed7-9a92-901d67787434\",\n" +
|
||||||
|
" \"resource\": {\n" +
|
||||||
|
" \"resourceType\": \"ServiceRequest\",\n" +
|
||||||
|
" \"identifier\": [ {\n" +
|
||||||
|
" \"system\": \"https://corhealth-ontario.ca/NamingSystem/service-request-id\",\n" +
|
||||||
|
" \"value\": \"1\"\n" +
|
||||||
|
" } ],\n" +
|
||||||
|
" \"performer\": [ {\n" +
|
||||||
|
" \"reference\": \"urn:uuid:65d2bf18-543e-4d05-b66b-07cee541172f\",\n" +
|
||||||
|
" \"type\": \"Organization\"\n" +
|
||||||
|
" } ]\n" +
|
||||||
|
" },\n" +
|
||||||
|
" \"request\": {\n" +
|
||||||
|
" \"method\": \"PUT\",\n" +
|
||||||
|
" \"url\": \"/ServiceRequest?identifier=https%3A%2F%2Fcorhealth-ontario.ca%2FNamingSystem%2Fservice-request-id|1\"\n" +
|
||||||
|
" }\n" +
|
||||||
|
" } ]\n" +
|
||||||
|
"}";
|
||||||
|
|
||||||
|
Bundle bundle1 = (Bundle) myFhirCtx.newJsonParser().parseResource(bundle);
|
||||||
|
Bundle duplicateBundle = (Bundle) myFhirCtx.newJsonParser().parseResource(bundle);
|
||||||
|
ourLog.error("TRANS 1");
|
||||||
|
Bundle bundleResponse = mySystemDao.transaction(new SystemRequestDetails(), bundle1);
|
||||||
|
bundleResponse.getEntry().stream()
|
||||||
|
.forEach( entry -> {
|
||||||
|
assertThat(entry.getResponse().getStatus(), is(equalTo("201 Created")));
|
||||||
|
});
|
||||||
|
|
||||||
|
IBundleProvider search = myOrganizationDao.search(new SearchParameterMap().setLoadSynchronous(true));
|
||||||
|
assertEquals(1, search.getAllResources().size());
|
||||||
|
|
||||||
|
//Running the bundle again should just result in 0 new resources created, as the org should already exist, and there is no update to the SR.
|
||||||
|
ourLog.error("TRANS 2");
|
||||||
|
bundleResponse= mySystemDao.transaction(new SystemRequestDetails(), duplicateBundle);
|
||||||
|
bundleResponse.getEntry().stream()
|
||||||
|
.forEach( entry -> {
|
||||||
|
assertThat(entry.getResponse().getStatus(), is(equalTo("200 OK")));
|
||||||
|
});
|
||||||
|
|
||||||
|
search = myOrganizationDao.search(new SearchParameterMap().setLoadSynchronous(true), new SystemRequestDetails());
|
||||||
|
assertEquals(1, search.getAllResources().size());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIndexNoDuplicatesToken() {
|
public void testIndexNoDuplicatesToken() {
|
||||||
Patient res = new Patient();
|
Patient res = new Patient();
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
<appender-ref ref="STDOUT" />
|
<appender-ref ref="STDOUT" />
|
||||||
</logger>
|
</logger>
|
||||||
|
|
||||||
<logger name="ca.uhn.fhir.jpa.dao" additivity="false" level="info">
|
<logger name="ca.uhn.fhir.jpa.dao" additivity="false" level="debug">
|
||||||
<appender-ref ref="STDOUT" />
|
<appender-ref ref="STDOUT" />
|
||||||
</logger>
|
</logger>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue