From ec928ce7c853072fb89d86a012d60ce4444829b5 Mon Sep 17 00:00:00 2001 From: Lukas Malte Monnerjahn <lukasmalte.monnerjahn@dataport.de> Date: Wed, 16 Oct 2024 11:27:07 +0200 Subject: [PATCH] OZG-6897 clean up test --- .../ozgcloud/user/UserResourceMapperTest.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/user-manager-server/src/test/java/de/ozgcloud/user/UserResourceMapperTest.java b/user-manager-server/src/test/java/de/ozgcloud/user/UserResourceMapperTest.java index 40a505be..4dc12306 100644 --- a/user-manager-server/src/test/java/de/ozgcloud/user/UserResourceMapperTest.java +++ b/user-manager-server/src/test/java/de/ozgcloud/user/UserResourceMapperTest.java @@ -29,6 +29,7 @@ import static org.mockito.Mockito.*; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -66,7 +67,7 @@ class UserResourceMapperTest { @Mock RealmResource realm; - private UserResource userResource; + final Set<String> organisationsEinheitIds = Set.of(ORGANISATIONS_EINHEIT_ID_1); @DisplayName("To kop user") @Nested @@ -75,15 +76,8 @@ class UserResourceMapperTest { @BeforeEach void init() { when(properties.ldapIdKey()).thenReturn("LDAP_ID"); - when(properties.organisationsEinheitIdKey()).thenReturn("organisationseinheitId"); when(properties.client()).thenReturn("alfa"); - when(realm.getGroupByPath(GROUP_1_PATH)) - .thenReturn(GroupRepresentationTestFactory.createByPathAndOrganisationEinheitIds(GROUP_1_PATH, ORGANISATIONS_EINHEIT_ID_1)); - when(properties.ldapIdKey()).thenReturn("LDAP_ID"); - when(properties.organisationsEinheitIdKey()).thenReturn("organisationseinheitId"); - when(properties.client()).thenReturn("alfa"); - - userResource = UserResourceTestFactory.create(); + doReturn(organisationsEinheitIds).when(mapper).mapOrganisationsEinheitIds(any()); } @Test @@ -142,9 +136,9 @@ class UserResourceMapperTest { @Test void shouldMapOrganisationsEinheitIds() { - toKopUser(); + var result = toKopUser(); - verify(mapper).mapOrganisationsEinheitIds(userResource); + assertThat(result.getOrganisationsEinheitIds()).hasSameElementsAs(organisationsEinheitIds); } @Test @@ -176,7 +170,7 @@ class UserResourceMapperTest { } private User toKopUser() { - return toKopUser(userResource); + return toKopUser(UserResourceTestFactory.create()); } private User toKopUser(UserResource userResource) { -- GitLab