From f193a2165d9261c2bd3413339c954a8bba829a93 Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Thu, 16 May 2019 10:01:43 +0200 Subject: Refactor and Test ConfigProfileGenerator Refactor - Add Builder to ConfigProfileGenerator. Reason: Constructor had too many arguments. - Move Conversion from Map to Config from ConfigProfileGenerator into dedicated 'ConvertMapToConfig' Class; Reason: I expect additional configuration properties and I don't want those changes to affect the ConfigProfileGenerator (or it's test cases) - Move Access to Spring's env into facade to simplify ConfigProfileGenerator. --- .../moazs/preprocess/MapToConfigConverter.java | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/at/gv/egiz/moazs/preprocess/MapToConfigConverter.java (limited to 'src/main/java/at/gv/egiz/moazs/preprocess/MapToConfigConverter.java') diff --git a/src/main/java/at/gv/egiz/moazs/preprocess/MapToConfigConverter.java b/src/main/java/at/gv/egiz/moazs/preprocess/MapToConfigConverter.java new file mode 100644 index 0000000..ef7cff1 --- /dev/null +++ b/src/main/java/at/gv/egiz/moazs/preprocess/MapToConfigConverter.java @@ -0,0 +1,29 @@ +package at.gv.egiz.moazs.preprocess; + +import at.gv.zustellung.app2mzs.xsd.ConfigType; +import org.springframework.stereotype.Component; + +import java.util.Map; + +import static at.gv.zustellung.app2mzs.xsd.ServerType.serverTypeBuilder; + +@Component +public class MapToConfigConverter { + + private static final String TNVZ_REQUEST_KEY = "perform-query-person-request"; + private static final String MSG_URL_KEY = "msg.url"; + + public ConfigType convert(Map values) { + var server = serverTypeBuilder() + .withZUSEUrlID(values.get(MSG_URL_KEY)) + .build(); + + Boolean performQueryPersonRequest = values.get(TNVZ_REQUEST_KEY) == null + ? null : Boolean.getBoolean(values.get(TNVZ_REQUEST_KEY)); + + return ConfigType.configTypeBuilder() + .withPerformQueryPersonRequest(performQueryPersonRequest) + .withServer(server) + .build(); + } +} -- cgit v1.2.3