This commit is contained in:
jamesagnew 2018-01-08 08:20:39 -05:00
parent 7e2459fbdc
commit 19c6369175
1 changed files with 46 additions and 32 deletions

View File

@ -192,6 +192,7 @@ public class FhirResourceDaoDstu3InterceptorTest extends BaseJpaDstu3Test {
IIdType id = myPatientDao.create(p, mySrd).getId(); IIdType id = myPatientDao.create(p, mySrd).getId();
assertEquals(1L, id.getVersionIdPartAsLong().longValue()); assertEquals(1L, id.getVersionIdPartAsLong().longValue());
verify(myRequestOperationCallback, times(1)).resourcePreCreate(any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourceCreated(any(IBaseResource.class)); verify(myRequestOperationCallback, times(1)).resourceCreated(any(IBaseResource.class));
verifyNoMoreInteractions(myRequestOperationCallback); verifyNoMoreInteractions(myRequestOperationCallback);
} }
@ -263,7 +264,9 @@ public class FhirResourceDaoDstu3InterceptorTest extends BaseJpaDstu3Test {
IIdType newId = myPatientDao.delete(new IdType("Patient/" + id), mySrd).getId(); IIdType newId = myPatientDao.delete(new IdType("Patient/" + id), mySrd).getId();
assertEquals(2L, newId.getVersionIdPartAsLong().longValue()); assertEquals(2L, newId.getVersionIdPartAsLong().longValue());
verify(myRequestOperationCallback, times(1)).resourcePreDelete(any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourceDeleted(any(IBaseResource.class)); verify(myRequestOperationCallback, times(1)).resourceDeleted(any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourcePreCreate(any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourceCreated(any(IBaseResource.class)); verify(myRequestOperationCallback, times(1)).resourceCreated(any(IBaseResource.class));
verifyNoMoreInteractions(myRequestOperationCallback); verifyNoMoreInteractions(myRequestOperationCallback);
} }
@ -294,7 +297,9 @@ public class FhirResourceDaoDstu3InterceptorTest extends BaseJpaDstu3Test {
ourLog.info(oo); ourLog.info(oo);
assertThat(oo, containsString("deleted 2 resource(s)")); assertThat(oo, containsString("deleted 2 resource(s)"));
verify(myRequestOperationCallback, times(2)).resourcePreDelete(any(IBaseResource.class));
verify(myRequestOperationCallback, times(2)).resourceDeleted(any(IBaseResource.class)); verify(myRequestOperationCallback, times(2)).resourceDeleted(any(IBaseResource.class));
verify(myRequestOperationCallback, times(2)).resourcePreCreate(any(IBaseResource.class));
verify(myRequestOperationCallback, times(2)).resourceCreated(any(IBaseResource.class)); verify(myRequestOperationCallback, times(2)).resourceCreated(any(IBaseResource.class));
verifyNoMoreInteractions(myRequestOperationCallback); verifyNoMoreInteractions(myRequestOperationCallback);
} }
@ -316,16 +321,17 @@ public class FhirResourceDaoDstu3InterceptorTest extends BaseJpaDstu3Test {
Bundle xactBundle = new Bundle(); Bundle xactBundle = new Bundle();
xactBundle.setType(BundleType.TRANSACTION); xactBundle.setType(BundleType.TRANSACTION);
xactBundle xactBundle
.addEntry() .addEntry()
.setResource(p) .setResource(p)
.getRequest() .getRequest()
.setUrl("Patient") .setUrl("Patient")
.setMethod(HTTPVerb.POST); .setMethod(HTTPVerb.POST);
Bundle resp = mySystemDao.transaction(mySrd, xactBundle); Bundle resp = mySystemDao.transaction(mySrd, xactBundle);
IdType newId = new IdType(resp.getEntry().get(0).getResponse().getLocation()); IdType newId = new IdType(resp.getEntry().get(0).getResponse().getLocation());
assertEquals(1L, newId.getVersionIdPartAsLong().longValue()); assertEquals(1L, newId.getVersionIdPartAsLong().longValue());
verify(myRequestOperationCallback, times(1)).resourcePreCreate(any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourceCreated(any(IBaseResource.class)); verify(myRequestOperationCallback, times(1)).resourceCreated(any(IBaseResource.class));
verifyNoMoreInteractions(myRequestOperationCallback); verifyNoMoreInteractions(myRequestOperationCallback);
} }
@ -348,16 +354,18 @@ public class FhirResourceDaoDstu3InterceptorTest extends BaseJpaDstu3Test {
Bundle xactBundle = new Bundle(); Bundle xactBundle = new Bundle();
xactBundle.setType(BundleType.TRANSACTION); xactBundle.setType(BundleType.TRANSACTION);
xactBundle xactBundle
.addEntry() .addEntry()
.getRequest() .getRequest()
.setUrl("Patient/" + id) .setUrl("Patient/" + id)
.setMethod(HTTPVerb.DELETE); .setMethod(HTTPVerb.DELETE);
Bundle resp = mySystemDao.transaction(mySrd, xactBundle); Bundle resp = mySystemDao.transaction(mySrd, xactBundle);
IdType newId = new IdType(resp.getEntry().get(0).getResponse().getLocation()); IdType newId = new IdType(resp.getEntry().get(0).getResponse().getLocation());
assertEquals(2L, newId.getVersionIdPartAsLong().longValue()); assertEquals(2L, newId.getVersionIdPartAsLong().longValue());
verify(myRequestOperationCallback, times(1)).resourcePreDelete(any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourceDeleted(any(IBaseResource.class)); verify(myRequestOperationCallback, times(1)).resourceDeleted(any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourcePreCreate(any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourceCreated(any(IBaseResource.class)); verify(myRequestOperationCallback, times(1)).resourceCreated(any(IBaseResource.class));
verifyNoMoreInteractions(myRequestOperationCallback); verifyNoMoreInteractions(myRequestOperationCallback);
} }
@ -386,17 +394,19 @@ public class FhirResourceDaoDstu3InterceptorTest extends BaseJpaDstu3Test {
Bundle xactBundle = new Bundle(); Bundle xactBundle = new Bundle();
xactBundle.setType(BundleType.TRANSACTION); xactBundle.setType(BundleType.TRANSACTION);
xactBundle xactBundle
.addEntry() .addEntry()
.getRequest() .getRequest()
.setUrl("Patient?name=PATIENT") .setUrl("Patient?name=PATIENT")
.setMethod(HTTPVerb.DELETE); .setMethod(HTTPVerb.DELETE);
Bundle resp = mySystemDao.transaction(mySrd, xactBundle); Bundle resp = mySystemDao.transaction(mySrd, xactBundle);
String oo = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp); String oo = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp);
ourLog.info(oo); ourLog.info(oo);
assertThat(oo, containsString("deleted 2 resource(s)")); assertThat(oo, containsString("deleted 2 resource(s)"));
verify(myRequestOperationCallback, times(2)).resourcePreDelete(any(IBaseResource.class));
verify(myRequestOperationCallback, times(2)).resourceDeleted(any(IBaseResource.class)); verify(myRequestOperationCallback, times(2)).resourceDeleted(any(IBaseResource.class));
verify(myRequestOperationCallback, times(2)).resourcePreCreate(any(IBaseResource.class));
verify(myRequestOperationCallback, times(2)).resourceCreated(any(IBaseResource.class)); verify(myRequestOperationCallback, times(2)).resourceCreated(any(IBaseResource.class));
verifyNoMoreInteractions(myRequestOperationCallback); verifyNoMoreInteractions(myRequestOperationCallback);
} }
@ -422,18 +432,20 @@ public class FhirResourceDaoDstu3InterceptorTest extends BaseJpaDstu3Test {
Bundle xactBundle = new Bundle(); Bundle xactBundle = new Bundle();
xactBundle.setType(BundleType.TRANSACTION); xactBundle.setType(BundleType.TRANSACTION);
xactBundle xactBundle
.addEntry() .addEntry()
.setResource(p) .setResource(p)
.getRequest() .getRequest()
.setUrl("Patient/" + id) .setUrl("Patient/" + id)
.setMethod(HTTPVerb.PUT); .setMethod(HTTPVerb.PUT);
Bundle resp = mySystemDao.transaction(mySrd, xactBundle); Bundle resp = mySystemDao.transaction(mySrd, xactBundle);
IdType newId = new IdType(resp.getEntry().get(0).getResponse().getLocation()); IdType newId = new IdType(resp.getEntry().get(0).getResponse().getLocation());
assertEquals(2L, newId.getVersionIdPartAsLong().longValue()); assertEquals(2L, newId.getVersionIdPartAsLong().longValue());
verify(myRequestOperationCallback, times(1)).resourceUpdated(any(IBaseResource.class)); verify(myRequestOperationCallback, times(1)).resourceUpdated(any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourcePreUpdate(any(IBaseResource.class), any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourceUpdated(any(IBaseResource.class), any(IBaseResource.class)); verify(myRequestOperationCallback, times(1)).resourceUpdated(any(IBaseResource.class), any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourcePreCreate(any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourceCreated(any(IBaseResource.class)); verify(myRequestOperationCallback, times(1)).resourceCreated(any(IBaseResource.class));
verifyNoMoreInteractions(myRequestOperationCallback); verifyNoMoreInteractions(myRequestOperationCallback);
} }
@ -461,7 +473,9 @@ public class FhirResourceDaoDstu3InterceptorTest extends BaseJpaDstu3Test {
assertEquals(2L, newId.getVersionIdPartAsLong().longValue()); assertEquals(2L, newId.getVersionIdPartAsLong().longValue());
verify(myRequestOperationCallback, times(1)).resourceUpdated(any(IBaseResource.class)); verify(myRequestOperationCallback, times(1)).resourceUpdated(any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourcePreUpdate(any(IBaseResource.class), any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourceUpdated(any(IBaseResource.class), any(IBaseResource.class)); verify(myRequestOperationCallback, times(1)).resourceUpdated(any(IBaseResource.class), any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourcePreCreate(any(IBaseResource.class));
verify(myRequestOperationCallback, times(1)).resourceCreated(any(IBaseResource.class)); verify(myRequestOperationCallback, times(1)).resourceCreated(any(IBaseResource.class));
verifyNoMoreInteractions(myRequestOperationCallback); verifyNoMoreInteractions(myRequestOperationCallback);
} }