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 40a505bec362d80c4ef168875cec373729a453de..4dc12306c18b3a173b6d79671fdecdd962b73bb2 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) {