mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Polish "Test Micrometer config to property exposure"
See gh-33743
This commit is contained in:
parent
19e70055a5
commit
5c6a9122cb
@ -1,110 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2023 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.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.PropertiesConfigAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility to test that all Micrometer config values are exposed via properties and
|
|
||||||
* settable using the corresponding {@link PropertiesConfigAdapter} implementation.
|
|
||||||
*
|
|
||||||
* @author Mirko Sobeck
|
|
||||||
*/
|
|
||||||
public final class TestConfigsToPropertiesExposure {
|
|
||||||
|
|
||||||
private TestConfigsToPropertiesExposure() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final List<Class<?>> classesForPropertiesList = Arrays.asList(Boolean.class, Byte.class,
|
|
||||||
Character.class, Short.class, Integer.class, Long.class, Double.class, Float.class, String.class,
|
|
||||||
Duration.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Assertion to test if default methods of a given config are overridden by the
|
|
||||||
* adapter which implements it. This can be an indicator for micrometer config fields,
|
|
||||||
* that have been forgotten to expose via spring properties. Not overridden default
|
|
||||||
* methods in adapters are the most common cause of forgotten field exposure, because
|
|
||||||
* they do not for force an override.
|
|
||||||
* @param config micrometer config
|
|
||||||
* @param adapter adapter for properties {@link PropertiesConfigAdapter}
|
|
||||||
* @param excludedConfigMethods config methods that should be excluded for the
|
|
||||||
* assertion
|
|
||||||
*/
|
|
||||||
public static void assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(Class<?> config,
|
|
||||||
Class<? extends PropertiesConfigAdapter<?>> adapter, String... excludedConfigMethods) {
|
|
||||||
List<String> configDefaultMethodNames = Arrays.stream(config.getDeclaredMethods())
|
|
||||||
.filter((method) -> method.isDefault() && isSettableUsingProperties(method.getReturnType()))
|
|
||||||
.map(Method::getName).collect(Collectors.toList());
|
|
||||||
|
|
||||||
configDefaultMethodNames.removeAll(Arrays.stream(excludedConfigMethods).collect(Collectors.toList()));
|
|
||||||
List<String> notOverriddenDefaultMethods = new ArrayList<>(configDefaultMethodNames);
|
|
||||||
|
|
||||||
Class<?> currentClass = adapter;
|
|
||||||
// loop through adapter class and superclasses
|
|
||||||
// to find not overridden config methods
|
|
||||||
while (!Object.class.equals(currentClass)) {
|
|
||||||
List<String> overriddenClassDefaultMethods = Arrays.stream(currentClass.getDeclaredMethods())
|
|
||||||
.map(Method::getName).filter(configDefaultMethodNames::contains).collect(Collectors.toList());
|
|
||||||
|
|
||||||
notOverriddenDefaultMethods.removeAll(overriddenClassDefaultMethods);
|
|
||||||
currentClass = currentClass.getSuperclass();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notOverriddenDefaultMethods.size() >= 1) {
|
|
||||||
Assert.fail(
|
|
||||||
"Found config default methods that are not overridden by the related PropertiesConfigAdapter: \n"
|
|
||||||
+ notOverriddenDefaultMethods + "\n"
|
|
||||||
+ "This could be an indicator for not exposed properties fields.\n"
|
|
||||||
+ "Please check if the fields are meant to be exposed and if not, "
|
|
||||||
+ "exclude them from this test by providing them to the method.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Guess if a class can be set using properties. This will only catch the basic use
|
|
||||||
* cases regarding the micrometer configs to filter out methods that are not likely to
|
|
||||||
* be designed to be set via properties. <pre>
|
|
||||||
* isSettableUsingProperties(String.class) = true
|
|
||||||
* isSettableUsingProperties(boolean.class) = true
|
|
||||||
* isSettableUsingProperties(Object.class) = false
|
|
||||||
* </pre>
|
|
||||||
* @param clazz Class
|
|
||||||
* @return is likely to be settable using properties
|
|
||||||
*/
|
|
||||||
private static boolean isSettableUsingProperties(Class<?> clazz) {
|
|
||||||
if (Void.TYPE.equals(clazz)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clazz.isPrimitive()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return classesForPropertiesList.contains(clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -16,10 +16,8 @@
|
|||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.appoptics;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.appoptics;
|
||||||
|
|
||||||
import io.micrometer.appoptics.AppOpticsConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -32,6 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
class AppOpticsPropertiesConfigAdapterTests
|
class AppOpticsPropertiesConfigAdapterTests
|
||||||
extends StepRegistryPropertiesConfigAdapterTests<AppOpticsProperties, AppOpticsPropertiesConfigAdapter> {
|
extends StepRegistryPropertiesConfigAdapterTests<AppOpticsProperties, AppOpticsPropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
AppOpticsPropertiesConfigAdapterTests() {
|
||||||
|
super(AppOpticsPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AppOpticsProperties createProperties() {
|
protected AppOpticsProperties createProperties() {
|
||||||
return new AppOpticsProperties();
|
return new AppOpticsProperties();
|
||||||
@ -70,10 +72,4 @@ class AppOpticsPropertiesConfigAdapterTests
|
|||||||
assertThat(createConfigAdapter(properties).floorTimes()).isTrue();
|
assertThat(createConfigAdapter(properties).floorTimes()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void allDefaultConfigMethodsAreOverriddenByAtlasPropertiesConfigAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(AppOpticsConfig.class,
|
|
||||||
AppOpticsPropertiesConfigAdapter.class, "connectTimeout");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,9 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.atlas;
|
|||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import com.netflix.spectator.atlas.AtlasConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.AbstractPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -30,7 +29,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Mirko Sobeck
|
* @author Mirko Sobeck
|
||||||
*/
|
*/
|
||||||
class AtlasPropertiesConfigAdapterTests {
|
class AtlasPropertiesConfigAdapterTests
|
||||||
|
extends AbstractPropertiesConfigAdapterTests<AtlasProperties, AtlasPropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
AtlasPropertiesConfigAdapterTests() {
|
||||||
|
super(AtlasPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenPropertiesStepIsSetAdapterStepReturnsIt() {
|
void whenPropertiesStepIsSetAdapterStepReturnsIt() {
|
||||||
@ -134,10 +138,10 @@ class AtlasPropertiesConfigAdapterTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
@Override
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(AtlasConfig.class,
|
protected void adapterOverridesAllConfigMethods() {
|
||||||
AtlasPropertiesConfigAdapter.class, "lwcIgnorePublishStep", "initialPollingDelay", "autoStart",
|
adapterOverridesAllConfigMethodsExcept("autoStart", "commonTags", "debugRegistry", "publisher", "rollupPolicy",
|
||||||
"lwcStep", "validTagCharacters");
|
"validTagCharacters");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,8 @@
|
|||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.datadog;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.datadog;
|
||||||
|
|
||||||
import io.micrometer.datadog.DatadogConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -33,6 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
class DatadogPropertiesConfigAdapterTests
|
class DatadogPropertiesConfigAdapterTests
|
||||||
extends StepRegistryPropertiesConfigAdapterTests<DatadogProperties, DatadogPropertiesConfigAdapter> {
|
extends StepRegistryPropertiesConfigAdapterTests<DatadogProperties, DatadogPropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
DatadogPropertiesConfigAdapterTests() {
|
||||||
|
super(DatadogPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DatadogProperties createProperties() {
|
protected DatadogProperties createProperties() {
|
||||||
return new DatadogProperties();
|
return new DatadogProperties();
|
||||||
@ -78,10 +80,4 @@ class DatadogPropertiesConfigAdapterTests
|
|||||||
assertThat(createConfigAdapter(properties).uri()).isEqualTo("https://app.example.com/api/v1/series");
|
assertThat(createConfigAdapter(properties).uri()).isEqualTo("https://app.example.com/api/v1/series");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(DatadogConfig.class,
|
|
||||||
DatadogPropertiesConfigAdapter.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,9 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.dynatrace;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import io.micrometer.dynatrace.DynatraceApiVersion;
|
import io.micrometer.dynatrace.DynatraceApiVersion;
|
||||||
import io.micrometer.dynatrace.DynatraceConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.AbstractPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -32,7 +31,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @author Georg Pirklbauer
|
* @author Georg Pirklbauer
|
||||||
*/
|
*/
|
||||||
class DynatracePropertiesConfigAdapterTests {
|
class DynatracePropertiesConfigAdapterTests
|
||||||
|
extends AbstractPropertiesConfigAdapterTests<DynatraceProperties, DynatracePropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
DynatracePropertiesConfigAdapterTests() {
|
||||||
|
super(DynatracePropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenPropertiesUriIsSetAdapterUriReturnsIt() {
|
void whenPropertiesUriIsSetAdapterUriReturnsIt() {
|
||||||
@ -164,10 +168,4 @@ class DynatracePropertiesConfigAdapterTests {
|
|||||||
assertThat(properties.getGroup()).isNull();
|
assertThat(properties.getGroup()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(DynatraceConfig.class,
|
|
||||||
DynatracePropertiesConfigAdapter.class, "documentType");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,9 @@
|
|||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.elastic;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.elastic;
|
||||||
|
|
||||||
import io.micrometer.elastic.ElasticConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.AbstractPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -28,7 +27,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
*/
|
*/
|
||||||
class ElasticPropertiesConfigAdapterTests {
|
class ElasticPropertiesConfigAdapterTests
|
||||||
|
extends AbstractPropertiesConfigAdapterTests<ElasticProperties, ElasticPropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
ElasticPropertiesConfigAdapterTests() {
|
||||||
|
super(ElasticPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenPropertiesHostsIsSetAdapterHostsReturnsIt() {
|
void whenPropertiesHostsIsSetAdapterHostsReturnsIt() {
|
||||||
@ -100,10 +104,4 @@ class ElasticPropertiesConfigAdapterTests {
|
|||||||
assertThat(new ElasticPropertiesConfigAdapter(properties).apiKeyCredentials()).isEqualTo("secret");
|
assertThat(new ElasticPropertiesConfigAdapter(properties).apiKeyCredentials()).isEqualTo("secret");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(ElasticConfig.class,
|
|
||||||
ElasticPropertiesConfigAdapter.class, "documentType");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,9 @@ import java.time.Duration;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import info.ganglia.gmetric4j.gmetric.GMetric.UDPAddressingMode;
|
import info.ganglia.gmetric4j.gmetric.GMetric.UDPAddressingMode;
|
||||||
import io.micrometer.ganglia.GangliaConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.AbstractPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -32,7 +31,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Mirko Sobeck
|
* @author Mirko Sobeck
|
||||||
*/
|
*/
|
||||||
class GangliaPropertiesConfigAdapterTests {
|
class GangliaPropertiesConfigAdapterTests
|
||||||
|
extends AbstractPropertiesConfigAdapterTests<GangliaProperties, GangliaPropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
GangliaPropertiesConfigAdapterTests() {
|
||||||
|
super(GangliaPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenPropertiesEnabledIsSetAdapterEnabledReturnsIt() {
|
void whenPropertiesEnabledIsSetAdapterEnabledReturnsIt() {
|
||||||
@ -84,10 +88,4 @@ class GangliaPropertiesConfigAdapterTests {
|
|||||||
assertThat(new GangliaPropertiesConfigAdapter(properties).port()).isEqualTo(4242);
|
assertThat(new GangliaPropertiesConfigAdapter(properties).port()).isEqualTo(4242);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(GangliaConfig.class,
|
|
||||||
GangliaPropertiesConfigAdapter.class, "protocolVersion");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,10 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.graphite;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import io.micrometer.graphite.GraphiteConfig;
|
|
||||||
import io.micrometer.graphite.GraphiteProtocol;
|
import io.micrometer.graphite.GraphiteProtocol;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.AbstractPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -32,7 +31,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Mirko Sobeck
|
* @author Mirko Sobeck
|
||||||
*/
|
*/
|
||||||
class GraphitePropertiesConfigAdapterTests {
|
class GraphitePropertiesConfigAdapterTests
|
||||||
|
extends AbstractPropertiesConfigAdapterTests<GraphiteProperties, GraphitePropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
GraphitePropertiesConfigAdapterTests() {
|
||||||
|
super(GraphitePropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenPropertiesEnabledIsSetAdapterEnabledReturnsIt() {
|
void whenPropertiesEnabledIsSetAdapterEnabledReturnsIt() {
|
||||||
@ -97,10 +101,4 @@ class GraphitePropertiesConfigAdapterTests {
|
|||||||
assertThat(new GraphitePropertiesConfigAdapter(properties).tagsAsPrefix()).isEqualTo(new String[] { "worker" });
|
assertThat(new GraphitePropertiesConfigAdapter(properties).tagsAsPrefix()).isEqualTo(new String[] { "worker" });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(GraphiteConfig.class,
|
|
||||||
GraphitePropertiesConfigAdapter.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,9 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.humio;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import io.micrometer.humio.HumioConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.AbstractPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -30,7 +29,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
*/
|
*/
|
||||||
class HumioPropertiesConfigAdapterTests {
|
class HumioPropertiesConfigAdapterTests
|
||||||
|
extends AbstractPropertiesConfigAdapterTests<HumioProperties, HumioPropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
HumioPropertiesConfigAdapterTests() {
|
||||||
|
super(HumioPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenApiTokenIsSetAdapterApiTokenReturnsIt() {
|
void whenApiTokenIsSetAdapterApiTokenReturnsIt() {
|
||||||
@ -54,10 +58,4 @@ class HumioPropertiesConfigAdapterTests {
|
|||||||
assertThat(new HumioPropertiesConfigAdapter(properties).uri()).isEqualTo("https://humio.example.com");
|
assertThat(new HumioPropertiesConfigAdapter(properties).uri()).isEqualTo("https://humio.example.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(HumioConfig.class,
|
|
||||||
HumioPropertiesConfigAdapter.class, "connectTimeout");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -17,10 +17,9 @@
|
|||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.influx;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.influx;
|
||||||
|
|
||||||
import io.micrometer.influx.InfluxApiVersion;
|
import io.micrometer.influx.InfluxApiVersion;
|
||||||
import io.micrometer.influx.InfluxConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.AbstractPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -29,7 +28,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
*/
|
*/
|
||||||
class InfluxPropertiesConfigAdapterTests {
|
class InfluxPropertiesConfigAdapterTests
|
||||||
|
extends AbstractPropertiesConfigAdapterTests<InfluxProperties, InfluxPropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
InfluxPropertiesConfigAdapterTests() {
|
||||||
|
super(InfluxPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void adaptInfluxV1BasicConfig() {
|
void adaptInfluxV1BasicConfig() {
|
||||||
@ -61,10 +65,4 @@ class InfluxPropertiesConfigAdapterTests {
|
|||||||
assertThat(adapter.token()).isEqualTo("token");
|
assertThat(adapter.token()).isEqualTo("token");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(InfluxConfig.class,
|
|
||||||
InfluxPropertiesConfigAdapter.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,9 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.jmx;
|
|||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import io.micrometer.jmx.JmxConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.AbstractPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -30,7 +29,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Mirko Sobeck
|
* @author Mirko Sobeck
|
||||||
*/
|
*/
|
||||||
class JmxPropertiesConfigAdapterTests {
|
class JmxPropertiesConfigAdapterTests
|
||||||
|
extends AbstractPropertiesConfigAdapterTests<JmxProperties, JmxPropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
JmxPropertiesConfigAdapterTests() {
|
||||||
|
super(JmxPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenPropertiesStepIsSetAdapterStepReturnsIt() {
|
void whenPropertiesStepIsSetAdapterStepReturnsIt() {
|
||||||
@ -46,10 +50,4 @@ class JmxPropertiesConfigAdapterTests {
|
|||||||
assertThat(new JmxPropertiesConfigAdapter(properties).domain()).isEqualTo("abc");
|
assertThat(new JmxPropertiesConfigAdapter(properties).domain()).isEqualTo("abc");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(JmxConfig.class,
|
|
||||||
JmxPropertiesConfigAdapter.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,8 @@
|
|||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.kairos;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.kairos;
|
||||||
|
|
||||||
import io.micrometer.kairos.KairosConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -32,6 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
class KairosPropertiesConfigAdapterTests
|
class KairosPropertiesConfigAdapterTests
|
||||||
extends StepRegistryPropertiesConfigAdapterTests<KairosProperties, KairosPropertiesConfigAdapter> {
|
extends StepRegistryPropertiesConfigAdapterTests<KairosProperties, KairosPropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
KairosPropertiesConfigAdapterTests() {
|
||||||
|
super(KairosPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected KairosProperties createProperties() {
|
protected KairosProperties createProperties() {
|
||||||
return new KairosProperties();
|
return new KairosProperties();
|
||||||
@ -64,10 +66,4 @@ class KairosPropertiesConfigAdapterTests
|
|||||||
assertThat(createConfigAdapter(properties).password()).isEqualTo("secret");
|
assertThat(createConfigAdapter(properties).password()).isEqualTo("secret");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(KairosConfig.class,
|
|
||||||
KairosPropertiesConfigAdapter.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,8 @@
|
|||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.newrelic;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.newrelic;
|
||||||
|
|
||||||
import io.micrometer.newrelic.ClientProviderType;
|
import io.micrometer.newrelic.ClientProviderType;
|
||||||
import io.micrometer.newrelic.NewRelicConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -33,6 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
class NewRelicPropertiesConfigAdapterTests
|
class NewRelicPropertiesConfigAdapterTests
|
||||||
extends StepRegistryPropertiesConfigAdapterTests<NewRelicProperties, NewRelicPropertiesConfigAdapter> {
|
extends StepRegistryPropertiesConfigAdapterTests<NewRelicProperties, NewRelicPropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
NewRelicPropertiesConfigAdapterTests() {
|
||||||
|
super(NewRelicPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NewRelicProperties createProperties() {
|
protected NewRelicProperties createProperties() {
|
||||||
return new NewRelicProperties();
|
return new NewRelicProperties();
|
||||||
@ -85,10 +87,4 @@ class NewRelicPropertiesConfigAdapterTests
|
|||||||
assertThat(createConfigAdapter(properties).uri()).isEqualTo("https://example.newrelic.com");
|
assertThat(createConfigAdapter(properties).uri()).isEqualTo("https://example.newrelic.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(NewRelicConfig.class,
|
|
||||||
NewRelicPropertiesConfigAdapter.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,9 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import io.micrometer.prometheus.HistogramFlavor;
|
import io.micrometer.prometheus.HistogramFlavor;
|
||||||
import io.micrometer.prometheus.PrometheusConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.AbstractPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -31,7 +30,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Mirko Sobeck
|
* @author Mirko Sobeck
|
||||||
*/
|
*/
|
||||||
class PrometheusPropertiesConfigAdapterTests {
|
class PrometheusPropertiesConfigAdapterTests
|
||||||
|
extends AbstractPropertiesConfigAdapterTests<PrometheusProperties, PrometheusPropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
PrometheusPropertiesConfigAdapterTests() {
|
||||||
|
super(PrometheusPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenPropertiesDescriptionsIsSetAdapterDescriptionsReturnsIt() {
|
void whenPropertiesDescriptionsIsSetAdapterDescriptionsReturnsIt() {
|
||||||
@ -55,10 +59,4 @@ class PrometheusPropertiesConfigAdapterTests {
|
|||||||
assertThat(new PrometheusPropertiesConfigAdapter(properties).step()).isEqualTo(Duration.ofSeconds(30));
|
assertThat(new PrometheusPropertiesConfigAdapter(properties).step()).isEqualTo(Duration.ofSeconds(30));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(PrometheusConfig.class,
|
|
||||||
PrometheusPropertiesConfigAdapter.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2023 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.properties;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import io.micrometer.core.instrument.config.validate.Validated;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for testing properties config adapters.
|
||||||
|
*
|
||||||
|
* @param <P> the properties used by the adapter
|
||||||
|
* @param <A> the adapter under test
|
||||||
|
* @author Andy Wilkinson
|
||||||
|
* @author Mirko Sobeck
|
||||||
|
*/
|
||||||
|
public abstract class AbstractPropertiesConfigAdapterTests<P, A extends PropertiesConfigAdapter<P>> {
|
||||||
|
|
||||||
|
private final Class<? extends A> adapter;
|
||||||
|
|
||||||
|
protected AbstractPropertiesConfigAdapterTests(Class<? extends A> adapter) {
|
||||||
|
this.adapter = adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
protected void adapterOverridesAllConfigMethods() {
|
||||||
|
adapterOverridesAllConfigMethodsExcept();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void adapterOverridesAllConfigMethodsExcept(String... nonConfigMethods) {
|
||||||
|
Class<?> config = findImplementedConfig();
|
||||||
|
Set<String> expectedConfigMethodNames = Arrays.stream(config.getDeclaredMethods())
|
||||||
|
.filter(Method::isDefault)
|
||||||
|
.filter(this::hasNoParameters)
|
||||||
|
.filter(this::isNotValidationMethod)
|
||||||
|
.filter(this::isNotDeprecated)
|
||||||
|
.map(Method::getName)
|
||||||
|
.collect(Collectors.toCollection(TreeSet::new));
|
||||||
|
expectedConfigMethodNames.removeAll(Arrays.asList(nonConfigMethods));
|
||||||
|
Set<String> actualConfigMethodNames = new TreeSet<>();
|
||||||
|
Class<?> currentClass = this.adapter;
|
||||||
|
while (!Object.class.equals(currentClass)) {
|
||||||
|
actualConfigMethodNames.addAll(Arrays.stream(currentClass.getDeclaredMethods())
|
||||||
|
.map(Method::getName)
|
||||||
|
.filter(expectedConfigMethodNames::contains)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
currentClass = currentClass.getSuperclass();
|
||||||
|
}
|
||||||
|
assertThat(actualConfigMethodNames).containsExactlyInAnyOrderElementsOf(expectedConfigMethodNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Class<?> findImplementedConfig() {
|
||||||
|
Class<?>[] interfaces = this.adapter.getInterfaces();
|
||||||
|
if (interfaces.length == 1) {
|
||||||
|
return interfaces[0];
|
||||||
|
}
|
||||||
|
throw new IllegalStateException(this.adapter + " is not a config implementation");
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isNotDeprecated(Method method) {
|
||||||
|
return !AnnotatedElementUtils.hasAnnotation(method, Deprecated.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasNoParameters(Method method) {
|
||||||
|
return method.getParameterCount() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isNotValidationMethod(Method method) {
|
||||||
|
return !Validated.class.equals(method.getReturnType());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -30,7 +30,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @author Artsiom Yudovin
|
* @author Artsiom Yudovin
|
||||||
*/
|
*/
|
||||||
public abstract class PushRegistryPropertiesConfigAdapterTests<P extends PushRegistryProperties, A extends PushRegistryPropertiesConfigAdapter<P>> {
|
public abstract class PushRegistryPropertiesConfigAdapterTests<P extends PushRegistryProperties, A extends PushRegistryPropertiesConfigAdapter<P>>
|
||||||
|
extends AbstractPropertiesConfigAdapterTests<P, PropertiesConfigAdapter<P>> {
|
||||||
|
|
||||||
|
protected PushRegistryPropertiesConfigAdapterTests(Class<A> adapter) {
|
||||||
|
super(adapter);
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract P createProperties();
|
protected abstract P createProperties();
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -27,4 +27,8 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.properties
|
|||||||
public abstract class StepRegistryPropertiesConfigAdapterTests<P extends StepRegistryProperties, A extends StepRegistryPropertiesConfigAdapter<P>>
|
public abstract class StepRegistryPropertiesConfigAdapterTests<P extends StepRegistryProperties, A extends StepRegistryPropertiesConfigAdapter<P>>
|
||||||
extends PushRegistryPropertiesConfigAdapterTests<P, A> {
|
extends PushRegistryPropertiesConfigAdapterTests<P, A> {
|
||||||
|
|
||||||
|
protected StepRegistryPropertiesConfigAdapterTests(Class<A> adapter) {
|
||||||
|
super(adapter);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,8 @@
|
|||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx;
|
||||||
|
|
||||||
import io.micrometer.signalfx.SignalFxConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx.SignalFxProperties.HistogramType;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx.SignalFxProperties.HistogramType;
|
||||||
|
|
||||||
@ -33,6 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
class SignalFxPropertiesConfigAdapterTests
|
class SignalFxPropertiesConfigAdapterTests
|
||||||
extends StepRegistryPropertiesConfigAdapterTests<SignalFxProperties, SignalFxPropertiesConfigAdapter> {
|
extends StepRegistryPropertiesConfigAdapterTests<SignalFxProperties, SignalFxPropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
protected SignalFxPropertiesConfigAdapterTests() {
|
||||||
|
super(SignalFxPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SignalFxProperties createProperties() {
|
protected SignalFxProperties createProperties() {
|
||||||
SignalFxProperties signalFxProperties = new SignalFxProperties();
|
SignalFxProperties signalFxProperties = new SignalFxProperties();
|
||||||
@ -70,11 +72,6 @@ class SignalFxPropertiesConfigAdapterTests
|
|||||||
SignalFxProperties properties = createProperties();
|
SignalFxProperties properties = createProperties();
|
||||||
properties.setPublishedHistogramType(HistogramType.CUMULATIVE);
|
properties.setPublishedHistogramType(HistogramType.CUMULATIVE);
|
||||||
assertThat(createConfigAdapter(properties).publishCumulativeHistogram()).isTrue();
|
assertThat(createConfigAdapter(properties).publishCumulativeHistogram()).isTrue();
|
||||||
|
|
||||||
@Test
|
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(SignalFxConfig.class,
|
|
||||||
SignalFxPropertiesConfigAdapter.class, "publishDeltaHistogram", "publishCumulativeHistogram");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,9 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.simple;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import io.micrometer.core.instrument.simple.CountingMode;
|
import io.micrometer.core.instrument.simple.CountingMode;
|
||||||
import io.micrometer.core.instrument.simple.SimpleConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.AbstractPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -31,7 +30,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Mirko Sobeck
|
* @author Mirko Sobeck
|
||||||
*/
|
*/
|
||||||
class SimplePropertiesConfigAdapterTests {
|
class SimplePropertiesConfigAdapterTests
|
||||||
|
extends AbstractPropertiesConfigAdapterTests<SimpleProperties, SimplePropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
SimplePropertiesConfigAdapterTests() {
|
||||||
|
super(SimplePropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenPropertiesStepIsSetAdapterStepReturnsIt() {
|
void whenPropertiesStepIsSetAdapterStepReturnsIt() {
|
||||||
@ -47,10 +51,4 @@ class SimplePropertiesConfigAdapterTests {
|
|||||||
assertThat(new SimplePropertiesConfigAdapter(properties).mode()).isEqualTo(CountingMode.STEP);
|
assertThat(new SimplePropertiesConfigAdapter(properties).mode()).isEqualTo(CountingMode.STEP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(SimpleConfig.class,
|
|
||||||
SimplePropertiesConfigAdapter.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,9 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.stackdrive
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import io.micrometer.stackdriver.StackdriverConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.AbstractPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -31,7 +30,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Johannes Graf
|
* @author Johannes Graf
|
||||||
*/
|
*/
|
||||||
class StackdriverPropertiesConfigAdapterTests {
|
class StackdriverPropertiesConfigAdapterTests
|
||||||
|
extends AbstractPropertiesConfigAdapterTests<StackdriverProperties, StackdriverPropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
StackdriverPropertiesConfigAdapterTests() {
|
||||||
|
super(StackdriverPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenPropertiesProjectIdIsSetAdapterProjectIdReturnsIt() {
|
void whenPropertiesProjectIdIsSetAdapterProjectIdReturnsIt() {
|
||||||
@ -66,9 +70,9 @@ class StackdriverPropertiesConfigAdapterTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
@Override
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(StackdriverConfig.class,
|
protected void adapterOverridesAllConfigMethods() {
|
||||||
StackdriverPropertiesConfigAdapter.class, "metricTypePrefix");
|
adapterOverridesAllConfigMethodsExcept("credentials");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,11 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.statsd;
|
|||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import io.micrometer.statsd.StatsdConfig;
|
|
||||||
import io.micrometer.statsd.StatsdFlavor;
|
import io.micrometer.statsd.StatsdFlavor;
|
||||||
import io.micrometer.statsd.StatsdProtocol;
|
import io.micrometer.statsd.StatsdProtocol;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.AbstractPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -32,7 +31,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Johnny Lim
|
* @author Johnny Lim
|
||||||
*/
|
*/
|
||||||
class StatsdPropertiesConfigAdapterTests {
|
class StatsdPropertiesConfigAdapterTests
|
||||||
|
extends AbstractPropertiesConfigAdapterTests<StatsdProperties, StatsdPropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
protected StatsdPropertiesConfigAdapterTests() {
|
||||||
|
super(StatsdPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenPropertiesEnabledIsSetAdapterEnabledReturnsIt() {
|
void whenPropertiesEnabledIsSetAdapterEnabledReturnsIt() {
|
||||||
@ -107,10 +111,4 @@ class StatsdPropertiesConfigAdapterTests {
|
|||||||
assertThat(new StatsdPropertiesConfigAdapter(properties).buffered()).isEqualTo(properties.isBuffered());
|
assertThat(new StatsdPropertiesConfigAdapter(properties).buffered()).isEqualTo(properties.isBuffered());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(StatsdConfig.class,
|
|
||||||
StatsdPropertiesConfigAdapter.class, "queueSize");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,8 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.wavefront;
|
|||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import io.micrometer.wavefront.WavefrontConfig;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.TestConfigsToPropertiesExposure;
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.PushRegistryPropertiesConfigAdapterTests;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.PushRegistryPropertiesConfigAdapterTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -34,6 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
class WavefrontPropertiesConfigAdapterTests
|
class WavefrontPropertiesConfigAdapterTests
|
||||||
extends PushRegistryPropertiesConfigAdapterTests<WavefrontProperties, WavefrontPropertiesConfigAdapter> {
|
extends PushRegistryPropertiesConfigAdapterTests<WavefrontProperties, WavefrontPropertiesConfigAdapter> {
|
||||||
|
|
||||||
|
protected WavefrontPropertiesConfigAdapterTests() {
|
||||||
|
super(WavefrontPropertiesConfigAdapter.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WavefrontProperties createProperties() {
|
protected WavefrontProperties createProperties() {
|
||||||
return new WavefrontProperties();
|
return new WavefrontProperties();
|
||||||
@ -93,11 +95,4 @@ class WavefrontPropertiesConfigAdapterTests
|
|||||||
assertThat(createConfigAdapter(properties).reportDayDistribution()).isTrue();
|
assertThat(createConfigAdapter(properties).reportDayDistribution()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void allConfigDefaultMethodsAreOverriddenByAdapter() {
|
|
||||||
TestConfigsToPropertiesExposure.assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(WavefrontConfig.class,
|
|
||||||
WavefrontPropertiesConfigAdapter.class, "distributionPort", "reportMinuteDistribution",
|
|
||||||
"reportHourDistribution", "reportDayDistribution");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user