### Question:
QuotaServer { public static <T extends Enum<T>> QuotaServer<T> createFromConfiguration( String quotaPrefix, Class<T> enumClass) { checkState(Configuration.isInitialized(), "configuration not initialized yet"); checkNotNull(enumClass); T[] enumValues = enumClass.getEnumConstants(); checkNotNull(enumValues, "class " + enumClass + " is not an enum class"); double defaultQps = Configuration.getValue( String.format(CONFIG_QUOTA_SERVER_DEFAULT_QPS_FORMAT, quotaPrefix), DEFAULT_QPS, Configuration.DOUBLE_PARSER) .get(); QuotaServer.Builder<T, QuotaServer<T>> builder = new QuotaServer.Builder<T, QuotaServer<T>>(enumClass); for (T operation : enumValues) { String configKey = String.format(CONFIG_QUOTA_SERVER_ENUM_KEY_FORMAT, quotaPrefix, operation); ConfigValue<Double> qps = Configuration.getValue(configKey, defaultQps, Configuration.DOUBLE_PARSER); if (qps.get() <= 0) { throw new InvalidConfigurationException( "QPS for " + configKey + " can not be 0 or negative. Configured as " + qps.get()); } builder.addQuota(operation, qps.get()); } return builder.build(); } private  QuotaServer(Builder<T, ? extends QuotaServer<T>> builder); double acquire(T operation); double getRate(T operation); static QuotaServer<T> createFromConfiguration(
      String quotaPrefix, Class<T> enumClass); static final double DEFAULT_QPS; }### Answer:
@Test public void testInvalidDefaultQpsFromConfig() { Properties properties = new Properties(); properties.put("quotaServer.ops.defaultQps", "5ABCD"); setupConfig.initConfig(properties); thrown.expect(InvalidConfigurationException.class); QuotaServer.<Operations>createFromConfiguration("ops", Operations.class); }
@Test public void testInvalidQpsFromConfig() { Properties properties = new Properties(); properties.put("quotaServer.ops.OP1", "2"); properties.put("quotaServer.ops.OP2", "XYZ"); setupConfig.initConfig(properties); thrown.expect(InvalidConfigurationException.class); QuotaServer.<Operations>createFromConfiguration("ops", Operations.class); }
@Test public void testNegQpsFromConfig() { Properties properties = new Properties(); properties.put("quotaServer.ops.OP1", "-2"); setupConfig.initConfig(properties); thrown.expect(InvalidConfigurationException.class); QuotaServer.<Operations>createFromConfiguration("ops", Operations.class); }