-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'rel_7_6' into mb-202411010-adapter
- Loading branch information
Showing
6 changed files
with
178 additions
and
3 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...n/hapi/fhir/changelog/7_6_0/6440-fix-hooks-not-called-for-precheck-for-cached-search.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
type: fix | ||
issue: 6440 | ||
title: "Previously, if an `IInterceptorBroadcaster` was set in a `RequestDetails` object, | ||
`STORAGE_PRECHECK_FOR_CACHED_SEARCH` hooks that were registered to that `IInterceptorBroadcaster` were not | ||
called. Also, if an `IInterceptorBroadcaster` was set in the `RequestDetails` object, the boolean return value of the hooks | ||
registered to that `IInterceptorBroadcaster` were not taken into account. This second issue existed for all pointcuts | ||
that returned a boolean type, not just for `STORAGE_PRECHECK_FOR_CACHED_SEARCH`. These issues have now been fixed." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
161 changes: 161 additions & 0 deletions
161
...erver/src/test/java/ca/uhn/fhir/rest/server/util/CompositeInterceptorBroadcasterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
package ca.uhn.fhir.rest.server.util; | ||
|
||
import ca.uhn.fhir.interceptor.api.HookParams; | ||
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster; | ||
import ca.uhn.fhir.interceptor.api.Pointcut; | ||
import ca.uhn.fhir.rest.api.server.RequestDetails; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.never; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class CompositeInterceptorBroadcasterTest { | ||
|
||
@Mock | ||
private IInterceptorBroadcaster myModuleBroadcasterMock; | ||
@Mock | ||
private IInterceptorBroadcaster myReqDetailsBroadcasterMock; | ||
@Mock | ||
private Pointcut myPointcutMock; | ||
@Mock | ||
private HookParams myHookParamsMock; | ||
@Mock | ||
private RequestDetails myRequestDetailsMock; | ||
|
||
|
||
@Test | ||
void doCallHooks_WhenModuleBroadcasterReturnsTrue_And_RequestDetailsBroadcasterReturnsTrue_ThenReturnsTrue() { | ||
when(myRequestDetailsMock.getInterceptorBroadcaster()).thenReturn(myReqDetailsBroadcasterMock); | ||
|
||
when(myModuleBroadcasterMock.callHooks(myPointcutMock, myHookParamsMock)).thenReturn(true); | ||
when(myReqDetailsBroadcasterMock.callHooks(myPointcutMock, myHookParamsMock)).thenReturn(true); | ||
|
||
boolean retVal = CompositeInterceptorBroadcaster.doCallHooks(myModuleBroadcasterMock, myRequestDetailsMock, | ||
myPointcutMock, myHookParamsMock); | ||
|
||
assertThat(retVal).isTrue(); | ||
|
||
verify(myModuleBroadcasterMock).callHooks(myPointcutMock, myHookParamsMock); | ||
verify(myReqDetailsBroadcasterMock).callHooks(myPointcutMock, myHookParamsMock); | ||
} | ||
|
||
@Test | ||
void doCallHooks_WhenModuleBroadcasterReturnsTrue_And_RequestDetailsBroadcasterReturnsFalse_ThenReturnsFalse() { | ||
when(myRequestDetailsMock.getInterceptorBroadcaster()).thenReturn(myReqDetailsBroadcasterMock); | ||
|
||
when(myModuleBroadcasterMock.callHooks(myPointcutMock, myHookParamsMock)).thenReturn(true); | ||
when(myReqDetailsBroadcasterMock.callHooks(myPointcutMock, myHookParamsMock)).thenReturn(false); | ||
|
||
boolean retVal = CompositeInterceptorBroadcaster.doCallHooks(myModuleBroadcasterMock, myRequestDetailsMock, | ||
myPointcutMock, myHookParamsMock); | ||
|
||
assertThat(retVal).isFalse(); | ||
|
||
verify(myModuleBroadcasterMock).callHooks(myPointcutMock, myHookParamsMock); | ||
verify(myReqDetailsBroadcasterMock).callHooks(myPointcutMock, myHookParamsMock); | ||
} | ||
|
||
@Test | ||
void doCallHooks_WhenModuleBroadcasterReturnsFalse_ThenSkipsBroadcasterInRequestDetails_And_ReturnsFalse() { | ||
when(myRequestDetailsMock.getInterceptorBroadcaster()).thenReturn(myReqDetailsBroadcasterMock); | ||
|
||
when(myModuleBroadcasterMock.callHooks(myPointcutMock, myHookParamsMock)).thenReturn(false); | ||
|
||
boolean retVal = CompositeInterceptorBroadcaster.doCallHooks(myModuleBroadcasterMock, myRequestDetailsMock, | ||
myPointcutMock, myHookParamsMock); | ||
|
||
assertThat(retVal).isFalse(); | ||
|
||
verify(myModuleBroadcasterMock).callHooks(myPointcutMock, myHookParamsMock); | ||
verify(myReqDetailsBroadcasterMock, never()).callHooks(myPointcutMock, myHookParamsMock); | ||
} | ||
|
||
@Test | ||
void doCallHooks_WhenModuleBroadcasterReturnsTrue_And_NullRequestDetailsBroadcaster_ThenReturnsTrue() { | ||
|
||
when(myModuleBroadcasterMock.callHooks(myPointcutMock, myHookParamsMock)).thenReturn(true); | ||
when(myRequestDetailsMock.getInterceptorBroadcaster()).thenReturn(null); | ||
|
||
boolean retVal = CompositeInterceptorBroadcaster.doCallHooks(myModuleBroadcasterMock, myRequestDetailsMock, myPointcutMock, | ||
myHookParamsMock); | ||
|
||
assertThat(retVal).isTrue(); | ||
|
||
verify(myModuleBroadcasterMock).callHooks(myPointcutMock, myHookParamsMock); | ||
} | ||
|
||
@Test | ||
void doCallHooks_WhenModuleBroadcasterReturnsFalse_And_NullRequestDetailsBroadcaster_ThenReturnsFalse() { | ||
|
||
when(myModuleBroadcasterMock.callHooks(myPointcutMock, myHookParamsMock)).thenReturn(false); | ||
when(myRequestDetailsMock.getInterceptorBroadcaster()).thenReturn(null); | ||
|
||
boolean retVal = CompositeInterceptorBroadcaster.doCallHooks(myModuleBroadcasterMock, myRequestDetailsMock, myPointcutMock, | ||
myHookParamsMock); | ||
|
||
assertThat(retVal).isFalse(); | ||
|
||
verify(myModuleBroadcasterMock).callHooks(myPointcutMock, myHookParamsMock); | ||
} | ||
|
||
@Test | ||
void doCallHooks_WhenModuleBroadcasterReturnsTrue_And_NullRequestDetails_ThenReturnsTrue() { | ||
|
||
when(myModuleBroadcasterMock.callHooks(myPointcutMock, myHookParamsMock)).thenReturn(true); | ||
|
||
boolean retVal = CompositeInterceptorBroadcaster.doCallHooks(myModuleBroadcasterMock, null, myPointcutMock, myHookParamsMock); | ||
|
||
assertThat(retVal).isTrue(); | ||
|
||
verify(myModuleBroadcasterMock).callHooks(myPointcutMock, myHookParamsMock); | ||
} | ||
|
||
@Test | ||
void doCallHooks_WhenModuleBroadcasterReturnsFalse_And_NullRequestDetails_ThenReturnsFalse() { | ||
|
||
when(myModuleBroadcasterMock.callHooks(myPointcutMock, myHookParamsMock)).thenReturn(false); | ||
|
||
boolean retVal = CompositeInterceptorBroadcaster.doCallHooks(myModuleBroadcasterMock, null, myPointcutMock, myHookParamsMock); | ||
|
||
assertThat(retVal).isFalse(); | ||
|
||
verify(myModuleBroadcasterMock).callHooks(myPointcutMock, myHookParamsMock); | ||
} | ||
|
||
@Test | ||
void doCallHooks_WhenNullModuleBroadcaster_And_NullRequestDetails_ThenReturnsTrue() { | ||
|
||
boolean retVal = CompositeInterceptorBroadcaster.doCallHooks(null, null, myPointcutMock, myHookParamsMock); | ||
|
||
assertThat(retVal).isTrue(); | ||
} | ||
|
||
@Test | ||
void doCallHooks_WhenNullModuleBroadcaster_And_RequestDetailsBroadcasterReturnsTrue_ThenReturnsTrue() { | ||
when(myRequestDetailsMock.getInterceptorBroadcaster()).thenReturn(myReqDetailsBroadcasterMock); | ||
when(myReqDetailsBroadcasterMock.callHooks(myPointcutMock, myHookParamsMock)).thenReturn(true); | ||
|
||
boolean retVal = CompositeInterceptorBroadcaster.doCallHooks(null, myRequestDetailsMock, myPointcutMock, myHookParamsMock); | ||
|
||
assertThat(retVal).isTrue(); | ||
verify(myReqDetailsBroadcasterMock).callHooks(myPointcutMock, myHookParamsMock); | ||
} | ||
|
||
|
||
@Test | ||
void doCallHooks_WhenNullModuleBroadcaster_And_RequestDetailsBroadcasterReturnsFalse_ThenReturnsFalse() { | ||
when(myRequestDetailsMock.getInterceptorBroadcaster()).thenReturn(myReqDetailsBroadcasterMock); | ||
when(myReqDetailsBroadcasterMock.callHooks(myPointcutMock, myHookParamsMock)).thenReturn(false); | ||
|
||
boolean retVal = CompositeInterceptorBroadcaster.doCallHooks(null, myRequestDetailsMock, myPointcutMock, myHookParamsMock); | ||
|
||
assertThat(retVal).isFalse(); | ||
verify(myReqDetailsBroadcasterMock).callHooks(myPointcutMock, myHookParamsMock); | ||
} | ||
} |