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

OZG-6636 map empty trustLevel as null

parent 62164426
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,7 @@ import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -166,7 +167,7 @@ class FormDataController {
return ServiceKonto.builder()
.type(formCycleServiceKonto.getType())
.postfachAddress(buildPostfachAddress(formCycleServiceKonto))
.trustLevel(formCycleServiceKonto.getTrustLevel())
.trustLevel(StringUtils.trimToNull(formCycleServiceKonto.getTrustLevel()))
.build();
}
......
......@@ -34,7 +34,9 @@ import java.io.ByteArrayOutputStream;
import java.util.Collections;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
......@@ -56,8 +58,8 @@ import de.ozgcloud.eingang.common.formdata.IncomingFileGroupTestFactory;
import de.ozgcloud.eingang.common.formdata.IncomingFileTestFactory;
import de.ozgcloud.eingang.common.formdata.ServiceKonto.PostfachAddress;
import de.ozgcloud.eingang.common.formdata.ServiceKontoTestFactory;
import de.ozgcloud.eingang.common.vorgang.VorgangNummerSupplier;
import de.ozgcloud.eingang.common.formdata.StringBasedIdentifier;
import de.ozgcloud.eingang.common.vorgang.VorgangNummerSupplier;
import de.ozgcloud.eingang.semantik.SemantikAdapter;
import lombok.SneakyThrows;
......@@ -298,6 +300,7 @@ class FormDataControllerTest {
}
}
@DisplayName("ServiceKonto mapping")
@Nested
class TestServiceKontoMapping {
......@@ -315,14 +318,29 @@ class FormDataControllerTest {
verify(controller, never()).buildServiceKonto(any());
}
@Test
void shouldMapTrustLevel() {
var formData = controller.addServiceKonto(FormCycleFormDataTestFactory.create(), buildEmptyFormDataWithHeader());
@DisplayName("trustLevel")
@Nested
class TestTrustLevel {
@Test
void shouldMap() {
var formData = controller.addServiceKonto(FormCycleFormDataTestFactory.create(), buildEmptyFormDataWithHeader());
assertThat(formData.getHeader().getServiceKonto().getTrustLevel()).isEqualTo(ServiceKontoTestFactory.TRUST_LEVEL);
}
assertThat(formData.getHeader().getServiceKonto().getTrustLevel()).isEqualTo(ServiceKontoTestFactory.TRUST_LEVEL);
@Test
void shouldMapAsNullIfEmpty() {
var serviceKontoWithEmptyTrustLevel = FormCycleServiceKontoTestFactory.createBuilder().setTrustLevel(StringUtils.EMPTY).build();
var formCycleFormData = FormCycleFormDataTestFactory.createBuilder().setServiceKonto(serviceKontoWithEmptyTrustLevel).build();
var formData = controller.addServiceKonto(formCycleFormData, buildEmptyFormDataWithHeader());
assertThat(formData.getHeader().getServiceKonto().getTrustLevel()).isNull();
}
}
String getServiceKontoType(FormData formData) {
private String getServiceKontoType(FormData formData) {
return formData.getHeader().getServiceKonto().getType();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment