File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
src/test/java/org/ays/common/util/exception/handler Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 9
9
import org .ays .common .model .response .AysErrorResponse ;
10
10
import org .ays .common .util .exception .AysAuthException ;
11
11
import org .ays .common .util .exception .AysBadRequestException ;
12
+ import org .ays .common .util .exception .AysForbiddenException ;
12
13
import org .ays .common .util .exception .AysNotExistException ;
13
14
import org .ays .common .util .exception .AysProcessException ;
14
15
import org .junit .jupiter .api .Assertions ;
@@ -169,6 +170,33 @@ void givenHandleEndpointNotFoundException_whenThrowNoResourceFoundException_then
169
170
}
170
171
}
171
172
173
+
174
+ @ Test
175
+ void givenForbiddenException_whenThrowForbiddenException_thenReturnAysError () {
176
+
177
+ // Given
178
+ AysForbiddenException mockException = new AysForbiddenException ("Forbidden action" ) {
179
+
180
+ @ Serial
181
+ private static final long serialVersionUID = 1L ;
182
+
183
+ @ Override
184
+ public String getMessage () {
185
+ return "Forbidden action" ;
186
+ }
187
+ };
188
+
189
+ // When
190
+ AysErrorResponse mockErrorResponse = AysErrorResponse .builder ()
191
+ .header (AysErrorResponse .Header .AUTH_ERROR .getName ())
192
+ .build ();
193
+
194
+ // Then
195
+ AysErrorResponse errorResponse = globalExceptionHandler .handleForbiddenError (mockException );
196
+ this .checkAysError (mockErrorResponse , errorResponse );
197
+ }
198
+
199
+
172
200
@ Test
173
201
void givenAccessDeniedException_whenThrowAccessDeniedException_thenReturnAysError () {
174
202
You can’t perform that action at this time.
0 commit comments