From 23ac1813bf12a5cb2fa0ffc37a6480af6b594703 Mon Sep 17 00:00:00 2001 From: K4sik Date: Tue, 1 Oct 2024 13:15:15 +0300 Subject: [PATCH] Added test case for IllegalArgumentException --- .../exception/handler/CustomExceptionHandlerTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/src/test/java/greencity/exception/handler/CustomExceptionHandlerTest.java b/core/src/test/java/greencity/exception/handler/CustomExceptionHandlerTest.java index 34576c564..41ce9fdda 100644 --- a/core/src/test/java/greencity/exception/handler/CustomExceptionHandlerTest.java +++ b/core/src/test/java/greencity/exception/handler/CustomExceptionHandlerTest.java @@ -139,6 +139,16 @@ void testHandleBadRefreshTokenException() { ResponseEntity.status(HttpStatus.BAD_REQUEST).body(exceptionResponse)); } + @Test + void testHandleIllegalTokenException() { + IllegalArgumentException illegalArgumentException = new IllegalArgumentException("test"); + ExceptionResponse exceptionResponse = new ExceptionResponse(objectMap); + when(errorAttributes.getErrorAttributes(eq(webRequest), + any(ErrorAttributeOptions.class))).thenReturn(objectMap); + assertEquals(customExceptionHandler.handleIllegalArgumentException(illegalArgumentException, webRequest), + ResponseEntity.status(HttpStatus.BAD_REQUEST).body(exceptionResponse)); + } + @Test void handleBadRequestException() { BadRequestException badRequestException = new BadRequestException("test");