### Question:
OverridePathBasedReferentialIntegrityForDeletesInterceptor { public void addPath(String thePath) { getPaths().add(thePath); } OverridePathBasedReferentialIntegrityForDeletesInterceptor(); void addPath(String thePath); void clearPaths(); Set<String> getPaths(); @Hook(value = Pointcut.STORAGE_PRESTORAGE_DELETE_CONFLICTS, order = CascadingDeleteInterceptor.OVERRIDE_PATH_BASED_REF_INTEGRITY_INTERCEPTOR_ORDER) void handleDeleteConflicts(DeleteConflictList theDeleteConflictList);  }### Answer:
@Test public void testAllowDelete() { mySvc.addPath("AuditEvent.agent.who"); myInterceptorRegistry.registerInterceptor(mySvc); Patient patient = new Patient(); patient.setId("P"); patient.setActive(true); myPatientDao.update(patient); AuditEvent audit = new AuditEvent(); audit.setId("A"); audit.addAgent().getWho().setReference("Patient/P"); myAuditEventDao.update(audit); myPatientDao.delete(new IdType("Patient/P")); try { myPatientDao.read(new IdType("Patient/P")); fail(); } catch (ResourceGoneException e) { } IBundleProvider searchOutcome = myAuditEventDao.search(SearchParameterMap.newSynchronous(AuditEvent.SP_AGENT, new ReferenceParam("Patient/P"))); assertEquals(1, searchOutcome.size()); }
@Test public void testWrongPath() { mySvc.addPath("AuditEvent.identifier"); mySvc.addPath("Patient.agent.who"); myInterceptorRegistry.registerInterceptor(mySvc); Patient patient = new Patient(); patient.setId("P"); patient.setActive(true); myPatientDao.update(patient); AuditEvent audit = new AuditEvent(); audit.setId("A"); audit.addAgent().getWho().setReference("Patient/P"); myAuditEventDao.update(audit); try { myPatientDao.delete(new IdType("Patient/P")); fail(); } catch (ResourceVersionConflictException e) { } }
@Test public void testCombineWithCascadeDeleteInterceptor() { try { myInterceptorRegistry.registerInterceptor(myCascadingDeleteInterceptor); mySvc.addPath("AuditEvent.agent.who"); myInterceptorRegistry.registerInterceptor(mySvc); Patient patient = new Patient(); patient.setId("P"); patient.setActive(true); myPatientDao.update(patient); AuditEvent audit = new AuditEvent(); audit.setId("A"); audit.addAgent().getWho().setReference("Patient/P"); myAuditEventDao.update(audit); myPatientDao.delete(new IdType("Patient/P")); } finally { myInterceptorRegistry.unregisterInterceptor(myCascadingDeleteInterceptor); } }