From cdf67a7b1b1e270a3327765748f19f316289aa99 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Sat, 28 Sep 2024 16:04:17 +0200
Subject: [PATCH] OZG-6523 implement comments from code review

---
 .../vorgang/CollaborationServiceKontoMapper.java     |  3 +--
 .../CollaborationEventListenerTest.java              |  9 ++++-----
 .../collaboration/CollaborationServiceITCase.java    | 12 ++++++------
 .../vorgang/PostfachAddressTestFactory.java          |  7 +++----
 .../vorgang/ServiceKontoTestFactory.java             |  3 +--
 5 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/collaboration-manager-server/src/main/java/de/ozgcloud/collaboration/vorgang/CollaborationServiceKontoMapper.java b/collaboration-manager-server/src/main/java/de/ozgcloud/collaboration/vorgang/CollaborationServiceKontoMapper.java
index 2f9004e..33a3509 100644
--- a/collaboration-manager-server/src/main/java/de/ozgcloud/collaboration/vorgang/CollaborationServiceKontoMapper.java
+++ b/collaboration-manager-server/src/main/java/de/ozgcloud/collaboration/vorgang/CollaborationServiceKontoMapper.java
@@ -29,7 +29,6 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.stream.Collectors;
 
-import org.apache.commons.lang3.StringUtils;
 import org.mapstruct.CollectionMappingStrategy;
 import org.mapstruct.Mapper;
 import org.mapstruct.Mapping;
@@ -89,6 +88,6 @@ public interface CollaborationServiceKontoMapper {
 	GrpcServiceKonto toServiceKonto(ServiceKonto serviceKonto);
 
 	default String toString(TrustLevel trustLevel) {
-		return Objects.isNull(trustLevel) ? StringUtils.EMPTY : trustLevel.getValue();
+		return trustLevel.getValue();
 	}
 }
