ConfigReader implements ConfigProperties { public ConfigReader readConfiguration() throws InterpreterPropertyException { for ( ExecutionConfigSource s : propertySources) { Map<ExecutionProperty, List<String>> propertyMap = new HashMap<>(); propertyMap = s.parseProperties(propertyMap, args); sourceToPropertiesMap.put(s, propertyMap); } mergeProperties(sourceToPropertiesMap); validateProperties(propertyMap); return this; } ConfigReader(List<ExecutionProperty> properties);  ConfigReader(List<ExecutionProperty> properties, String[] args); ConfigReader readConfiguration(); void setProperty(ExecutionProperty property, List<String> values); List<String> getValues(ExecutionProperty property); String getValue(ExecutionProperty property); boolean isSet(ExecutionProperty property); boolean isTrue(ExecutionProperty property);  }
@Test public void testCannotSetLessThanMinimumValues() { ExecutionProperty propertyWithMinValues = new TestProperty(TestConfigProperty.HANDLER_PACKAGES) { public int getMinValueCount() { return 2; } }; ConfigReader c = new ConfigReader(Collections.singletonList(propertyWithMinValues), new String[] { "-h", "onevalue" }); try { c.readConfiguration(); } catch (InterpreterPropertyException e) { assertTrue("contains At Least 2", e.getMessage().contains("At least 2 value(s) must be supplied")); return; } fail("Must complain when less than min vals set"); }
@Test public void testCannotSetMoreThanMaxValues() { ExecutionProperty propertyWithMinValues = new TestProperty(TestConfigProperty.HANDLER_PACKAGES) { public int getMaxValueCount() { return 1; } }; ConfigReader c = new ConfigReader(Collections.singletonList(propertyWithMinValues), new String[] { "-h", "onevalue", "twovalues" }); try { c.readConfiguration(); } catch (InterpreterPropertyException e) { assertTrue("contains At Most 1", e.getMessage().contains("At most 1 value(s) must be supplied")); return; } fail("Must complain when more than max vals set"); }
@Test public void mandatoryPropertyMustBeSet() { System.clearProperty(TestConfigProperty.FEATURE_PATHS.getSystemProperty()); String[] switches = new String[] { "-d" }; ConfigReader c = new ConfigReader(TestConfigProperty.getAll(), switches); try { c.readConfiguration(); } catch (InterpreterPropertyException e) { assertTrue(e.getMessage().contains("Mandatory property featurePaths was not set")); return; } fail("Must require mandatory -f property value"); }