fixed delete reference error message
This commit is contained in:
parent
5dfacab1df
commit
10f7eb31eb
|
@ -1294,7 +1294,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao,
|
|||
b.append("Unable to delete ");
|
||||
b.append(next.getTargetId().toUnqualifiedVersionless().getValue());
|
||||
b.append(" because at least one resource has a reference to this resource. First reference found was resource ");
|
||||
b.append(next.getTargetId().toUnqualifiedVersionless().getValue());
|
||||
b.append(next.getSourceId().toUnqualifiedVersionless().getValue());
|
||||
b.append(" in path ");
|
||||
b.append(next.getSourcePath());
|
||||
String msg = b.toString();
|
||||
|
|
|
@ -5,8 +5,8 @@ import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao;
|
|||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
|
||||
import ca.uhn.fhir.jpa.entity.Search;
|
||||
import ca.uhn.fhir.jpa.model.search.SearchStatusEnum;
|
||||
import ca.uhn.fhir.jpa.model.entity.*;
|
||||
import ca.uhn.fhir.jpa.model.search.SearchStatusEnum;
|
||||
import ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParamConstants;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
|
@ -16,11 +16,12 @@ import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
|||
import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntryTransactionMethodEnum;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.SortOrderEnum;
|
||||
import ca.uhn.fhir.rest.api.SortSpec;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.param.*;
|
||||
import ca.uhn.fhir.rest.server.exceptions.*;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -43,7 +44,6 @@ import org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity;
|
|||
import org.hl7.fhir.r4.model.OperationOutcome.IssueType;
|
||||
import org.hl7.fhir.r4.model.Quantity.QuantityComparator;
|
||||
import org.junit.*;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
|
||||
|
@ -57,11 +57,9 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.Future;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.Mockito.reset;
|
||||
|
||||
@SuppressWarnings({"unchecked", "deprecation", "Duplicates"})
|
||||
public class FhirResourceDaoR4Test extends BaseJpaR4Test {
|
||||
|
@ -1196,7 +1194,8 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test {
|
|||
myOrganizationDao.delete(orgId, mySrd);
|
||||
fail();
|
||||
} catch (ResourceVersionConflictException e) {
|
||||
assertConflictException(e);
|
||||
assertConflictException("Patient", e);
|
||||
ourLog.info("Expected exception thrown: " + e.getMessage());
|
||||
}
|
||||
|
||||
myPatientDao.delete(patId, mySrd);
|
||||
|
@ -1402,7 +1401,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test {
|
|||
myObservationDao.deleteByUrl("Observation?_has:DiagnosticReport:result:identifier=foo|IDENTIFIER", mySrd);
|
||||
fail();
|
||||
} catch (ResourceVersionConflictException e) {
|
||||
assertConflictException(e);
|
||||
assertConflictException("DiagnosticReport", e);
|
||||
}
|
||||
|
||||
myObservationDao.read(obs1id);
|
||||
|
@ -3874,9 +3873,10 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test {
|
|||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
public static void assertConflictException(ResourceVersionConflictException e) {
|
||||
public static void assertConflictException(String theResourceType, ResourceVersionConflictException e) {
|
||||
assertThat(e.getMessage(), matchesPattern(
|
||||
"Unable to delete [a-zA-Z]+/[0-9]+ because at least one resource has a reference to this resource. First reference found was resource [a-zA-Z]+/[0-9]+ in path [a-zA-Z]+.[a-zA-Z]+"));
|
||||
"Unable to delete [a-zA-Z]+/[0-9]+ because at least one resource has a reference to this resource. First reference found was resource " + theResourceType + "/[0-9]+ in path [a-zA-Z]+.[a-zA-Z]+"));
|
||||
|
||||
}
|
||||
|
||||
private static List<String> toStringList(List<CanonicalType> theUriType) {
|
||||
|
|
Loading…
Reference in New Issue