reproduced failure reported by FMCNA
This commit is contained in:
parent
767a84bddb
commit
28ea97ee9a
|
@ -224,6 +224,10 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao,
|
|||
throw new MethodNotAllowedException("$expunge is not enabled on this server");
|
||||
}
|
||||
|
||||
if (theExpungeOptions.getLimit() < 1) {
|
||||
throw new InvalidRequestException("Expunge limit may not be less than 1. Received expunge limit "+theExpungeOptions.getLimit() + ".");
|
||||
}
|
||||
|
||||
AtomicInteger remainingCount = new AtomicInteger(theExpungeOptions.getLimit());
|
||||
|
||||
if (theResourceName == null && theResourceId == null && theVersion == null) {
|
||||
|
|
|
@ -49,8 +49,9 @@ public class ExpungeOptions {
|
|||
/**
|
||||
* The maximum number of resource versions to expunge
|
||||
*/
|
||||
public void setLimit(int theLimit) {
|
||||
public ExpungeOptions setLimit(int theLimit) {
|
||||
myLimit = theLimit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isExpungeEverything() {
|
||||
|
|
|
@ -4,6 +4,7 @@ import ca.uhn.fhir.jpa.dao.DaoConfig;
|
|||
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
|
||||
import ca.uhn.fhir.jpa.util.ExpungeOptions;
|
||||
import ca.uhn.fhir.jpa.util.JpaConstants;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
|
@ -290,6 +291,41 @@ public class ResourceProviderExpungeDstu3Test extends BaseResourceProviderDstu3T
|
|||
assertGone(myDeletedObservationId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpungeLimitZero() {
|
||||
try {
|
||||
myPatientDao.expunge(new ExpungeOptions()
|
||||
.setExpungeDeletedResources(true)
|
||||
.setExpungeOldVersions(true)
|
||||
.setLimit(0));
|
||||
fail();
|
||||
} catch (InvalidRequestException e) {
|
||||
assertEquals("Expunge limit may not be less than 1. Received expunge limit 0.", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpungeInstanceOldVersionsAndDeletedBoundaryLimit() {
|
||||
myPatientDao.delete(myTwoVersionPatientId);
|
||||
|
||||
myPatientDao.expunge(myTwoVersionPatientId.toUnqualifiedVersionless(), new ExpungeOptions()
|
||||
.setExpungeDeletedResources(true)
|
||||
.setExpungeOldVersions(true)
|
||||
.setLimit(2));
|
||||
|
||||
// Patients
|
||||
assertStillThere(myOneVersionPatientId);
|
||||
assertExpunged(myTwoVersionPatientId.withVersion("1"));
|
||||
assertExpunged(myTwoVersionPatientId.withVersion("2"));
|
||||
assertGone(myDeletedPatientId);
|
||||
|
||||
// No observations deleted
|
||||
assertStillThere(myOneVersionObservationId);
|
||||
assertStillThere(myTwoVersionObservationId.withVersion("1"));
|
||||
assertStillThere(myTwoVersionObservationId.withVersion("2"));
|
||||
assertGone(myDeletedObservationId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParameters() {
|
||||
Parameters p = new Parameters();
|
||||
|
|
Loading…
Reference in New Issue