Skip to content
Snippets Groups Projects
Commit 136a47f0 authored by Krzysztof Witukiewicz's avatar Krzysztof Witukiewicz
Browse files

OZG-7501 OZG-7899 Create constants for fields in command body

parent ccc41c07
Branches
Tags
1 merge request!22Ozg 7501 weiterleitung vorbereiten
This commit is part of merge request !22. Comments created here will be created in the context of that merge request.
......@@ -34,18 +34,27 @@ import de.ozgcloud.command.Command;
@Mapper(imports = MapUtils.class)
interface ForwardingRequestMapper {
interface CommandBodyFields {
String ORGANISATION_EINHEIT_ID = "organisationEinheitId";
String NAME = "name";
String STRASSE = "strasse";
String HAUSNUMMER = "hausnummer";
String PLZ = "plz";
String ORT = "ort";
}
@Mapping(target = "version", source = "relationVersion")
@Mapping(target = "organisationEinheit", source = "bodyObject")
ForwardingRequest fromCommand(Command command);
@Mapping(target = "id", expression = "java(MapUtils.getString(body, \"organisationEinheitId\"))")
@Mapping(target = "name", expression = "java(MapUtils.getString(body, \"name\"))")
@Mapping(target = "id", expression = "java(MapUtils.getString(body, CommandBodyFields.ORGANISATION_EINHEIT_ID))")
@Mapping(target = "name", expression = "java(MapUtils.getString(body, CommandBodyFields.NAME))")
@Mapping(target = "address", source = ".")
OrganisationEinheit toOrganisationEinheit(Map<String, Object> body);
@Mapping(target = "street", expression = "java(MapUtils.getString(body, \"strasse\"))")
@Mapping(target = "houseNumber", expression = "java(MapUtils.getString(body, \"hausnummer\"))")
@Mapping(target = "zipCode", expression = "java(MapUtils.getString(body, \"plz\"))")
@Mapping(target = "city", expression = "java(MapUtils.getString(body, \"ort\"))")
@Mapping(target = "street", expression = "java(MapUtils.getString(body, CommandBodyFields.STRASSE))")
@Mapping(target = "houseNumber", expression = "java(MapUtils.getString(body, CommandBodyFields.HAUSNUMMER))")
@Mapping(target = "zipCode", expression = "java(MapUtils.getString(body, CommandBodyFields.PLZ))")
@Mapping(target = "city", expression = "java(MapUtils.getString(body, CommandBodyFields.ORT))")
Address toAddress(Map<String, Object> body);
}
......@@ -35,18 +35,19 @@ import org.mapstruct.factory.Mappers;
import org.mockito.Spy;
import de.ozgcloud.vorgang.command.CommandTestFactory;
import de.ozgcloud.vorgang.vorgang.redirect.ForwardingRequestMapper.CommandBodyFields;
class ForwardingRequestMapperTest {
@Spy
private ForwardingRequestMapper mapper = Mappers.getMapper(ForwardingRequestMapper.class);
private final Map<String, Object> bodyObject = Map.of(
"organisationEinheitId", OrganisationEinheitTestFactory.ID,
"name", OrganisationEinheitTestFactory.NAME,
"strasse", AddressTestFactory.STREET,
"hausnummer", AddressTestFactory.HOUSE_NUMBER,
"plz", AddressTestFactory.ZIP_CODE,
"ort", AddressTestFactory.CITY
CommandBodyFields.ORGANISATION_EINHEIT_ID, OrganisationEinheitTestFactory.ID,
CommandBodyFields.NAME, OrganisationEinheitTestFactory.NAME,
CommandBodyFields.STRASSE, AddressTestFactory.STREET,
CommandBodyFields.HAUSNUMMER, AddressTestFactory.HOUSE_NUMBER,
CommandBodyFields.PLZ, AddressTestFactory.ZIP_CODE,
CommandBodyFields.ORT, AddressTestFactory.CITY
);
@Nested
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment