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

OZG-5899 map empty field to empty list

parent b382b64c
Branches
Tags
No related merge requests found
...@@ -93,7 +93,7 @@ public interface BescheidMapper { ...@@ -93,7 +93,7 @@ public interface BescheidMapper {
} }
default Optional<List<FileId>> mapToAttachments(Object attachments) { default Optional<List<FileId>> mapToAttachments(Object attachments) {
if (Objects.isNull(attachments)) { if (Objects.isNull(attachments) || StringUtils.isEmpty(String.valueOf(attachments))) {
return Optional.empty(); return Optional.empty();
} }
if (attachments instanceof Collection<?> attachmentList) { if (attachments instanceof Collection<?> attachmentList) {
......
...@@ -7,6 +7,7 @@ import static org.mockito.Mockito.*; ...@@ -7,6 +7,7 @@ import static org.mockito.Mockito.*;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
...@@ -99,6 +100,13 @@ class BescheidMapperTest { ...@@ -99,6 +100,13 @@ class BescheidMapperTest {
assertThat(attachments).hasValue(Collections.singletonList(BescheidTestFactory.ATTACHMENT)); assertThat(attachments).hasValue(Collections.singletonList(BescheidTestFactory.ATTACHMENT));
} }
@Test
void shouldMapEmptyStringToEmptyList() {
var attachments = mapper.mapToAttachments(StringUtils.EMPTY);
assertThat(attachments).isEmpty();
}
} }
@DisplayName("To get bescheid draft response") @DisplayName("To get bescheid draft response")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment