From dbf9c59daa480069d917a1b39606452aac518f05 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Thu, 13 Jun 2024 11:22:29 +0200 Subject: [PATCH] OZG-5400 add unittest realm update --- .../KeycloakGenericRemoteServiceTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ozgcloud-keycloak-operator/src/test/java/de/ozgcloud/operator/keycloak/KeycloakGenericRemoteServiceTest.java b/ozgcloud-keycloak-operator/src/test/java/de/ozgcloud/operator/keycloak/KeycloakGenericRemoteServiceTest.java index e6b96ee..83e2720 100644 --- a/ozgcloud-keycloak-operator/src/test/java/de/ozgcloud/operator/keycloak/KeycloakGenericRemoteServiceTest.java +++ b/ozgcloud-keycloak-operator/src/test/java/de/ozgcloud/operator/keycloak/KeycloakGenericRemoteServiceTest.java @@ -43,6 +43,7 @@ import org.keycloak.admin.client.resource.RealmsResource; import org.keycloak.admin.client.resource.RolesResource; import org.keycloak.representations.idm.ClientRepresentation; import org.keycloak.representations.idm.GroupRepresentation; +import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.representations.idm.RoleRepresentation; import org.mockito.InjectMocks; import org.mockito.Mock; @@ -81,6 +82,8 @@ class KeycloakGenericRemoteServiceTest { private RolesResource rolesResource; @Mock private RoleRepresentation roleRepresentation; + @Mock + private RealmRepresentation realmRepresentation; @Nested class TestGetKeycloakClientById { @@ -189,4 +192,19 @@ class KeycloakGenericRemoteServiceTest { () -> service.getClientRole(UserRepresentationTestFactory.ROLE1, REAL_CLIENT_ID, REALM)); } } + + @Nested + class TestGetRealmRepresentation { + + @BeforeEach + void init() { + when(keycloak.realm(REALM)).thenReturn(realmResource); + when(realmResource.toRepresentation()).thenReturn(realmRepresentation); + } + + @Test + void shouldGetClientFromKeycloak() { + assertThat(Optional.of(keycloak.realm(REALM).toRepresentation())).isNotEmpty().contains(realmRepresentation); + } + } } -- GitLab