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
No related branches found
No related tags found
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; ...@@ -34,18 +34,27 @@ import de.ozgcloud.command.Command;
@Mapper(imports = MapUtils.class) @Mapper(imports = MapUtils.class)
interface ForwardingRequestMapper { 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 = "version", source = "relationVersion")
@Mapping(target = "organisationEinheit", source = "bodyObject") @Mapping(target = "organisationEinheit", source = "bodyObject")
ForwardingRequest fromCommand(Command command); ForwardingRequest fromCommand(Command command);
@Mapping(target = "id", expression = "java(MapUtils.getString(body, \"organisationEinheitId\"))") @Mapping(target = "id", expression = "java(MapUtils.getString(body, CommandBodyFields.ORGANISATION_EINHEIT_ID))")
@Mapping(target = "name", expression = "java(MapUtils.getString(body, \"name\"))") @Mapping(target = "name", expression = "java(MapUtils.getString(body, CommandBodyFields.NAME))")
@Mapping(target = "address", source = ".") @Mapping(target = "address", source = ".")
OrganisationEinheit toOrganisationEinheit(Map<String, Object> body); OrganisationEinheit toOrganisationEinheit(Map<String, Object> body);
@Mapping(target = "street", expression = "java(MapUtils.getString(body, \"strasse\"))") @Mapping(target = "street", expression = "java(MapUtils.getString(body, CommandBodyFields.STRASSE))")
@Mapping(target = "houseNumber", expression = "java(MapUtils.getString(body, \"hausnummer\"))") @Mapping(target = "houseNumber", expression = "java(MapUtils.getString(body, CommandBodyFields.HAUSNUMMER))")
@Mapping(target = "zipCode", expression = "java(MapUtils.getString(body, \"plz\"))") @Mapping(target = "zipCode", expression = "java(MapUtils.getString(body, CommandBodyFields.PLZ))")
@Mapping(target = "city", expression = "java(MapUtils.getString(body, \"ort\"))") @Mapping(target = "city", expression = "java(MapUtils.getString(body, CommandBodyFields.ORT))")
Address toAddress(Map<String, Object> body); Address toAddress(Map<String, Object> body);
} }
...@@ -35,18 +35,19 @@ import org.mapstruct.factory.Mappers; ...@@ -35,18 +35,19 @@ import org.mapstruct.factory.Mappers;
import org.mockito.Spy; import org.mockito.Spy;
import de.ozgcloud.vorgang.command.CommandTestFactory; import de.ozgcloud.vorgang.command.CommandTestFactory;
import de.ozgcloud.vorgang.vorgang.redirect.ForwardingRequestMapper.CommandBodyFields;
class ForwardingRequestMapperTest { class ForwardingRequestMapperTest {
@Spy @Spy
private ForwardingRequestMapper mapper = Mappers.getMapper(ForwardingRequestMapper.class); private ForwardingRequestMapper mapper = Mappers.getMapper(ForwardingRequestMapper.class);
private final Map<String, Object> bodyObject = Map.of( private final Map<String, Object> bodyObject = Map.of(
"organisationEinheitId", OrganisationEinheitTestFactory.ID, CommandBodyFields.ORGANISATION_EINHEIT_ID, OrganisationEinheitTestFactory.ID,
"name", OrganisationEinheitTestFactory.NAME, CommandBodyFields.NAME, OrganisationEinheitTestFactory.NAME,
"strasse", AddressTestFactory.STREET, CommandBodyFields.STRASSE, AddressTestFactory.STREET,
"hausnummer", AddressTestFactory.HOUSE_NUMBER, CommandBodyFields.HAUSNUMMER, AddressTestFactory.HOUSE_NUMBER,
"plz", AddressTestFactory.ZIP_CODE, CommandBodyFields.PLZ, AddressTestFactory.ZIP_CODE,
"ort", AddressTestFactory.CITY CommandBodyFields.ORT, AddressTestFactory.CITY
); );
@Nested @Nested
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment