/** * Mocks a call to {@link Config#GetValue(ConfigValues)) and returns the value it should return. * @return The mocked value */ private static String mockConfig(Version version, ConfigurationValues configurationValues) { String returnValue = RandomUtils.instance().nextString(10, true); ConfigValues configValues = ConfigValues.valueOf(configurationValues.name()); mcr.mockConfigValue(configValues, version, returnValue); return returnValue; }
@Test public void testDefaultValues() { ConfigValues[] values = ConfigValues.values(); for (ConfigValues curConfig : values) { if (curConfig == ConfigValues.Invalid) continue; Field configField = null; try { configField = ConfigValues.class.getField(curConfig.name()); } catch (Exception e) { Assert.fail("Failed to look up" + curConfig.name()); e.printStackTrace(); } OptionBehaviourAttribute behaviourAttr = configField.getAnnotation(OptionBehaviourAttribute.class); if (behaviourAttr != null && behaviourAttr.behaviour() == OptionBehaviour.Password) { continue; // no cert available for password decrypt } TypeConverterAttribute typeAttr = configField.getAnnotation(TypeConverterAttribute.class); assertNotNull( "The following field is missing the " + TypeConverterAttribute.class.getSimpleName() + " annotation: " + curConfig.name(), typeAttr); Class<?> c = typeAttr.value(); Object obj = config.getValue(curConfig, ConfigCommon.defaultConfigurationVersion); Assert.assertTrue("null return for " + curConfig.name(), obj != null); Assert.assertTrue( curConfig.name() + " is a " + obj.getClass().getName() + " but should be a " + c.getName(), c.isInstance(obj)); } }
/** get the configurable delay value from the DB according to given key */ private long getConfigurableDelay(String configurableDelayKeyName) { ConfigValues configDelay = ConfigValues.valueOf(configurableDelayKeyName); return Config.<Integer>getValue(configDelay).longValue(); }