Untitled
unknown
plain_text
6 days ago
1.3 kB
2
Indexable
package com.santander.scib.dlx.web; import com.santander.scib.dlx.model.nativ.DlxGenericResponse; import com.santander.scib.dlx.model.nativ.DlxMessageItem; import feign.FeignException; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.ResponseEntity; import java.util.List; import static org.junit.jupiter.api.Assertions.*; @ExtendWith(MockitoExtension.class) class ExceptionControllerTest { @InjectMocks private ExceptionController exceptionController; @Test void handleDlxApiException_ShouldReturnErrorResponse() { FeignException feignException = FeignException.errorStatus("Test Exception", ResponseEntity.status(500).build()); ResponseEntity<DlxGenericResponse<FeignException>> response = exceptionController.handleDlxApiException(feignException); assertEquals(500, response.getStatusCodeValue()); assertNotNull(response.getBody()); assertNotNull(response.getBody().getErrors()); List<DlxMessageItem> errors = response.getBody().getErrors(); assertEquals(1, errors.size()); assertTrue(errors.get(0).getMessage().contains("HTTP Response Status")); } }
Editor is loading...
Leave a Comment