\ No newline at end of file
diff --git a/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/CollaborationEventListenerTest.java b/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/CollaborationEventListenerTest.java
index c824865..36cb45c 100644
--- a/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/CollaborationEventListenerTest.java
+++ b/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/CollaborationEventListenerTest.java
@@ -88,14 +88,12 @@ class CollaborationEventListenerTest {
 
 		private final Command command = CommandTestFactory.createBuilder().build();
 
-		private CollaborationRequest collaborationRequest = CollaborationRequestTestFactory.create();
-
 		@Captor
 		private ArgumentCaptor<CommandFailedEvent> commandFailedEventCaptor;
 
 		@Test
 		void shouldCallCommandMapper() {
-			when(commandMapper.toCollaborationRequest(any())).thenReturn(collaborationRequest);
+			when(commandMapper.toCollaborationRequest(any())).thenReturn(CollaborationRequestTestFactory.create());
 
 			eventListener.createCollaborationRequest(command);
 
@@ -104,6 +102,7 @@ class CollaborationEventListenerTest {
 
 		@Test
 		void shouldCallCreateCollaborationRequest() {
+			var collaborationRequest = CollaborationRequestTestFactory.create();
 			when(commandMapper.toCollaborationRequest(any())).thenReturn(collaborationRequest);
 
 			eventListener.createCollaborationRequest(command);
@@ -113,7 +112,7 @@ class CollaborationEventListenerTest {
 
 		@Test
 		void shouldCallCreateFachstellenBeteiligungRequest() {
-			collaborationRequest = CollaborationRequestTestFactory.createBuilder().collaborationLevel(4).build();
+			var collaborationRequest = CollaborationRequestTestFactory.createBuilder().collaborationLevel(4).build();
 			when(commandMapper.toCollaborationRequest(any())).thenReturn(collaborationRequest);
 
 			eventListener.createCollaborationRequest(command);
@@ -125,7 +124,7 @@ class CollaborationEventListenerTest {
 		@ParameterizedTest(name = "when collaboration level is {0}")
 		@ValueSource(ints = { 0, 2, 3, 5 })
 		void shouldDeclineRequest(int collaborationLevel) {
-			collaborationRequest = CollaborationRequestTestFactory.createBuilder().collaborationLevel(collaborationLevel).build();
+			var collaborationRequest = CollaborationRequestTestFactory.createBuilder().collaborationLevel(collaborationLevel).build();
 			when(commandMapper.toCollaborationRequest(any())).thenReturn(collaborationRequest);
 
 			eventListener.createCollaborationRequest(command);
diff --git a/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/CollaborationServiceITCase.java b/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/CollaborationServiceITCase.java
index 8eb4154..5284752 100644
--- a/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/CollaborationServiceITCase.java
+++ b/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/CollaborationServiceITCase.java
@@ -79,8 +79,8 @@ class CollaborationServiceITCase {
 	@Nested
 	class TestCreateFachstellenBeteiligungRequest {
 
-		@DisplayName("should validate titel")
-		@ParameterizedTest(name = "fail when titel: \"{0}\"")
+		@DisplayName("validate titel")
+		@ParameterizedTest(name = "should throw exception on titel: \"{0}\"")
 		@NullAndEmptySource
 		@ValueSource(strings = { StringUtils.SPACE })
 		void shouldValidateTitel(String titel) {
@@ -89,8 +89,8 @@ class CollaborationServiceITCase {
 			Assertions.assertThrows(ConstraintViolationException.class, () -> service.createFachstellenBeteiligungRequest(request));
 		}
 
-		@DisplayName("should validate anfrage")
-		@ParameterizedTest(name = "fail when titel: \"{0}\"")
+		@DisplayName("validate anfrage")
+		@ParameterizedTest(name = "should throw exception on anfrage: \"{0}\"")
 		@NullAndEmptySource
 		@ValueSource(strings = { StringUtils.SPACE })
 		void shouldValidateAnfrage(String anfrage) {
@@ -99,8 +99,8 @@ class CollaborationServiceITCase {
 			Assertions.assertThrows(ConstraintViolationException.class, () -> service.createFachstellenBeteiligungRequest(request));
 		}
 
-		@DisplayName("should validate zustaendigeStelle")
-		@ParameterizedTest(name = "fail when zustaendigeStelle: \"{0}\"")
+		@DisplayName("validate zustaendigeStelle")
+		@ParameterizedTest(name = "should throw exception oon zustaendigeStelle: \"{0}\"")
 		@NullAndEmptySource
 		@ValueSource(strings = { StringUtils.SPACE })
 		void shouldValidateCollaborationRequestTitel(String zustaendigeStelle) {
diff --git a/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/vorgang/PostfachAddressTestFactory.java b/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/vorgang/PostfachAddressTestFactory.java
index e1102be..8c20d29 100644
--- a/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/vorgang/PostfachAddressTestFactory.java
+++ b/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/vorgang/PostfachAddressTestFactory.java
@@ -26,15 +26,14 @@ package de.ozgcloud.collaboration.vorgang;
 import java.util.Map;
 
 import de.ozgcloud.apilib.vorgang.OzgCloudPostfachAddressIdentifierTestFactory;
-import de.ozgcloud.apilib.vorgang.OzgCloudPostfachAddressTestFactory;
 import de.ozgcloud.collaboration.vorgang.ServiceKonto.PostfachAddress;
 import de.ozgcloud.collaboration.vorgang.ServiceKonto.PostfachAddress.PostfachAddressBuilder;
 
 public class PostfachAddressTestFactory {
 
-	public static final String VERSION = OzgCloudPostfachAddressTestFactory.VERSION;
-	public static final int TYPE = OzgCloudPostfachAddressTestFactory.TYPE;
-	public static final String POSTFACH_ID = OzgCloudPostfachAddressIdentifierTestFactory.VALUE;
+	public static final String VERSION = "1.0";
+	public static final int TYPE = 1;
+	public static final String POSTFACH_ID = "0815";
 
 	public static PostfachAddress create() {
 		return createBuilder().build();
diff --git a/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/vorgang/ServiceKontoTestFactory.java b/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/vorgang/ServiceKontoTestFactory.java
index d9b42bd..b7e0105 100644
--- a/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/vorgang/ServiceKontoTestFactory.java
+++ b/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/vorgang/ServiceKontoTestFactory.java
@@ -23,13 +23,12 @@
  */
 package de.ozgcloud.collaboration.vorgang;
 
-import de.ozgcloud.apilib.vorgang.OzgCloudServiceKontoTestFactory;
 import de.ozgcloud.collaboration.vorgang.ServiceKonto.ServiceKontoBuilder;
 
 public class ServiceKontoTestFactory {
 
 	public static final TrustLevel TRUST_LEVEL = TrustLevel.LEVEL_1;
-	public static final String TYPE = OzgCloudServiceKontoTestFactory.TYPE_STR;
+	public static final String TYPE = "type";
 	public static final ServiceKonto.PostfachAddress POSTFACH_ADDRESS = PostfachAddressTestFactory.create();
 
 	public static ServiceKonto create() {
-- 
GitLab