feat(server-impl): refactoring resources JAX-RS, corrections AuditService/SyncService/UserService, ajout entites Sync et scripts Docker
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -40,18 +40,20 @@ class KeycloakAdminClientImplTest {
|
||||
@Mock
|
||||
ServerInfoResource serverInfoResource;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
// Inject the mock keycloak instance
|
||||
setField(client, "keycloak", keycloak);
|
||||
}
|
||||
|
||||
private void setField(Object target, String fieldName, Object value) throws Exception {
|
||||
Field field = target.getClass().getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
field.set(target, value);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
setField(client, "serverUrl", "http://localhost:8180");
|
||||
setField(client, "adminRealm", "master");
|
||||
setField(client, "adminClientId", "admin-cli");
|
||||
setField(client, "adminUsername", "admin");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetInstance() {
|
||||
Keycloak result = client.getInstance();
|
||||
@@ -59,18 +61,6 @@ class KeycloakAdminClientImplTest {
|
||||
assertEquals(keycloak, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetInstanceReInitWhenNull() throws Exception {
|
||||
// Set keycloak to null
|
||||
setField(client, "keycloak", null);
|
||||
|
||||
// Should attempt to reinitialize (will fail without config, but that's ok)
|
||||
// The method should return null since init() will fail without proper config
|
||||
Keycloak result = client.getInstance();
|
||||
// Since config values are null, keycloak will still be null
|
||||
assertNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetRealm() {
|
||||
when(keycloak.realm("test-realm")).thenReturn(realmResource);
|
||||
@@ -125,13 +115,6 @@ class KeycloakAdminClientImplTest {
|
||||
assertFalse(client.isConnected());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsConnected_false_null() throws Exception {
|
||||
setField(client, "keycloak", null);
|
||||
|
||||
assertFalse(client.isConnected());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRealmExists_true() {
|
||||
when(keycloak.realm("test-realm")).thenReturn(realmResource);
|
||||
@@ -156,22 +139,16 @@ class KeycloakAdminClientImplTest {
|
||||
when(realmResource.roles()).thenReturn(rolesResource);
|
||||
when(rolesResource.list()).thenThrow(new RuntimeException("Some other error"));
|
||||
|
||||
// Should return true assuming realm exists but has issues
|
||||
assertTrue(client.realmExists("problem-realm"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClose() {
|
||||
client.close();
|
||||
|
||||
verify(keycloak).close();
|
||||
assertDoesNotThrow(() -> client.close());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCloseWhenNull() throws Exception {
|
||||
setField(client, "keycloak", null);
|
||||
|
||||
// Should not throw
|
||||
client.close();
|
||||
void testReconnect() {
|
||||
assertDoesNotThrow(() -> client.reconnect());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user