Mercurial > stress-tester
changeset 908:5eb7806d3416
refactoring
author | Devel 1 |
---|---|
date | Wed, 18 Apr 2018 16:12:13 +0200 |
parents | 9ad946f81619 |
children | 57bec9c38e0d |
files | stress-tester/src/main/java/com/passus/st/config/TestJobConfigurator.java stress-tester/src/main/java/com/passus/st/project/ProjectConfigurator.java |
diffstat | 2 files changed, 25 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/config/TestJobConfigurator.java Wed Apr 18 14:39:38 2018 +0200 +++ b/stress-tester/src/main/java/com/passus/st/config/TestJobConfigurator.java Wed Apr 18 16:12:13 2018 +0200 @@ -24,6 +24,16 @@ private PluginFactory<DomainConfigurator> configuratorFactory = DomainConfiguratorFactory.getInstance(); + private final BiPredicate<String, DomainConfigurator> filter; + + public TestJobConfigurator() { + this(null); + } + + public TestJobConfigurator(BiPredicate<String, DomainConfigurator> filter) { + this.filter = filter; + } + public PluginFactory<DomainConfigurator> getConfiguratorFactory() { return configuratorFactory; } @@ -33,13 +43,11 @@ this.configuratorFactory = configuratorFactory; } - protected Map<String, DomainConfigurator> getDomainsConfigurator(Configuration config, Errors errors, - BiPredicate<String, DomainConfigurator> filter) { - return getDomainsConfigurator(config.getRootNode(), errors, filter); + protected Map<String, DomainConfigurator> getDomainsConfigurator(Configuration config, Errors errors) { + return getDomainsConfigurator(config.getRootNode(), errors); } - protected Map<String, DomainConfigurator> getDomainsConfigurator(CNode rootNode, Errors errors, - BiPredicate<String, DomainConfigurator> filter) { + protected Map<String, DomainConfigurator> getDomainsConfigurator(CNode rootNode, Errors errors) { if (!validateType(rootNode, NodeType.MAP, errors)) { return null; } @@ -71,9 +79,9 @@ return domainsConfigurator; } - protected void doValidate(Configuration config, Errors errors, ConfigurationContext context, - BiPredicate<String, DomainConfigurator> filter) { - Map<String, DomainConfigurator> configurators = getDomainsConfigurator(config, errors, filter); + @Override + public void validate(Configuration config, Errors errors, ConfigurationContext context) { + Map<String, DomainConfigurator> configurators = getDomainsConfigurator(config, errors); if (!errors.hasError()) { for (Entry<String, DomainConfigurator> entry : configurators.entrySet()) { String keyName = entry.getKey(); @@ -92,13 +100,8 @@ } @Override - public void validate(Configuration config, Errors errors, ConfigurationContext context) { - doValidate(config, errors, context, null); - } - - protected void doConfigure(Configuration config, Errors errors, ConfigurationContext context, - BiPredicate<String, DomainConfigurator> filter) { - Map<String, DomainConfigurator> configurators = getDomainsConfigurator(config, errors, filter); + public void configure(Configuration config, Errors errors, ConfigurationContext context) { + Map<String, DomainConfigurator> configurators = getDomainsConfigurator(config, errors); if (!errors.hasError()) { for (Entry<String, DomainConfigurator> entry : configurators.entrySet()) { String keyName = entry.getKey(); @@ -120,9 +123,4 @@ } } - @Override - public void configure(Configuration config, Errors errors, ConfigurationContext context) { - doConfigure(config, errors, context, null); - } - }
--- a/stress-tester/src/main/java/com/passus/st/project/ProjectConfigurator.java Wed Apr 18 14:39:38 2018 +0200 +++ b/stress-tester/src/main/java/com/passus/st/project/ProjectConfigurator.java Wed Apr 18 16:12:13 2018 +0200 @@ -13,13 +13,17 @@ public class ProjectConfigurator extends TestJobConfigurator { - private final BiPredicate<String, DomainConfigurator> projectKeysPredicate = (keyName, configurator) -> { + private static final BiPredicate<String, DomainConfigurator> PROJECT_KEYS_PREDICATE = (keyName, configurator) -> { return keyName != null && keyName.equals("name") || keyName.equals("active") || keyName.equals("description"); }; + public ProjectConfigurator() { + super(PROJECT_KEYS_PREDICATE); + } + @Override public void validate(Configuration config, Errors errors, ConfigurationContext context) { if (config.getString("name") == null) { @@ -27,12 +31,12 @@ return; } - super.doValidate(config, errors, context, projectKeysPredicate); + super.validate(config, errors, context); } @Override public void configure(Configuration config, Errors errors, ConfigurationContext context) { - super.doConfigure(config, errors, context, projectKeysPredicate); + super.configure(config, errors, context); if (!errors.hasError()) { String name = config.getString("name"); boolean active = config.getBoolean("active", true);