|
|
|
@ -46,6 +46,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.time.Duration;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
@ -58,9 +59,6 @@ import static org.mockito.Mockito.*;
|
|
|
|
|
public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Test {
|
|
|
|
|
|
|
|
|
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderInterceptorR4Test.class);
|
|
|
|
|
private IServerOperationInterceptor myDaoInterceptor;
|
|
|
|
|
|
|
|
|
|
private IServerOperationInterceptor myServerInterceptor;
|
|
|
|
|
private List<Object> myInterceptors = new ArrayList<>();
|
|
|
|
|
@Mock
|
|
|
|
|
private IAnonymousInterceptor myHook;
|
|
|
|
@ -73,47 +71,11 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
|
|
|
|
super.after();
|
|
|
|
|
|
|
|
|
|
myDaoConfig.setSearchPreFetchThresholds(new DaoConfig().getSearchPreFetchThresholds());
|
|
|
|
|
ourRestServer.unregisterInterceptor(myServerInterceptor);
|
|
|
|
|
|
|
|
|
|
myInterceptorRegistry.unregisterInterceptors(myInterceptors);
|
|
|
|
|
myInterceptors.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void before() throws Exception {
|
|
|
|
|
super.before();
|
|
|
|
|
|
|
|
|
|
myServerInterceptor = mock(IServerOperationInterceptor.class);
|
|
|
|
|
myDaoInterceptor = mock(IServerOperationInterceptor.class);
|
|
|
|
|
|
|
|
|
|
resetServerInterceptor();
|
|
|
|
|
|
|
|
|
|
ourRestServer.registerInterceptor(myServerInterceptor);
|
|
|
|
|
|
|
|
|
|
ourRestServer.registerInterceptor(new InterceptorAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void incomingRequestPreHandled(RestOperationTypeEnum theOperation, ActionRequestDetails theProcessedRequest) {
|
|
|
|
|
super.incomingRequestPreHandled(theOperation, theProcessedRequest);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void resetServerInterceptor() throws ServletException, IOException {
|
|
|
|
|
reset(myServerInterceptor);
|
|
|
|
|
reset(myDaoInterceptor);
|
|
|
|
|
when(myServerInterceptor.handleException(any(RequestDetails.class), any(BaseServerResponseException.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
|
|
|
|
when(myServerInterceptor.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
|
|
|
|
when(myServerInterceptor.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
|
|
|
|
when(myServerInterceptor.outgoingResponse(any(RequestDetails.class))).thenReturn(true);
|
|
|
|
|
when(myServerInterceptor.outgoingResponse(any(RequestDetails.class), any(IBaseResource.class))).thenReturn(true);
|
|
|
|
|
when(myServerInterceptor.outgoingResponse(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
|
|
|
|
when(myServerInterceptor.outgoingResponse(any(RequestDetails.class), any(IBaseResource.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
|
|
|
|
when(myServerInterceptor.outgoingResponse(any(RequestDetails.class), any(ResponseDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
|
|
|
|
ourRestServer.getInterceptorService().unregisterAllInterceptors();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testPerfInterceptors() throws InterruptedException {
|
|
|
|
|
public void testPerfInterceptors() {
|
|
|
|
|
myDaoConfig.setSearchPreFetchThresholds(Lists.newArrayList(15, 100));
|
|
|
|
|
for (int i = 0; i < 30; i++) {
|
|
|
|
|
Patient p = new Patient();
|
|
|
|
@ -123,11 +85,11 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IAnonymousInterceptor interceptor = mock(IAnonymousInterceptor.class);
|
|
|
|
|
myInterceptorRegistry.registerAnonymousInterceptor(Pointcut.JPA_PERFTRACE_SEARCH_FIRST_RESULT_LOADED, interceptor);
|
|
|
|
|
myInterceptorRegistry.registerAnonymousInterceptor(Pointcut.JPA_PERFTRACE_SEARCH_COMPLETE, interceptor);
|
|
|
|
|
myInterceptorRegistry.registerAnonymousInterceptor(Pointcut.JPA_PERFTRACE_SEARCH_FAILED, interceptor);
|
|
|
|
|
myInterceptorRegistry.registerAnonymousInterceptor(Pointcut.JPA_PERFTRACE_SEARCH_PASS_COMPLETE, interceptor);
|
|
|
|
|
myInterceptorRegistry.registerAnonymousInterceptor(Pointcut.JPA_PERFTRACE_SEARCH_SELECT_COMPLETE, interceptor);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.JPA_PERFTRACE_SEARCH_FIRST_RESULT_LOADED, interceptor);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.JPA_PERFTRACE_SEARCH_COMPLETE, interceptor);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.JPA_PERFTRACE_SEARCH_FAILED, interceptor);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.JPA_PERFTRACE_SEARCH_PASS_COMPLETE, interceptor);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.JPA_PERFTRACE_SEARCH_SELECT_COMPLETE, interceptor);
|
|
|
|
|
myInterceptors.add(interceptor);
|
|
|
|
|
|
|
|
|
|
myInterceptors.add(new PerformanceTracingLoggingInterceptor());
|
|
|
|
@ -148,6 +110,7 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
|
|
|
|
// Load the next (and final) page
|
|
|
|
|
reset(interceptor);
|
|
|
|
|
results = ourClient.loadPage().next(results).execute();
|
|
|
|
|
assertNotNull(results);
|
|
|
|
|
verify(interceptor, times(1)).invoke(eq(Pointcut.JPA_PERFTRACE_SEARCH_FIRST_RESULT_LOADED), myParamsCaptor.capture());
|
|
|
|
|
verify(interceptor, times(1)).invoke(eq(Pointcut.JPA_PERFTRACE_SEARCH_SELECT_COMPLETE), myParamsCaptor.capture());
|
|
|
|
|
verify(interceptor, times(1)).invoke(eq(Pointcut.JPA_PERFTRACE_SEARCH_COMPLETE), myParamsCaptor.capture());
|
|
|
|
@ -176,7 +139,12 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
|
|
|
|
transaction(bundle);
|
|
|
|
|
|
|
|
|
|
// Do it again but with a conditional create that shouldn't actually create
|
|
|
|
|
resetServerInterceptor();
|
|
|
|
|
IAnonymousInterceptor interceptor = mock(IAnonymousInterceptor.class);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.SERVER_INCOMING_REQUEST_PRE_HANDLED, interceptor);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.SERVER_INCOMING_REQUEST_POST_PROCESSED, interceptor);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.STORAGE_PRESTORAGE_RESOURCE_CREATED, interceptor);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.STORAGE_PRESTORAGE_RESOURCE_UPDATED, interceptor);
|
|
|
|
|
|
|
|
|
|
entry.getRequest().setIfNoneExist("Patient?name=" + methodName);
|
|
|
|
|
transaction(bundle);
|
|
|
|
|
|
|
|
|
@ -184,22 +152,12 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
|
|
|
|
* Server Interceptor
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
ArgumentCaptor<ActionRequestDetails> ardCaptor = ArgumentCaptor.forClass(ActionRequestDetails.class);
|
|
|
|
|
ArgumentCaptor<RestOperationTypeEnum> opTypeCaptor = ArgumentCaptor.forClass(RestOperationTypeEnum.class);
|
|
|
|
|
verify(myServerInterceptor, times(1)).incomingRequestPreHandled(opTypeCaptor.capture(), ardCaptor.capture());
|
|
|
|
|
assertEquals(RestOperationTypeEnum.TRANSACTION, opTypeCaptor.getAllValues().get(0));
|
|
|
|
|
verify(interceptor, timeout(Duration.ofSeconds(10)).times(1)).invoke(eq(Pointcut.SERVER_INCOMING_REQUEST_PRE_HANDLED), myParamsCaptor.capture());
|
|
|
|
|
assertEquals(RestOperationTypeEnum.TRANSACTION, myParamsCaptor.getAllValues().get(0).get(RestOperationTypeEnum.class));
|
|
|
|
|
|
|
|
|
|
verify(myServerInterceptor, times(1)).incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
|
|
|
|
|
verify(myServerInterceptor, times(0)).resourceCreated(any(RequestDetails.class), any(IBaseResource.class));
|
|
|
|
|
verify(myServerInterceptor, times(0)).resourceUpdated(any(RequestDetails.class), any(IBaseResource.class), any(IBaseResource.class));
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* DAO Interceptor
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
verify(myDaoInterceptor, times(0)).incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
|
|
|
|
|
verify(myDaoInterceptor, times(0)).resourceCreated(any(RequestDetails.class), any(IBaseResource.class));
|
|
|
|
|
verify(myDaoInterceptor, times(0)).resourceUpdated(any(RequestDetails.class), any(IBaseResource.class), any(IBaseResource.class));
|
|
|
|
|
verify(interceptor, times(1)).invoke(eq(Pointcut.SERVER_INCOMING_REQUEST_POST_PROCESSED), myParamsCaptor.capture());
|
|
|
|
|
verify(interceptor, times(0)).invoke(eq(Pointcut.STORAGE_PRESTORAGE_RESOURCE_CREATED), myParamsCaptor.capture());
|
|
|
|
|
verify(interceptor, times(0)).invoke(eq(Pointcut.STORAGE_PRESTORAGE_RESOURCE_UPDATED), myParamsCaptor.capture());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -211,8 +169,8 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
|
|
|
|
pt.addName().setFamily(methodName);
|
|
|
|
|
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
|
|
|
|
|
|
|
|
|
|
verify(myServerInterceptor, times(0)).incomingRequestPreHandled(any(RestOperationTypeEnum.class), any(ActionRequestDetails.class));
|
|
|
|
|
verify(myDaoInterceptor, times(0)).incomingRequestPreHandled(any(RestOperationTypeEnum.class), any(ActionRequestDetails.class));
|
|
|
|
|
IAnonymousInterceptor interceptor = mock(IAnonymousInterceptor.class);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.SERVER_INCOMING_REQUEST_PRE_HANDLED, interceptor);
|
|
|
|
|
|
|
|
|
|
HttpPost post = new HttpPost(ourServerBase + "/Patient");
|
|
|
|
|
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
|
|
|
@ -224,12 +182,9 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
|
|
|
|
assertThat(newIdString, startsWith(ourServerBase + "/Patient/"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ArgumentCaptor<ActionRequestDetails> ardCaptor = ArgumentCaptor.forClass(ActionRequestDetails.class);
|
|
|
|
|
ArgumentCaptor<RestOperationTypeEnum> opTypeCaptor = ArgumentCaptor.forClass(RestOperationTypeEnum.class);
|
|
|
|
|
verify(myServerInterceptor, times(1)).incomingRequestPreHandled(opTypeCaptor.capture(), ardCaptor.capture());
|
|
|
|
|
assertEquals(RestOperationTypeEnum.CREATE, opTypeCaptor.getValue());
|
|
|
|
|
assertEquals("Patient", ardCaptor.getValue().getResourceType());
|
|
|
|
|
assertNotNull(ardCaptor.getValue().getResource());
|
|
|
|
|
verify(interceptor, timeout(Duration.ofSeconds(10)).times(1)).invoke(eq(Pointcut.SERVER_INCOMING_REQUEST_PRE_HANDLED), myParamsCaptor.capture());
|
|
|
|
|
assertEquals(RestOperationTypeEnum.CREATE, myParamsCaptor.getValue().get(RestOperationTypeEnum.class));
|
|
|
|
|
assertEquals("Patient", myParamsCaptor.getValue().get(RequestDetails.class).getResource().getIdElement().getResourceType());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -248,27 +203,18 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
|
|
|
|
entry.getRequest().setMethod(HTTPVerb.POST);
|
|
|
|
|
entry.getRequest().setUrl("Patient");
|
|
|
|
|
|
|
|
|
|
IAnonymousInterceptor interceptor = mock(IAnonymousInterceptor.class);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.SERVER_INCOMING_REQUEST_PRE_HANDLED, interceptor);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.SERVER_INCOMING_REQUEST_POST_PROCESSED, interceptor);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.STORAGE_PRECOMMIT_RESOURCE_CREATED, interceptor);
|
|
|
|
|
|
|
|
|
|
transaction(bundle);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Server Interceptor
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
ArgumentCaptor<ActionRequestDetails> ardCaptor = ArgumentCaptor.forClass(ActionRequestDetails.class);
|
|
|
|
|
ArgumentCaptor<RestOperationTypeEnum> opTypeCaptor = ArgumentCaptor.forClass(RestOperationTypeEnum.class);
|
|
|
|
|
verify(myServerInterceptor, times(2)).incomingRequestPreHandled(opTypeCaptor.capture(), ardCaptor.capture());
|
|
|
|
|
assertEquals(RestOperationTypeEnum.TRANSACTION, opTypeCaptor.getAllValues().get(0));
|
|
|
|
|
assertEquals(null, ardCaptor.getAllValues().get(0).getResourceType());
|
|
|
|
|
assertNotNull(ardCaptor.getAllValues().get(0).getResource());
|
|
|
|
|
assertEquals(RestOperationTypeEnum.CREATE, opTypeCaptor.getAllValues().get(1));
|
|
|
|
|
assertEquals("Patient", ardCaptor.getAllValues().get(1).getResourceType());
|
|
|
|
|
assertNotNull(ardCaptor.getAllValues().get(1).getResource());
|
|
|
|
|
|
|
|
|
|
ArgumentCaptor<RequestDetails> rdCaptor = ArgumentCaptor.forClass(RequestDetails.class);
|
|
|
|
|
ArgumentCaptor<HttpServletRequest> srCaptor = ArgumentCaptor.forClass(HttpServletRequest.class);
|
|
|
|
|
ArgumentCaptor<HttpServletResponse> sRespCaptor = ArgumentCaptor.forClass(HttpServletResponse.class);
|
|
|
|
|
verify(myServerInterceptor, times(1)).incomingRequestPostProcessed(rdCaptor.capture(), srCaptor.capture(), sRespCaptor.capture());
|
|
|
|
|
verify(interceptor, timeout(Duration.ofSeconds(10)).times(2)).invoke(eq(Pointcut.SERVER_INCOMING_REQUEST_PRE_HANDLED), myParamsCaptor.capture());
|
|
|
|
|
assertEquals(RestOperationTypeEnum.CREATE, myParamsCaptor.getValue().get(RestOperationTypeEnum.class));
|
|
|
|
|
verify(interceptor, timeout(Duration.ofSeconds(10)).times(1)).invoke(eq(Pointcut.SERVER_INCOMING_REQUEST_POST_PROCESSED), myParamsCaptor.capture());
|
|
|
|
|
|
|
|
|
|
verify(interceptor, timeout(Duration.ofSeconds(10)).times(1)).invoke(eq(Pointcut.STORAGE_PRECOMMIT_RESOURCE_CREATED), myParamsCaptor.capture());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -306,8 +252,6 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
|
|
|
|
IIdType orgId = ourClient.create().resource(org).execute().getId().toUnqualified();
|
|
|
|
|
assertNotNull(orgId.getVersionIdPartAsLong());
|
|
|
|
|
|
|
|
|
|
resetServerInterceptor();
|
|
|
|
|
|
|
|
|
|
Patient pt = new Patient();
|
|
|
|
|
pt.addName().setFamily(methodName);
|
|
|
|
|
pt.setManagingOrganization(new Reference(orgId));
|
|
|
|
@ -319,8 +263,8 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
|
|
|
|
|
|
|
|
|
ourLog.info(resource);
|
|
|
|
|
|
|
|
|
|
verify(myServerInterceptor, times(0)).incomingRequestPreHandled(any(RestOperationTypeEnum.class), any(ActionRequestDetails.class));
|
|
|
|
|
verify(myDaoInterceptor, times(0)).incomingRequestPreHandled(any(RestOperationTypeEnum.class), any(ActionRequestDetails.class));
|
|
|
|
|
IAnonymousInterceptor interceptor = mock(IAnonymousInterceptor.class);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.SERVER_INCOMING_REQUEST_PRE_HANDLED, interceptor);
|
|
|
|
|
|
|
|
|
|
HttpPost post = new HttpPost(ourServerBase + "/Patient");
|
|
|
|
|
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
|
|
|
@ -332,16 +276,10 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
|
|
|
|
assertThat(newIdString, startsWith(ourServerBase + "/Patient/"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ArgumentCaptor<ActionRequestDetails> ardCaptor = ArgumentCaptor.forClass(ActionRequestDetails.class);
|
|
|
|
|
ArgumentCaptor<RestOperationTypeEnum> opTypeCaptor = ArgumentCaptor.forClass(RestOperationTypeEnum.class);
|
|
|
|
|
verify(myServerInterceptor, times(1)).incomingRequestPreHandled(opTypeCaptor.capture(), ardCaptor.capture());
|
|
|
|
|
verify(interceptor, timeout(Duration.ofSeconds(10)).times(1)).invoke(eq(Pointcut.SERVER_INCOMING_REQUEST_PRE_HANDLED), myParamsCaptor.capture());
|
|
|
|
|
assertEquals(RestOperationTypeEnum.CREATE, myParamsCaptor.getValue().get(RestOperationTypeEnum.class));
|
|
|
|
|
|
|
|
|
|
assertEquals(RestOperationTypeEnum.CREATE, opTypeCaptor.getValue());
|
|
|
|
|
assertEquals("Patient", ardCaptor.getValue().getResourceType());
|
|
|
|
|
assertNotNull(ardCaptor.getValue().getResource());
|
|
|
|
|
|
|
|
|
|
Patient patient;
|
|
|
|
|
patient = (Patient) ardCaptor.getAllValues().get(0).getResource();
|
|
|
|
|
Patient patient = (Patient) myParamsCaptor.getValue().get(RequestDetails.class).getResource();
|
|
|
|
|
assertEquals(orgId.getValue(), patient.getManagingOrganization().getReference());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -366,31 +304,19 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
|
|
|
|
transaction(bundle);
|
|
|
|
|
|
|
|
|
|
// Do it again but with an update that shouldn't actually create
|
|
|
|
|
resetServerInterceptor();
|
|
|
|
|
IAnonymousInterceptor interceptor = mock(IAnonymousInterceptor.class);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.SERVER_INCOMING_REQUEST_PRE_HANDLED, interceptor);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.STORAGE_PRECOMMIT_RESOURCE_CREATED, interceptor);
|
|
|
|
|
ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.STORAGE_PRECOMMIT_RESOURCE_UPDATED, interceptor);
|
|
|
|
|
|
|
|
|
|
entry.getRequest().setIfNoneExist("Patient?name=" + methodName);
|
|
|
|
|
transaction(bundle);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Server Interceptor
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
ArgumentCaptor<ActionRequestDetails> ardCaptor = ArgumentCaptor.forClass(ActionRequestDetails.class);
|
|
|
|
|
ArgumentCaptor<RestOperationTypeEnum> opTypeCaptor = ArgumentCaptor.forClass(RestOperationTypeEnum.class);
|
|
|
|
|
verify(myServerInterceptor, times(2)).incomingRequestPreHandled(opTypeCaptor.capture(), ardCaptor.capture());
|
|
|
|
|
assertEquals(RestOperationTypeEnum.TRANSACTION, opTypeCaptor.getAllValues().get(0));
|
|
|
|
|
assertEquals(RestOperationTypeEnum.UPDATE, opTypeCaptor.getAllValues().get(1));
|
|
|
|
|
|
|
|
|
|
verify(myServerInterceptor, times(1)).incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
|
|
|
|
|
verify(myServerInterceptor, times(0)).resourceCreated(any(RequestDetails.class), any(IBaseResource.class));
|
|
|
|
|
verify(myServerInterceptor, times(0)).resourceUpdated(any(RequestDetails.class), any(IBaseResource.class), any(IBaseResource.class));
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* DAO Interceptor
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
verify(myDaoInterceptor, times(0)).incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
|
|
|
|
|
verify(myDaoInterceptor, times(0)).resourceCreated(any(RequestDetails.class), any(IBaseResource.class));
|
|
|
|
|
verify(myDaoInterceptor, times(0)).resourceUpdated(any(RequestDetails.class), any(IBaseResource.class), any(IBaseResource.class));
|
|
|
|
|
verify(interceptor, timeout(Duration.ofSeconds(10)).times(2)).invoke(eq(Pointcut.SERVER_INCOMING_REQUEST_PRE_HANDLED), myParamsCaptor.capture());
|
|
|
|
|
assertEquals(RestOperationTypeEnum.TRANSACTION, myParamsCaptor.getAllValues().get(0).get(RestOperationTypeEnum.class));
|
|
|
|
|
assertEquals(RestOperationTypeEnum.UPDATE, myParamsCaptor.getAllValues().get(1).get(RestOperationTypeEnum.class));
|
|
|
|
|
verify(interceptor, times(0)).invoke(eq(Pointcut.STORAGE_PRECOMMIT_RESOURCE_CREATED), any());
|
|
|
|
|
verify(interceptor, times(0)).invoke(eq(Pointcut.STORAGE_PRECOMMIT_RESOURCE_UPDATED), any());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|