diff options
author | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-05-16 10:01:43 +0200 |
---|---|---|
committer | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-05-16 10:01:43 +0200 |
commit | f193a2165d9261c2bd3413339c954a8bba829a93 (patch) | |
tree | 79595af29ba8c74f1abf79b213367e9d9b515078 /src/main/java/at/gv/egiz/moazs/config | |
parent | 5e6304ee003285793c0992a81e424969a2a6af88 (diff) | |
download | moa-zs-f193a2165d9261c2bd3413339c954a8bba829a93.tar.gz moa-zs-f193a2165d9261c2bd3413339c954a8bba829a93.tar.bz2 moa-zs-f193a2165d9261c2bd3413339c954a8bba829a93.zip |
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.
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/config')
-rw-r--r-- | src/main/java/at/gv/egiz/moazs/config/DeliveryRequestAugmenterConfig.java | 33 | ||||
-rw-r--r-- | src/main/java/at/gv/egiz/moazs/config/PreprocessConfig.java | 43 |
2 files changed, 43 insertions, 33 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/config/DeliveryRequestAugmenterConfig.java b/src/main/java/at/gv/egiz/moazs/config/DeliveryRequestAugmenterConfig.java deleted file mode 100644 index 01d13f5..0000000 --- a/src/main/java/at/gv/egiz/moazs/config/DeliveryRequestAugmenterConfig.java +++ /dev/null @@ -1,33 +0,0 @@ -package at.gv.egiz.moazs.config; - -import at.gv.egiz.moazs.preprocess.ConfigProfileGenerator; -import at.gv.egiz.moazs.preprocess.ConfigProfileMerger; -import at.gv.egiz.moazs.preprocess.ConfigProfileValidator; -import at.gv.zustellung.app2mzs.xsd.ConfigType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.ConfigurableEnvironment; - -import java.util.Map; - -@Configuration -public class DeliveryRequestAugmenterConfig { - - @Bean - @Autowired - public Map<String, ConfigType> deliveryRequestConfigs(ConfigProfileGenerator generator) { - return generator.generate(); - } - - @Value("${verify-completeness-of-default-delivery-request-configuration:true}") - private boolean verifyCompletenessOfDefaultConfiguration; - - @Bean - @Autowired - public ConfigProfileGenerator configProfileGenerator(ConfigurableEnvironment env, ConfigProfileMerger merger, ConfigProfileValidator validator) { - return new ConfigProfileGenerator(env, merger, verifyCompletenessOfDefaultConfiguration, validator); - } - -} diff --git a/src/main/java/at/gv/egiz/moazs/config/PreprocessConfig.java b/src/main/java/at/gv/egiz/moazs/config/PreprocessConfig.java new file mode 100644 index 0000000..ce40691 --- /dev/null +++ b/src/main/java/at/gv/egiz/moazs/config/PreprocessConfig.java @@ -0,0 +1,43 @@ +package at.gv.egiz.moazs.config; + +import at.gv.egiz.moazs.preprocess.*; +import at.gv.zustellung.app2mzs.xsd.ConfigType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Map; + +import static at.gv.egiz.moazs.preprocess.ConfigProfileGenerator.configProfileGeneratorBuilder; + +@Configuration +public class PreprocessConfig { + + @Bean + @Autowired + public Map<String, ConfigType> deliveryRequestConfigs(ConfigProfileGenerator generator) { + return generator.generate(); + } + + @Value("${verify-completeness-of-default-delivery-request-configuration:true}") + private boolean verifyCompletenessOfDefaultConfiguration; + + @Bean + @Autowired + public ConfigProfileGenerator configProfileGenerator( + SpringPropertiesFacade properties, + MapToConfigConverter converter, + ConfigProfileValidator validator, + ConfigProfileMerger merger) { + + return configProfileGeneratorBuilder() + .withProperties(properties) + .withConverter(converter) + .withValidator(validator) + .withMerger(merger) + .withVerifyCompletenessOfDefaultConfiguration(verifyCompletenessOfDefaultConfiguration) + .build(); + } + +} |