@Test(expected = InstantiationException.class) public void throwsExceptionForParameterizedMetric_whenConfigIsWrong() throws Exception { final Map precisionAtFiveConfig = new HashMap(); precisionAtFiveConfig.put("class", "io.sease.rre.core.domain.metrics.impl.PrecisionAtK"); precisionAtFiveConfig.put("v", 5); final Map<String, Map> metricConfiguration = new HashMap<>(); metricConfiguration.put("pAt5", precisionAtFiveConfig); final MetricClassManager manager = new ParameterizedMetricClassManager(Arrays.asList(METRICS), metricConfiguration); manager.instantiateMetric("pAt5"); }
@Override public Metric instantiateMetric(String metricName) throws IllegalArgumentException, InstantiationException { final Metric metric; if (!metricConfiguration.containsKey(metricName)) { metric = super.instantiateMetric(metricName); } else { final String className = metricClasses.get(metricName); final Class<? extends Metric> klazz = findMetricClass(className); metric = instantiateClassWithConfiguration(klazz, metricConfiguration.get(metricName)); } return metric; }
ParameterizedMetricClassManager extends SimpleMetricClassManager implements MetricClassManager { @Override public Metric instantiateMetric(String metricName) throws IllegalArgumentException, InstantiationException { final Metric metric; if (!metricConfiguration.containsKey(metricName)) { metric = super.instantiateMetric(metricName); } else { final String className = metricClasses.get(metricName); final Class<? extends Metric> klazz = findMetricClass(className); metric = instantiateClassWithConfiguration(klazz, metricConfiguration.get(metricName)); } return metric; } }
ParameterizedMetricClassManager extends SimpleMetricClassManager implements MetricClassManager { @Override public Metric instantiateMetric(String metricName) throws IllegalArgumentException, InstantiationException { final Metric metric; if (!metricConfiguration.containsKey(metricName)) { metric = super.instantiateMetric(metricName); } else { final String className = metricClasses.get(metricName); final Class<? extends Metric> klazz = findMetricClass(className); metric = instantiateClassWithConfiguration(klazz, metricConfiguration.get(metricName)); } return metric; } @SuppressWarnings("rawtypes")  ParameterizedMetricClassManager(Collection<String> metricNames, Map<String, Map> metricConfiguration); }
ParameterizedMetricClassManager extends SimpleMetricClassManager implements MetricClassManager { @Override public Metric instantiateMetric(String metricName) throws IllegalArgumentException, InstantiationException { final Metric metric; if (!metricConfiguration.containsKey(metricName)) { metric = super.instantiateMetric(metricName); } else { final String className = metricClasses.get(metricName); final Class<? extends Metric> klazz = findMetricClass(className); metric = instantiateClassWithConfiguration(klazz, metricConfiguration.get(metricName)); } return metric; } @SuppressWarnings("rawtypes")  ParameterizedMetricClassManager(Collection<String> metricNames, Map<String, Map> metricConfiguration); @Override Metric instantiateMetric(String metricName); }
ParameterizedMetricClassManager extends SimpleMetricClassManager implements MetricClassManager { @Override public Metric instantiateMetric(String metricName) throws IllegalArgumentException, InstantiationException { final Metric metric; if (!metricConfiguration.containsKey(metricName)) { metric = super.instantiateMetric(metricName); } else { final String className = metricClasses.get(metricName); final Class<? extends Metric> klazz = findMetricClass(className); metric = instantiateClassWithConfiguration(klazz, metricConfiguration.get(metricName)); } return metric; } @SuppressWarnings("rawtypes")  ParameterizedMetricClassManager(Collection<String> metricNames, Map<String, Map> metricConfiguration); @Override Metric instantiateMetric(String metricName); static final String NAME_KEY; static final String MAXIMUM_GRADE_KEY; static final String MISSING_GRADE_KEY; }