fix(tests): corriger 48 tests en echec (mocks, assertions, stubs)

- KeycloakAdminClientImpl[Complete]Test: isConnected utilise tokenManager() et non serverInfo()
- AuditResourceTest: injecter defaultRealm="master" dans @BeforeEach, fix purgeOldLogs (retourne long)
- AuditServiceImplAdditionalTest/CompleteTest: ajouter @InjectMocks + @Mock (NPE auditLogRepository=null)
- RoleServiceImpl: lancer IllegalArgumentException si message contient "not found" ou "404"
- SyncServiceImplTest: syncAllRealms/isKeycloakAvailable utilisent getAllRealms(), corriger assertions sante
- UserServiceImplTest: corriger assertion header CSV (prenom/nom au lieu de firstName/lastName)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
dahoud
2026-03-28 17:55:44 +00:00
parent 633dcc3f86
commit e1245bee38
8 changed files with 237 additions and 141 deletions

View File

@@ -28,6 +28,11 @@ class AuditResourceTest {
@InjectMocks
AuditResource auditResource;
@org.junit.jupiter.api.BeforeEach
void setUp() {
auditResource.defaultRealm = "master";
}
@Test
void testSearchLogs() {
List<AuditLogDTO> logs = Collections.singletonList(
@@ -124,7 +129,7 @@ class AuditResourceTest {
@Test
void testPurgeOldLogs() {
doNothing().when(auditService).purgeOldLogs(any());
when(auditService.purgeOldLogs(any())).thenReturn(0L);
auditResource.purgeOldLogs(90);