Skip to content
Snippets Groups Projects
Commit cdf67a7b authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6523 implement comments from code review

parent ea00a198
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,6 @@ import java.util.Map; ...@@ -29,7 +29,6 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.mapstruct.CollectionMappingStrategy; import org.mapstruct.CollectionMappingStrategy;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
...@@ -89,6 +88,6 @@ public interface CollaborationServiceKontoMapper { ...@@ -89,6 +88,6 @@ public interface CollaborationServiceKontoMapper {
GrpcServiceKonto toServiceKonto(ServiceKonto serviceKonto); GrpcServiceKonto toServiceKonto(ServiceKonto serviceKonto);
default String toString(TrustLevel trustLevel) { default String toString(TrustLevel trustLevel) {
return Objects.isNull(trustLevel) ? StringUtils.EMPTY : trustLevel.getValue(); return trustLevel.getValue();
} }
} }
\ No newline at end of file
...@@ -88,14 +88,12 @@ class CollaborationEventListenerTest { ...@@ -88,14 +88,12 @@ class CollaborationEventListenerTest {
private final Command command = CommandTestFactory.createBuilder().build(); private final Command command = CommandTestFactory.createBuilder().build();
private CollaborationRequest collaborationRequest = CollaborationRequestTestFactory.create();
@Captor @Captor
private ArgumentCaptor<CommandFailedEvent> commandFailedEventCaptor; private ArgumentCaptor<CommandFailedEvent> commandFailedEventCaptor;
@Test @Test
void shouldCallCommandMapper() { void shouldCallCommandMapper() {
when(commandMapper.toCollaborationRequest(any())).thenReturn(collaborationRequest); when(commandMapper.toCollaborationRequest(any())).thenReturn(CollaborationRequestTestFactory.create());
eventListener.createCollaborationRequest(command); eventListener.createCollaborationRequest(command);
...@@ -104,6 +102,7 @@ class CollaborationEventListenerTest { ...@@ -104,6 +102,7 @@ class CollaborationEventListenerTest {
@Test @Test
void shouldCallCreateCollaborationRequest() { void shouldCallCreateCollaborationRequest() {
var collaborationRequest = CollaborationRequestTestFactory.create();
when(commandMapper.toCollaborationRequest(any())).thenReturn(collaborationRequest); when(commandMapper.toCollaborationRequest(any())).thenReturn(collaborationRequest);
eventListener.createCollaborationRequest(command); eventListener.createCollaborationRequest(command);
...@@ -113,7 +112,7 @@ class CollaborationEventListenerTest { ...@@ -113,7 +112,7 @@ class CollaborationEventListenerTest {
@Test @Test
void shouldCallCreateFachstellenBeteiligungRequest() { void shouldCallCreateFachstellenBeteiligungRequest() {
collaborationRequest = CollaborationRequestTestFactory.createBuilder().collaborationLevel(4).build(); var collaborationRequest = CollaborationRequestTestFactory.createBuilder().collaborationLevel(4).build();
when(commandMapper.toCollaborationRequest(any())).thenReturn(collaborationRequest); when(commandMapper.toCollaborationRequest(any())).thenReturn(collaborationRequest);
eventListener.createCollaborationRequest(command); eventListener.createCollaborationRequest(command);
...@@ -125,7 +124,7 @@ class CollaborationEventListenerTest { ...@@ -125,7 +124,7 @@ class CollaborationEventListenerTest {
@ParameterizedTest(name = "when collaboration level is {0}") @ParameterizedTest(name = "when collaboration level is {0}")
@ValueSource(ints = { 0, 2, 3, 5 }) @ValueSource(ints = { 0, 2, 3, 5 })
void shouldDeclineRequest(int collaborationLevel) { void shouldDeclineRequest(int collaborationLevel) {
collaborationRequest = CollaborationRequestTestFactory.createBuilder().collaborationLevel(collaborationLevel).build(); var collaborationRequest = CollaborationRequestTestFactory.createBuilder().collaborationLevel(collaborationLevel).build();
when(commandMapper.toCollaborationRequest(any())).thenReturn(collaborationRequest); when(commandMapper.toCollaborationRequest(any())).thenReturn(collaborationRequest);
eventListener.createCollaborationRequest(command); eventListener.createCollaborationRequest(command);
......
...@@ -79,8 +79,8 @@ class CollaborationServiceITCase { ...@@ -79,8 +79,8 @@ class CollaborationServiceITCase {
@Nested @Nested
class TestCreateFachstellenBeteiligungRequest { class TestCreateFachstellenBeteiligungRequest {
@DisplayName("should validate titel") @DisplayName("validate titel")
@ParameterizedTest(name = "fail when titel: \"{0}\"") @ParameterizedTest(name = "should throw exception on titel: \"{0}\"")
@NullAndEmptySource @NullAndEmptySource
@ValueSource(strings = { StringUtils.SPACE }) @ValueSource(strings = { StringUtils.SPACE })
void shouldValidateTitel(String titel) { void shouldValidateTitel(String titel) {
...@@ -89,8 +89,8 @@ class CollaborationServiceITCase { ...@@ -89,8 +89,8 @@ class CollaborationServiceITCase {
Assertions.assertThrows(ConstraintViolationException.class, () -> service.createFachstellenBeteiligungRequest(request)); Assertions.assertThrows(ConstraintViolationException.class, () -> service.createFachstellenBeteiligungRequest(request));
} }
@DisplayName("should validate anfrage") @DisplayName("validate anfrage")
@ParameterizedTest(name = "fail when titel: \"{0}\"") @ParameterizedTest(name = "should throw exception on anfrage: \"{0}\"")
@NullAndEmptySource @NullAndEmptySource
@ValueSource(strings = { StringUtils.SPACE }) @ValueSource(strings = { StringUtils.SPACE })
void shouldValidateAnfrage(String anfrage) { void shouldValidateAnfrage(String anfrage) {
...@@ -99,8 +99,8 @@ class CollaborationServiceITCase { ...@@ -99,8 +99,8 @@ class CollaborationServiceITCase {
Assertions.assertThrows(ConstraintViolationException.class, () -> service.createFachstellenBeteiligungRequest(request)); Assertions.assertThrows(ConstraintViolationException.class, () -> service.createFachstellenBeteiligungRequest(request));
} }
@DisplayName("should validate zustaendigeStelle") @DisplayName("validate zustaendigeStelle")
@ParameterizedTest(name = "fail when zustaendigeStelle: \"{0}\"") @ParameterizedTest(name = "should throw exception oon zustaendigeStelle: \"{0}\"")
@NullAndEmptySource @NullAndEmptySource
@ValueSource(strings = { StringUtils.SPACE }) @ValueSource(strings = { StringUtils.SPACE })
void shouldValidateCollaborationRequestTitel(String zustaendigeStelle) { void shouldValidateCollaborationRequestTitel(String zustaendigeStelle) {
......
...@@ -26,15 +26,14 @@ package de.ozgcloud.collaboration.vorgang; ...@@ -26,15 +26,14 @@ package de.ozgcloud.collaboration.vorgang;
import java.util.Map; import java.util.Map;
import de.ozgcloud.apilib.vorgang.OzgCloudPostfachAddressIdentifierTestFactory; 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;
import de.ozgcloud.collaboration.vorgang.ServiceKonto.PostfachAddress.PostfachAddressBuilder; import de.ozgcloud.collaboration.vorgang.ServiceKonto.PostfachAddress.PostfachAddressBuilder;
public class PostfachAddressTestFactory { public class PostfachAddressTestFactory {
public static final String VERSION = OzgCloudPostfachAddressTestFactory.VERSION; public static final String VERSION = "1.0";
public static final int TYPE = OzgCloudPostfachAddressTestFactory.TYPE; public static final int TYPE = 1;
public static final String POSTFACH_ID = OzgCloudPostfachAddressIdentifierTestFactory.VALUE; public static final String POSTFACH_ID = "0815";
public static PostfachAddress create() { public static PostfachAddress create() {
return createBuilder().build(); return createBuilder().build();
......
...@@ -23,13 +23,12 @@ ...@@ -23,13 +23,12 @@
*/ */
package de.ozgcloud.collaboration.vorgang; package de.ozgcloud.collaboration.vorgang;
import de.ozgcloud.apilib.vorgang.OzgCloudServiceKontoTestFactory;
import de.ozgcloud.collaboration.vorgang.ServiceKonto.ServiceKontoBuilder; import de.ozgcloud.collaboration.vorgang.ServiceKonto.ServiceKontoBuilder;
public class ServiceKontoTestFactory { public class ServiceKontoTestFactory {
public static final TrustLevel TRUST_LEVEL = TrustLevel.LEVEL_1; 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 final ServiceKonto.PostfachAddress POSTFACH_ADDRESS = PostfachAddressTestFactory.create();
public static ServiceKonto create() { public static ServiceKonto create() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment