From 89ff7b63f72ab527a7a705c5dc3e9b4bd24ffa96 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Mon, 28 Oct 2024 13:28:25 +0100
Subject: [PATCH] OZG-6867 Added missing unit test

---
 .../keycloak/KeycloakApiServiceTest.java      | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/test/java/de/ozgcloud/admin/keycloak/KeycloakApiServiceTest.java b/src/test/java/de/ozgcloud/admin/keycloak/KeycloakApiServiceTest.java
index ffded7ce..635351e6 100644
--- a/src/test/java/de/ozgcloud/admin/keycloak/KeycloakApiServiceTest.java
+++ b/src/test/java/de/ozgcloud/admin/keycloak/KeycloakApiServiceTest.java
@@ -3,6 +3,8 @@ package de.ozgcloud.admin.keycloak;
 import static org.assertj.core.api.Assertions.*;
 import static org.mockito.Mockito.*;
 
+import java.util.List;
+
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.Test;
@@ -26,6 +28,27 @@ class KeycloakApiServiceTest {
 	@Mock
 	private Response response;
 
+	@Nested
+	class TestGetAllGroups {
+
+		@Test
+		void shouldCallGroupsResource() {
+			service.getAllGroups();
+
+			verify(groupsResource).groups("", 0, Integer.MAX_VALUE, false);
+		}
+
+		@Test
+		void shouldReturnGroupRepresentations() {
+			var groupRepresentation = GroupRepresentationTestFactory.create();
+			when(groupsResource.groups("", 0, Integer.MAX_VALUE, false)).thenReturn(List.of(groupRepresentation));
+
+			var gotGroupRepresentations = service.getAllGroups();
+
+			assertThat(gotGroupRepresentations).containsExactly(groupRepresentation);
+		}
+	}
+
 	@Nested
 	class TestAddGroup {
 
-- 
GitLab