Polish "Improve property name in thrown Micrometer ValidationException"
See gh-21069
This commit is contained in:
@@ -34,8 +34,8 @@ class ValidationFailureAnalyzer extends AbstractFailureAnalyzer<ValidationExcept
|
||||
protected FailureAnalysis analyze(Throwable rootFailure, ValidationException cause) {
|
||||
StringBuilder description = new StringBuilder(String.format("Invalid Micrometer configuration detected:%n"));
|
||||
for (Invalid<?> failure : cause.getValidation().failures()) {
|
||||
description.append(String.format("%n - %s was '%s' but it %s",
|
||||
failure.getProperty(), failure.getValue(), failure.getMessage()));
|
||||
description.append(String.format("%n - %s was '%s' but it %s", failure.getProperty(), failure.getValue(),
|
||||
failure.getMessage()));
|
||||
}
|
||||
return new FailureAnalysis(description.toString(),
|
||||
"Update your application to correct the invalid configuration.", cause);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -43,8 +43,8 @@ class ValidationFailureAnalyzerTests {
|
||||
void analyzesMissingRequiredConfiguration() {
|
||||
FailureAnalysis analysis = new ValidationFailureAnalyzer()
|
||||
.analyze(createFailure(MissingAccountIdAndApiKeyConfiguration.class));
|
||||
assertThat(analysis.getCause().getMessage()).contains("management.metrics.export.newrelic.apiKey was 'null'");
|
||||
assertThat(analysis).isNotNull();
|
||||
assertThat(analysis.getCause().getMessage()).contains("management.metrics.export.newrelic.apiKey was 'null'");
|
||||
assertThat(analysis.getDescription()).isEqualTo(String.format("Invalid Micrometer configuration detected:%n%n"
|
||||
+ " - management.metrics.export.newrelic.apiKey was 'null' but it is required when publishing to Insights API%n"
|
||||
+ " - management.metrics.export.newrelic.accountId was 'null' but it is required when publishing to Insights API"));
|
||||
@@ -63,6 +63,7 @@ class ValidationFailureAnalyzerTests {
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Import(NewRelicProperties.class)
|
||||
static class MissingAccountIdAndApiKeyConfiguration {
|
||||
|
||||
@Bean
|
||||
NewRelicMeterRegistry meterRegistry(NewRelicProperties newRelicProperties) {
|
||||
return new NewRelicMeterRegistry(new NewRelicPropertiesConfigAdapter(newRelicProperties), Clock.SYSTEM);
|
||||
|
||||
Reference in New Issue
Block a user