RecipientRewriteTableConfiguration { public static RecipientRewriteTableConfiguration fromConfiguration(HierarchicalConfiguration<ImmutableNode> config) throws ConfigurationException { boolean recursive = config.getBoolean("recursiveMapping", RECURSIVE_MAPPING_ENABLED); int mappingLimit; if (recursive) { mappingLimit = config.getInt("mappingLimit", DEFAULT_ENABLED_MAPPING_LIMIT); checkMappingLimit(mappingLimit); } else { mappingLimit = DISABLED_MAPPING_LIMIT; } return new RecipientRewriteTableConfiguration(recursive, mappingLimit); } @VisibleForTesting  RecipientRewriteTableConfiguration(boolean recursive, int mappingLimit); static RecipientRewriteTableConfiguration fromConfiguration(HierarchicalConfiguration<ImmutableNode> config); int getMappingLimit(); boolean isRecursive(); @Override final boolean equals(Object other); @Override final int hashCode(); @Override String toString(); static final boolean RECURSIVE_MAPPING_ENABLED; static final int DEFAULT_ENABLED_MAPPING_LIMIT; static final int DISABLED_MAPPING_LIMIT; static final RecipientRewriteTableConfiguration DEFAULT_ENABLED; static final RecipientRewriteTableConfiguration DISABLED; }
@Test void negativeLimitShouldThrows() { BaseHierarchicalConfiguration configuration = new BaseHierarchicalConfiguration(); configuration.addProperty("recursiveMapping", "true"); configuration.addProperty("mappingLimit", -1); assertThatCode(() -> RecipientRewriteTableConfiguration.fromConfiguration(configuration)) .isInstanceOf(ConfigurationException.class); }