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

OZG-165 removing 'Eingang' from vorgang mapping

parent d6e12ae8
No related branches found
No related tags found
No related merge requests found
Showing
with 189 additions and 226 deletions
......@@ -29,7 +29,12 @@ message GrpcEingang {
Antragsteller antragsteller = 3;
ZustaendigeStelle zustaendigeStelle = 4;
repeated SubForm form = 10;
GrpcFormData formData = 10;
}
message GrpcFormData {
repeated FormField field = 1;
repeated SubForm form = 2;
}
message Antragsteller {
......@@ -41,8 +46,7 @@ message Antragsteller {
string geburtsname = 20;
repeated Field otherField = 30;
repeated SubForm subForm = 31;
GrpcFormData otherData = 30;
}
message ZustaendigeStelle {
......@@ -63,11 +67,11 @@ message EingangHeader {
message SubForm {
string title = 1;
repeated Field field = 2;
repeated FormField field = 2;
repeated SubForm subForm = 3;
}
message Field {
message FormField {
string name = 1;
string value = 2;
}
......
package de.itvsh.ozg.pluto;
import java.util.TimeZone;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
......@@ -7,8 +9,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
public class PlutoServerApplication {
public static void main(String[] args) {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
SpringApplication.run(PlutoServerApplication.class, args);
}
}
package de.itvsh.ozg.pluto.vorgang;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.apache.commons.lang3.tuple.Pair;
import org.mapstruct.CollectionMappingStrategy;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.NullValuePropertyMappingStrategy;
@Mapper(uses = { AntragstellerMapper.class,
EingangHeaderMapper.class }, nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE, nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED)
EingangHeaderMapper.class }, //
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE, //
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, //
collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED)
interface EingangMapper {
@Mapping(target = "subFormList", source = "formList")
static final Predicate<Entry<String, Object>> IS_FIELD_VALUE = entry -> entry.getValue() instanceof String;
PlutoEingang fromGrpc(GrpcEingang grpcEingang);
default PlutoSubForm buildPlutoSubForm(SubForm subForm) {
return PlutoSubForm.builder()
.title(subForm.getTitle())
.formMap(buildPlutoFormMap(subForm.getFieldList()))
.subFormList(buildPlutoSubFormList(subForm))
.build();
default Map<String, Object> mapFormData(GrpcFormData formData) {
Map<String, Object> result = new HashMap<>();
result.putAll(mapSubFormFields(formData.getFieldList()));
result.putAll(mapFormData(formData.getFormList()));
return result;
}
default List<PlutoSubForm> buildPlutoSubFormList(SubForm subForm) {
if (subForm.getSubFormList() == null)
return Collections.emptyList();
return subForm.getSubFormList().stream()
.map(entry -> buildPlutoSubForm(entry))
.collect(Collectors.toList());
default Map<String, Object> mapFormData(List<SubForm> subForms) {
return subForms.stream().map(subForm -> Pair.of(subForm.getTitle(), mapSubForm(subForm)))
.collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
}
default Map<String, Object> mapSubForm(SubForm subForm) {
Map<String, Object> result = new HashMap<>();
result.putAll(mapSubFormFields(subForm.getFieldList()));
result.putAll(mapFormData(subForm.getSubFormList()));
return result;
}
default Map<String, Object> mapSubFormFields(List<FormField> fields) {
return fields.stream().collect(Collectors.toMap(FormField::getName, FormField::getValue));
}
default HashMap<String, String> buildPlutoFormMap(List<Field> list) {
return list.stream().collect(Collectors.toMap(Field::getName, Field::getValue, (a, b) -> a, HashMap::new));
default HashMap<String, String> buildPlutoFormMap(List<FormField> list) {
return list.stream().collect(Collectors.toMap(FormField::getName, FormField::getValue, (a, b) -> a, HashMap::new));
}
@Mapping(target = "formList", source = "subFormList")
GrpcEingang toGrpc(PlutoEingang eingang);
default SubForm buildGrpcSubForm(PlutoSubForm subForm) {
return SubForm.newBuilder()
.setTitle(subForm.getTitle())
.addAllField(buildGrpcFormList(subForm.getFormMap()))
.addAllSubForm(buildSubFormList(subForm))
.build();
default GrpcFormData buildGrpcFormData(Map<String, Object> formData) {
return GrpcFormData.newBuilder().addAllField(buildGrpcFieldList(formData)).addAllForm(buildGrpcSubForms(formData)).build();
}
default List<SubForm> buildSubFormList(PlutoSubForm subForm) {
if (subForm.getSubFormList() == null)
return Collections.emptyList();
return subForm.getSubFormList().stream()
.map(entry -> buildGrpcSubForm(entry))
default List<FormField> buildGrpcFieldList(Map<String, Object> fieldMap) {
return fieldMap.entrySet().stream()
.filter(IS_FIELD_VALUE)
.map(this::buildGrpcField)
.collect(Collectors.toList());
}
default List<Field> buildGrpcFormList(HashMap<String, String> fieldMap) {
return fieldMap.entrySet().stream()
.map(entry -> buildGrpcField(entry))
@SuppressWarnings("unchecked")
default List<SubForm> buildGrpcSubForms(Map<String, Object> formData) {
return formData.entrySet().stream().filter(IS_FIELD_VALUE.negate())
.map(entry -> buildSubForm(entry.getKey(), (Map<String, Object>) entry.getValue()))
.collect(Collectors.toList());
}
default Field buildGrpcField(Entry<String, String> entry) {
return Field.newBuilder().setName(entry.getKey()).setValue(entry.getValue()).build();
default SubForm buildSubForm(String title, Map<String, Object> formData) {
return SubForm.newBuilder().setTitle(title).addAllField(buildGrpcFieldList(formData)).addAllSubForm(buildGrpcSubForms(formData)).build();
}
default FormField buildGrpcField(Entry<String, Object> entry) {
return FormField.newBuilder().setName(entry.getKey()).setValue(entry.getValue().toString()).build();
}
}
\ No newline at end of file
package de.itvsh.ozg.pluto.vorgang;
import java.util.List;
import java.util.Map;
import lombok.Builder;
import lombok.Getter;
......@@ -16,5 +16,5 @@ public class PlutoEingang {
private PlutoEingangHeader header;
private PlutoAntragsteller antragsteller;
private List<PlutoSubForm> subFormList;
private Map<String, Object> formData;
}
\ No newline at end of file
package de.itvsh.ozg.pluto.vorgang;
import java.util.HashMap;
import java.util.List;
import lombok.Builder;
import lombok.Getter;
import lombok.ToString;
@ToString
@Getter
@Builder
public class PlutoSubForm {
private String title;
private HashMap<String, String> formMap;
private List<PlutoSubForm> subFormList;
}
\ No newline at end of file
......@@ -7,3 +7,7 @@ spring:
data:
mongodb:
host: 172.30.190.222
......@@ -21,4 +21,13 @@ class ZonedDateTimeWriteConverterTest {
assertThat(convertedDate).isEqualTo(DATE_STR);
}
@Test
void shouldConvertToUTC() throws ParseException {
var date = ZonedDateTime.parse("2021-01-18T07:00:00+01:00");
var convertedDate = converter.convert(date);
assertThat(convertedDate).isEqualTo("2021-01-18T06:00:00Z");
}
}
\ No newline at end of file
package de.itvsh.ozg.pluto.vorgang;
import static de.itvsh.ozg.pluto.vorgang.GrpcSubFormTestFactory.*;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import java.util.Map;
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.mapstruct.factory.Mappers;
......@@ -72,56 +76,59 @@ class EingangMapperTest {
assertThat(eingang.getHeader()).isNull();
}
@DisplayName("Mapped FormData")
@Nested
class TestMapSubFormToPlutoSubForm {
class TestMapSubFormToFormData {
private GrpcEingang grpcEingang = GrpcEingangTestFactory.create();
@Test
void shouldNotBeEmpty() {
GrpcEingang grpcEingang = GrpcEingangTestFactory.create();
var eingang = mapper.fromGrpc(grpcEingang);
assertThat(eingang.getSubFormList()).isNotEmpty();
assertThat(eingang.getSubFormList().get(0).getTitle()).isEqualTo(GrpcSubFormTestFactory.TITLE);
assertThat(eingang.getFormData()).isNotEmpty();
}
@Test
void shouldHaveMappedSubForm() {
GrpcEingang grpcEingang = GrpcEingangTestFactory.create();
var eingang = mapper.fromGrpc(grpcEingang);
assertThat(eingang.getSubFormList()).isNotEmpty();
PlutoSubForm subForm = eingang.getSubFormList().get(0);
assertThat(subForm.getTitle()).isEqualTo(GrpcSubFormTestFactory.TITLE);
assertThat(subForm.getFormMap().get(GrpcSubFormTestFactory.FIELD_1_NAME)).isEqualTo(GrpcSubFormTestFactory.FIELD_1_VALUE);
assertThat(subForm.getFormMap().get(GrpcSubFormTestFactory.FIELD_2_NAME)).isEqualTo(GrpcSubFormTestFactory.FIELD_2_VALUE);
assertThat(eingang.getFormData()).containsKey(TITLE);
}
@DisplayName("mapped FormData should contain fields")
@Test
void fieldsInSubForm() {
var eingang = mapper.fromGrpc(grpcEingang);
@SuppressWarnings("unchecked")
Map<String, Object> formData = (Map<String, Object>) eingang.getFormData().get(TITLE);
assertThat(formData).containsEntry(FIELD_NAME, FIELD_VALUE);
}
@DisplayName("mapped FormData should contains subForm")
@Test
void shouldHaveMappedSubFormWithSubForm() {
GrpcEingang grpcEingang = GrpcEingangTestFactory.create();
var eingang = mapper.fromGrpc(grpcEingang);
@SuppressWarnings("unchecked")
Map<String, Object> formData = (Map<String, Object>) eingang.getFormData().get(TITLE);
assertThat(eingang.getSubFormList()).isNotEmpty();
PlutoSubForm subForm = eingang.getSubFormList().get(1).getSubFormList().get(0);
assertThat(subForm.getTitle()).isEqualTo(GrpcSubFormTestFactory.TITLE);
assertThat(subForm.getFormMap().get(GrpcSubFormTestFactory.FIELD_1_NAME)).isEqualTo(GrpcSubFormTestFactory.FIELD_1_VALUE);
assertThat(subForm.getFormMap().get(GrpcSubFormTestFactory.FIELD_2_NAME)).isEqualTo(GrpcSubFormTestFactory.FIELD_2_VALUE);
assertThat(formData).containsKey(GrpcSubFormTestFactory.SUBFORM_NAME);
}
@DisplayName("mapped SubForm should contain field")
@Test
void shouldHaveMappedSubFormWithSubFormWithSubForm() {
GrpcEingang grpcEingang = GrpcEingangTestFactory.create();
void subFormShouldContainField() {
var eingang = mapper.fromGrpc(grpcEingang);
@SuppressWarnings("unchecked")
Map<String, Object> subForm = (Map<String, Object>) ((Map<String, Object>) eingang.getFormData().get(TITLE)).get(SUBFORM_NAME);
assertThat(eingang.getSubFormList()).isNotEmpty();
PlutoSubForm subForm = eingang.getSubFormList().get(2).getSubFormList().get(0).getSubFormList().get(0);
assertThat(subForm.getTitle()).isEqualTo(GrpcSubFormTestFactory.TITLE);
assertThat(subForm.getFormMap().get(GrpcSubFormTestFactory.FIELD_1_NAME)).isEqualTo(GrpcSubFormTestFactory.FIELD_1_VALUE);
assertThat(subForm.getFormMap().get(GrpcSubFormTestFactory.FIELD_2_NAME)).isEqualTo(GrpcSubFormTestFactory.FIELD_2_VALUE);
assertThat(subForm).containsEntry(SUBFORM_FIELD_NAME, SUBFORM_FIELD_VALUE);
}
}
}
......@@ -176,70 +183,55 @@ class EingangMapperTest {
assertThat(grpcEingang.hasHeader()).isFalse();
}
@DisplayName("Mapped Eingang")
@Nested
class TestMapPlutoSubFormToSubForm {
class TestMapEingangToGrpcEingang {
@DisplayName("contains formdata")
@Nested
class TestMappingFormData {
private PlutoEingang eingang = PlutoEingangTestFactory.create();
@Test
void shouldNotBeEmpty() {
PlutoEingang eingang = PlutoEingangTestFactory.create();
var grpcEingang = mapper.toGrpc(eingang);
assertThat(grpcEingang.getFormList()).isNotEmpty();
assertThat(grpcEingang.getFormList().get(0).getTitle()).isEqualTo(PlutoSubFormTestFactory.TITLE);
assertThat(grpcEingang.getFormData()).isNotNull();
}
@Test
void shouldHaveMappedSubForm() {
PlutoEingang eingang = PlutoEingangTestFactory.create();
var grpcEingang = mapper.toGrpc(eingang);
void shouldHaveFields() {
var formData = mapper.toGrpc(eingang).getFormData();
assertThat(grpcEingang.getFormList()).isNotEmpty();
SubForm subForm = grpcEingang.getFormList().get(0);
assertThat(subForm.getTitle()).isEqualTo(PlutoSubFormTestFactory.TITLE);
shouldMatchFieldValues(subForm);
assertThat(formData.getFieldList()).hasSize(1);
}
@Test
void shouldHaveMappedSubFormWithSubForm() {
PlutoEingang eingang = PlutoEingangTestFactory.create();
var grpcEingang = mapper.toGrpc(eingang);
void shouldHaveMappedFormData() {
var formData = mapper.toGrpc(eingang).getFormData();
assertThat(grpcEingang.getFormList()).isNotEmpty();
SubForm subForm = grpcEingang.getFormList().get(1).getSubFormList().get(0);
assertThat(subForm.getTitle()).isEqualTo(PlutoSubFormTestFactory.TITLE);
shouldMatchFieldValues(subForm);
assertThat(formData.getFormList()).hasSize(1);
}
@Test
void shouldHaveMappedSubFormWithSubFormWithSubForm() {
PlutoEingang eingang = PlutoEingangTestFactory.create();
var grpcEingang = mapper.toGrpc(eingang);
void shouldHaveFormWithTitle() {
var formData = mapper.toGrpc(eingang).getFormData();
assertThat(grpcEingang.getFormList()).isNotEmpty();
SubForm subForm = grpcEingang.getFormList().get(2).getSubFormList().get(0).getSubFormList().get(0);
assertThat(subForm.getTitle()).isEqualTo(PlutoSubFormTestFactory.TITLE);
shouldMatchFieldValues(subForm);
assertThat(formData.getForm(0).getTitle()).isEqualTo(PlutoEingangTestFactory.SUBFORM_NAME);
}
private void shouldMatchFieldValues(SubForm subForm) {
var oneField = subForm.getField(0);
if (oneField.getName().equals(PlutoSubFormTestFactory.FORM_FIELD_1_KEY)) {
assertThat(oneField.getValue()).isEqualTo(PlutoSubFormTestFactory.FORM_FIELD_1_VALUE);
} else {
assertThat(oneField.getValue()).isEqualTo(PlutoSubFormTestFactory.FORM_FIELD_2_VALUE);
}
@Test
void formDataShouldHaveFields() {
var formData = mapper.toGrpc(eingang).getFormData();
var otherField = subForm.getField(1);
if (otherField.getName().equals(PlutoSubFormTestFactory.FORM_FIELD_2_KEY)) {
assertThat(otherField.getValue()).isEqualTo(PlutoSubFormTestFactory.FORM_FIELD_2_VALUE);
} else {
assertThat(otherField.getValue()).isEqualTo(PlutoSubFormTestFactory.FORM_FIELD_1_VALUE);
assertThat(formData.getFieldList()).hasSize(1);
assertThat(formData.getField(0).getName()).isEqualTo(PlutoEingangTestFactory.SINGLE_FIELD_NAME);
assertThat(formData.getField(0).getValue()).isEqualTo(PlutoEingangTestFactory.SINGLE_FIELD_VALUE);
}
}
}
}
}
\ No newline at end of file
package de.itvsh.ozg.pluto.vorgang;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
public class GrpcEingangTestFactory {
public static final String ID = UUID.randomUUID().toString();
public static final List<SubForm> SUB_FORM_LIST = Arrays.asList(
GrpcSubFormTestFactory.create(),
GrpcSubFormTestFactory.createBuilder()
.addAllSubForm(Collections.singleton(GrpcSubFormTestFactory.create()))
.build(),
GrpcSubFormTestFactory.createBuilder()
.addAllSubForm(Collections.singleton(
GrpcSubFormTestFactory.createBuilder()
.addAllSubForm(Collections.singleton(GrpcSubFormTestFactory.create()))
.build()))
.build());
public static final SubForm SUB_FORM = GrpcSubFormTestFactory.create();
public static GrpcEingang create() {
return createBuilder().build();
......@@ -29,6 +16,6 @@ public class GrpcEingangTestFactory {
.setId(ID)
.setHeader(GrpcEingangHeaderTestFactory.create())
.setAntragsteller(GrpcAntragstellerTestFactory.create())
.addAllForm(SUB_FORM_LIST);
.setFormData(GrpcFormData.newBuilder().addForm(GrpcSubFormTestFactory.create()).build());
}
}
\ No newline at end of file
package de.itvsh.ozg.pluto.vorgang;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.assertj.core.util.Arrays;
import com.thedeanda.lorem.LoremIpsum;
public class GrpcSubFormTestFactory {
public static final String TITLE = LoremIpsum.getInstance().getWords(2);
public static final String TITLE = "kontakt";
public static final String FIELD_NAME = "name";
public static final String FIELD_VALUE = LoremIpsum.getInstance().getName();
public static final String FIELD_1_NAME = LoremIpsum.getInstance().getName();
public static final String FIELD_1_VALUE = LoremIpsum.getInstance().getWords(5);
public static final String FIELD_2_NAME = LoremIpsum.getInstance().getName();
public static final String FIELD_2_VALUE = LoremIpsum.getInstance().getWords(5);
private static final List<Field> FIELD_LIST = Stream.of(Arrays.array(
Field.newBuilder().setName(FIELD_1_NAME).setValue(FIELD_1_VALUE).build(),
Field.newBuilder().setName(FIELD_2_NAME).setValue(FIELD_2_VALUE).build()))
.collect(Collectors.toList());
public static final String SUBFORM_NAME = "adresse";
public static final String SUBFORM_FIELD_NAME = "ort";
public static final String SUBFORM_FIELD_VALUE = LoremIpsum.getInstance().getCity();
public static SubForm create() {
return createBuilder().build();
......@@ -28,6 +20,8 @@ public class GrpcSubFormTestFactory {
public static SubForm.Builder createBuilder() {
return SubForm.newBuilder()
.setTitle(TITLE)
.addAllField(FIELD_LIST);
.addField(FormField.newBuilder().setName(FIELD_NAME).setValue(FIELD_VALUE).build())
.addSubForm(SubForm.newBuilder().setTitle(SUBFORM_NAME).addField(
FormField.newBuilder().setName(SUBFORM_FIELD_NAME).setValue(SUBFORM_FIELD_VALUE).build()));
}
}
\ No newline at end of file
package de.itvsh.ozg.pluto.vorgang;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class PlutoEingangTestFactory {
public static final String ID = UUID.randomUUID().toString();
public static final List<PlutoSubForm> SUB_FORM_LIST = Arrays.asList(
PlutoSubFormTestFactory.create(),
PlutoSubFormTestFactory.createBuilder()
.subFormList(Arrays.asList(PlutoSubFormTestFactory.create()))
.build(),
PlutoSubFormTestFactory.createBuilder()
.subFormList(Arrays.asList(
PlutoSubFormTestFactory.createBuilder()
.subFormList(Arrays.asList(PlutoSubFormTestFactory.create()))
.build()))
.build());
public static final String SINGLE_FIELD_NAME = "name";
public static final String SINGLE_FIELD_VALUE = "Thea";
public static final String SUBFORM_FIELD_NAME = "E-Mail";
public static final String SUBFORM_FIELD_VALUE = "thea@burger-portal.sh.de";
public static final String SUBFORM_NAME = "kontakt";
public static final Map<String, Object> SUBFORM = Map.of(SUBFORM_FIELD_NAME, SUBFORM_FIELD_VALUE);
public static final Map<String, Object> FORM_DATA = Map.of(SINGLE_FIELD_NAME, SINGLE_FIELD_VALUE, SUBFORM_NAME, SUBFORM);
public static PlutoEingang create() {
return createBuilder().build();
......@@ -28,6 +26,7 @@ public class PlutoEingangTestFactory {
.id(ID)
.header(PlutoEingangHeaderTestFactory.create())
.antragsteller(PlutoAntragstellerTestFactory.create())
.subFormList(SUB_FORM_LIST);
.formData(FORM_DATA);
// .subFormList(SUB_FORM_LIST);
}
}
\ No newline at end of file
package de.itvsh.ozg.pluto.vorgang;
import java.util.HashMap;
import com.thedeanda.lorem.LoremIpsum;
public class PlutoSubFormTestFactory {
public static final String TITLE = LoremIpsum.getInstance().getWords(10);
public static final String FORM_FIELD_1_KEY = LoremIpsum.getInstance().getWords(1);
public static final String FORM_FIELD_1_VALUE = LoremIpsum.getInstance().getWords(5);
public static final String FORM_FIELD_2_KEY = LoremIpsum.getInstance().getWords(1);
public static final String FORM_FIELD_2_VALUE = LoremIpsum.getInstance().getWords(5);
private static final HashMap<String, String> FORM_MAP = new HashMap<>() {
private static final long serialVersionUID = 1L;
{
put(FORM_FIELD_1_KEY, FORM_FIELD_1_VALUE);
put(FORM_FIELD_2_KEY, FORM_FIELD_2_VALUE);
}
};
public static PlutoSubForm create() {
return createBuilder().build();
}
public static PlutoSubForm.PlutoSubFormBuilder createBuilder() {
return PlutoSubForm.builder()
.title(TITLE)
.formMap(FORM_MAP);
}
}
\ No newline at end of file
......@@ -2,13 +2,15 @@ package de.itvsh.ozg.pluto.vorgang;
import static org.assertj.core.api.Assertions.*;
import java.util.List;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;
import java.util.TimeZone;
import org.junit.jupiter.api.BeforeAll;
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.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
......@@ -29,7 +31,6 @@ class VorgangRepositoryITCase {
assertThat(persisted.getId()).isNotNull();
}
@TestInstance(Lifecycle.PER_CLASS)
@Nested
class TestLoadVorgang {
......@@ -37,7 +38,7 @@ class VorgangRepositoryITCase {
private Vorgang persistedVorgang;
@BeforeAll
@BeforeEach
void persistVorgang() {
persistedVorgang = repository.save(vorgang);
}
......@@ -76,13 +77,23 @@ class VorgangRepositoryITCase {
assertThat(antragsteller.getAnrede()).isEqualTo(PlutoAntragstellerTestFactory.ANREDE);
}
@TestInstance(Lifecycle.PER_CLASS)
@Test
void shouldContainCorretTime() {
var persisted = repository
.save(VorgangTestFactory.createBuilder().id(null).createdAt(ZonedDateTime.parse("2021-01-01T10:00:00+05:00")).build());
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
var loaded = repository.findById(persisted.getId()).get();
assertThat(loaded.getCreatedAt().format(DateTimeFormatter.ISO_DATE_TIME)).hasToString("2021-01-01T05:00:00Z");
}
@Nested
class TestLoadVorgangWithEingangSubForm {
private Vorgang persistedVorgang;
@BeforeAll
@BeforeEach
void persistVorgang() {
persistedVorgang = repository.save(vorgang);
}
......@@ -92,26 +103,28 @@ class VorgangRepositoryITCase {
var loaded = repository.findById(persistedVorgang.getId());
assertThat(loaded).isPresent();
List<PlutoSubForm> subFormList = loaded.get().getEingangs().get(0).getSubFormList();
assertThat(subFormList).isNotEmpty();
assertThat(loaded.get().getEingangs()).hasSize(1);
assertThat(loaded.get().getEingangs().get(0).getFormData()).isNotEmpty();
}
@DisplayName("should contain FormData with SubForm")
@Test
void shouldContainEingangSubFormListWithSubFormList() {
var loaded = repository.findById(persistedVorgang.getId());
assertThat(loaded).isPresent();
List<PlutoSubForm> subFormList = loaded.get().getEingangs().get(0).getSubFormList().get(1).getSubFormList();
assertThat(subFormList).isNotEmpty();
var subFormMap = loaded.get().getEingangs().get(0).getFormData().get(PlutoEingangTestFactory.SUBFORM_NAME);
assertThat(subFormMap).isInstanceOf(Map.class);
}
@DisplayName("should contain FormData with Field")
@Test
void shouldContainEingangSubFormListWithSubFormListWithSubFormList() {
var loaded = repository.findById(persistedVorgang.getId());
assertThat(loaded).isPresent();
List<PlutoSubForm> subFormList = loaded.get().getEingangs().get(0).getSubFormList().get(2).getSubFormList().get(0).getSubFormList();
assertThat(subFormList).isNotEmpty();
var fieldValue = loaded.get().getEingangs().get(0).getFormData().get(PlutoEingangTestFactory.SINGLE_FIELD_NAME);
assertThat(fieldValue).isEqualTo(PlutoEingangTestFactory.SINGLE_FIELD_VALUE);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment