}
private void validateAddMeasure(Metric metric) {
- checkArgument(measureComputer.getOutputMetrics().contains(metric.getKey()), "Only metrics in %s can be used to add measures", measureComputer.getOutputMetrics());
+ checkArgument(measureComputer.getOutputMetrics().contains(metric.getKey()), "Only metrics in %s can be used to add measures. Metric '%s' is not allowed.",
+ measureComputer.getOutputMetrics(), metric.getKey());
if (measureRepository.getRawMeasure(internalComponent, metric).isPresent()) {
throw new UnsupportedOperationException(String.format("A measure on metric '%s' already exists on component '%s'", metric.getKey(), internalComponent.getKey()));
}
@Test
public void fail_with_IAE_when_add_measure_is_called_on_metric_not_in_output_list() throws Exception {
thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Only metrics in [int_metric_key] can be used to add measures");
+ thrown.expectMessage("Only metrics in [int_metric_key] can be used to add measures. Metric 'double_metric_key' is not allowed.");
MeasureComputer.Implementation.Context underTest = newContext(PROJECT_REF, of(NCLOC_KEY), of(INT_METRIC_KEY));
underTest.addMeasure(DOUBLE_METRIC_KEY, 10);
}
private void validateAddMeasure(String metricKey) {
- checkArgument(measureComputer.getOutputMetrics().contains(metricKey), "Only metrics in %s can be used to add measures", measureComputer.getOutputMetrics());
+ checkArgument(measureComputer.getOutputMetrics().contains(metricKey), "Only metrics in %s can be used to add measures. Metric '%s' is not allowed.",
+ measureComputer.getOutputMetrics(), metricKey);
if (componentMeasureByMetricKey.get(metricKey) != null) {
throw new UnsupportedOperationException(String.format("A measure on metric '%s' already exists", metricKey));
}