11 changed files with 674 additions and 8 deletions
@ -0,0 +1,119 @@
@@ -0,0 +1,119 @@
|
||||
/* |
||||
* 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.atlas; |
||||
|
||||
import java.time.Duration; |
||||
|
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
/** |
||||
* Tests for {@link AtlasPropertiesConfigAdapter}. |
||||
* |
||||
* @author Mirko Sobeck |
||||
*/ |
||||
class AtlasPropertiesConfigAdapterTests { |
||||
|
||||
@Test |
||||
void whenPropertiesStepIsSetAdapterStepReturnsIt() { |
||||
AtlasProperties properties = new AtlasProperties(); |
||||
properties.setStep(Duration.ofMinutes(15)); |
||||
assertThat(new AtlasPropertiesConfigAdapter(properties).step()).isEqualTo(Duration.ofMinutes(15)); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesEnabledIsSetAdapterEnabledReturnsIt() { |
||||
AtlasProperties properties = new AtlasProperties(); |
||||
properties.setEnabled(false); |
||||
assertThat(new AtlasPropertiesConfigAdapter(properties).enabled()).isFalse(); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesConnectTimeoutIsSetAdapterConnectTimeoutReturnsIt() { |
||||
AtlasProperties properties = new AtlasProperties(); |
||||
properties.setConnectTimeout(Duration.ofSeconds(12)); |
||||
assertThat(new AtlasPropertiesConfigAdapter(properties).connectTimeout()).isEqualTo(Duration.ofSeconds(12)); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesReadTimeoutIsSetAdapterReadTimeoutReturnsIt() { |
||||
AtlasProperties properties = new AtlasProperties(); |
||||
properties.setReadTimeout(Duration.ofSeconds(42)); |
||||
assertThat(new AtlasPropertiesConfigAdapter(properties).readTimeout()).isEqualTo(Duration.ofSeconds(42)); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesNumThreadsIsSetAdapterNumThreadsReturnsIt() { |
||||
AtlasProperties properties = new AtlasProperties(); |
||||
properties.setNumThreads(8); |
||||
assertThat(new AtlasPropertiesConfigAdapter(properties).numThreads()).isEqualTo(8); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesBatchSizeIsSetAdapterBatchSizeReturnsIt() { |
||||
AtlasProperties properties = new AtlasProperties(); |
||||
properties.setBatchSize(10042); |
||||
assertThat(new AtlasPropertiesConfigAdapter(properties).batchSize()).isEqualTo(10042); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesUriIsSetAdapterUriReturnsIt() { |
||||
AtlasProperties properties = new AtlasProperties(); |
||||
properties.setUri("https://atlas.example.com"); |
||||
assertThat(new AtlasPropertiesConfigAdapter(properties).uri()).isEqualTo("https://atlas.example.com"); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesLwcEnabledIsSetAdapterLwcEnabledReturnsIt() { |
||||
AtlasProperties properties = new AtlasProperties(); |
||||
properties.setLwcEnabled(true); |
||||
assertThat(new AtlasPropertiesConfigAdapter(properties).lwcEnabled()).isTrue(); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesConfigRefreshFrequencyIsSetAdapterConfigRefreshFrequencyReturnsIt() { |
||||
AtlasProperties properties = new AtlasProperties(); |
||||
properties.setConfigRefreshFrequency(Duration.ofMinutes(5)); |
||||
assertThat(new AtlasPropertiesConfigAdapter(properties).configRefreshFrequency()) |
||||
.isEqualTo(Duration.ofMinutes(5)); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesConfigTimeToLiveIsSetAdapterConfigTTLReturnsIt() { |
||||
AtlasProperties properties = new AtlasProperties(); |
||||
properties.setConfigTimeToLive(Duration.ofMinutes(6)); |
||||
assertThat(new AtlasPropertiesConfigAdapter(properties).configTTL()).isEqualTo(Duration.ofMinutes(6)); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesConfigUriIsSetAdapterConfigUriReturnsIt() { |
||||
AtlasProperties properties = new AtlasProperties(); |
||||
properties.setConfigUri("https://atlas.example.com/config"); |
||||
assertThat(new AtlasPropertiesConfigAdapter(properties).configUri()) |
||||
.isEqualTo("https://atlas.example.com/config"); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesEvalUriIsSetAdapterEvalUriReturnsIt() { |
||||
AtlasProperties properties = new AtlasProperties(); |
||||
properties.setEvalUri("https://atlas.example.com/evaluate"); |
||||
assertThat(new AtlasPropertiesConfigAdapter(properties).evalUri()) |
||||
.isEqualTo("https://atlas.example.com/evaluate"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,84 @@
@@ -0,0 +1,84 @@
|
||||
/* |
||||
* 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.ganglia; |
||||
|
||||
import java.time.Duration; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
import info.ganglia.gmetric4j.gmetric.GMetric.UDPAddressingMode; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
/** |
||||
* Tests for {@link GangliaPropertiesConfigAdapter}. |
||||
* |
||||
* @author Mirko Sobeck |
||||
*/ |
||||
class GangliaPropertiesConfigAdapterTests { |
||||
|
||||
@Test |
||||
void whenPropertiesEnabledIsSetAdapterEnabledReturnsIt() { |
||||
GangliaProperties properties = new GangliaProperties(); |
||||
properties.setEnabled(false); |
||||
assertThat(new GangliaPropertiesConfigAdapter(properties).enabled()).isFalse(); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesStepIsSetAdapterStepReturnsIt() { |
||||
GangliaProperties properties = new GangliaProperties(); |
||||
properties.setStep(Duration.ofMinutes(15)); |
||||
assertThat(new GangliaPropertiesConfigAdapter(properties).step()).isEqualTo(Duration.ofMinutes(15)); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesDurationUnitsIsSetAdapterDurationUnitsReturnsIt() { |
||||
GangliaProperties properties = new GangliaProperties(); |
||||
properties.setDurationUnits(TimeUnit.MINUTES); |
||||
assertThat(new GangliaPropertiesConfigAdapter(properties).durationUnits()).isEqualTo(TimeUnit.MINUTES); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesAddressingModeIsSetAdapterAddressingModeReturnsIt() { |
||||
GangliaProperties properties = new GangliaProperties(); |
||||
properties.setAddressingMode(UDPAddressingMode.UNICAST); |
||||
assertThat(new GangliaPropertiesConfigAdapter(properties).addressingMode()) |
||||
.isEqualTo(UDPAddressingMode.UNICAST); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesTimeToLiveIsSetAdapterTtlReturnsIt() { |
||||
GangliaProperties properties = new GangliaProperties(); |
||||
properties.setTimeToLive(2); |
||||
assertThat(new GangliaPropertiesConfigAdapter(properties).ttl()).isEqualTo(2); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesHostIsSetAdapterHostReturnsIt() { |
||||
GangliaProperties properties = new GangliaProperties(); |
||||
properties.setHost("node"); |
||||
assertThat(new GangliaPropertiesConfigAdapter(properties).host()).isEqualTo("node"); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesPortIsSetAdapterPortReturnsIt() { |
||||
GangliaProperties properties = new GangliaProperties(); |
||||
properties.setPort(4242); |
||||
assertThat(new GangliaPropertiesConfigAdapter(properties).port()).isEqualTo(4242); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,97 @@
@@ -0,0 +1,97 @@
|
||||
/* |
||||
* 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.graphite; |
||||
|
||||
import java.time.Duration; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
import io.micrometer.graphite.GraphiteProtocol; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
/** |
||||
* Tests for {@link GraphitePropertiesConfigAdapter}. |
||||
* |
||||
* @author Mirko Sobeck |
||||
*/ |
||||
class GraphitePropertiesConfigAdapterTests { |
||||
|
||||
@Test |
||||
void whenPropertiesEnabledIsSetAdapterEnabledReturnsIt() { |
||||
GraphiteProperties properties = new GraphiteProperties(); |
||||
properties.setEnabled(false); |
||||
assertThat(new GraphitePropertiesConfigAdapter(properties).enabled()).isFalse(); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesStepIsSetAdapterStepReturnsIt() { |
||||
GraphiteProperties properties = new GraphiteProperties(); |
||||
properties.setStep(Duration.ofMinutes(15)); |
||||
assertThat(new GraphitePropertiesConfigAdapter(properties).step()).isEqualTo(Duration.ofMinutes(15)); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesRateUnitsIsSetAdapterRateUnitsReturnsIt() { |
||||
GraphiteProperties properties = new GraphiteProperties(); |
||||
properties.setRateUnits(TimeUnit.MINUTES); |
||||
assertThat(new GraphitePropertiesConfigAdapter(properties).rateUnits()).isEqualTo(TimeUnit.MINUTES); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesDurationUnitsIsSetAdapterDurationUnitsReturnsIt() { |
||||
GraphiteProperties properties = new GraphiteProperties(); |
||||
properties.setRateUnits(TimeUnit.MINUTES); |
||||
assertThat(new GraphitePropertiesConfigAdapter(properties).rateUnits()).isEqualTo(TimeUnit.MINUTES); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesHostIsSetAdapterHostReturnsIt() { |
||||
GraphiteProperties properties = new GraphiteProperties(); |
||||
properties.setHost("node"); |
||||
assertThat(new GraphitePropertiesConfigAdapter(properties).host()).isEqualTo("node"); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesPortIsSetAdapterPortReturnsIt() { |
||||
GraphiteProperties properties = new GraphiteProperties(); |
||||
properties.setPort(4242); |
||||
assertThat(new GraphitePropertiesConfigAdapter(properties).port()).isEqualTo(4242); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesProtocolIsSetAdapterProtocolReturnsIt() { |
||||
GraphiteProperties properties = new GraphiteProperties(); |
||||
properties.setProtocol(GraphiteProtocol.UDP); |
||||
assertThat(new GraphitePropertiesConfigAdapter(properties).protocol()).isEqualTo(GraphiteProtocol.UDP); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesGraphiteTagsEnabledIsSetAdapterGraphiteTagsEnabledReturnsIt() { |
||||
GraphiteProperties properties = new GraphiteProperties(); |
||||
properties.setGraphiteTagsEnabled(true); |
||||
assertThat(new GraphitePropertiesConfigAdapter(properties).graphiteTagsEnabled()).isTrue(); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesTagsAsPrefixIsSetAdapterTagsAsPrefixReturnsIt() { |
||||
GraphiteProperties properties = new GraphiteProperties(); |
||||
properties.setTagsAsPrefix(new String[] { "worker" }); |
||||
assertThat(new GraphitePropertiesConfigAdapter(properties).tagsAsPrefix()).isEqualTo(new String[] { "worker" }); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
/* |
||||
* 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.jmx; |
||||
|
||||
import java.time.Duration; |
||||
|
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
/** |
||||
* Tests for {@link JmxPropertiesConfigAdapter}. |
||||
* |
||||
* @author Mirko Sobeck |
||||
*/ |
||||
class JmxPropertiesConfigAdapterTests { |
||||
|
||||
@Test |
||||
void whenPropertiesStepIsSetAdapterStepReturnsIt() { |
||||
JmxProperties properties = new JmxProperties(); |
||||
properties.setStep(Duration.ofMinutes(15)); |
||||
assertThat(new JmxPropertiesConfigAdapter(properties).step()).isEqualTo(Duration.ofMinutes(15)); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesDomainIsSetAdapterDomainReturnsIt() { |
||||
JmxProperties properties = new JmxProperties(); |
||||
properties.setDomain("abc"); |
||||
assertThat(new JmxPropertiesConfigAdapter(properties).domain()).isEqualTo("abc"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,86 @@
@@ -0,0 +1,86 @@
|
||||
/* |
||||
* 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.newrelic; |
||||
|
||||
import io.micrometer.newrelic.ClientProviderType; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
/** |
||||
* Tests for {@link NewRelicPropertiesConfigAdapter}. |
||||
* |
||||
* @author Mirko Sobeck |
||||
*/ |
||||
class NewRelicPropertiesConfigAdapterTests |
||||
extends StepRegistryPropertiesConfigAdapterTests<NewRelicProperties, NewRelicPropertiesConfigAdapter> { |
||||
|
||||
@Override |
||||
protected NewRelicProperties createProperties() { |
||||
return new NewRelicProperties(); |
||||
} |
||||
|
||||
@Override |
||||
protected NewRelicPropertiesConfigAdapter createConfigAdapter(NewRelicProperties properties) { |
||||
return new NewRelicPropertiesConfigAdapter(properties); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesMeterNameEventTypeEnabledIsSetAdapterMeterNameEventTypeEnabledReturnsIt() { |
||||
NewRelicProperties properties = createProperties(); |
||||
properties.setMeterNameEventTypeEnabled(true); |
||||
assertThat(createConfigAdapter(properties).meterNameEventTypeEnabled()).isEqualTo(true); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesEventTypeIsSetAdapterEventTypeReturnsIt() { |
||||
NewRelicProperties properties = createProperties(); |
||||
properties.setEventType("foo"); |
||||
assertThat(createConfigAdapter(properties).eventType()).isEqualTo("foo"); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesClientProviderTypeIsSetAdapterClientProviderTypeReturnsIt() { |
||||
NewRelicProperties properties = createProperties(); |
||||
properties.setClientProviderType(ClientProviderType.INSIGHTS_AGENT); |
||||
assertThat(createConfigAdapter(properties).clientProviderType()).isEqualTo(ClientProviderType.INSIGHTS_AGENT); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesApikeyIsSetAdapterApikeyReturnsIt() { |
||||
NewRelicProperties properties = createProperties(); |
||||
properties.setApiKey("my-key"); |
||||
assertThat(createConfigAdapter(properties).apiKey()).isEqualTo("my-key"); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesAccountIdIsSetAdapterAccountIdReturnsIt() { |
||||
NewRelicProperties properties = createProperties(); |
||||
properties.setAccountId("A38"); |
||||
assertThat(createConfigAdapter(properties).accountId()).isEqualTo("A38"); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesUriIsSetAdapterUriReturnsIt() { |
||||
NewRelicProperties properties = createProperties(); |
||||
properties.setUri("https://example.newrelic.com"); |
||||
assertThat(createConfigAdapter(properties).uri()).isEqualTo("https://example.newrelic.com"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
/* |
||||
* 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.prometheus; |
||||
|
||||
import java.time.Duration; |
||||
|
||||
import io.micrometer.prometheus.HistogramFlavor; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
/** |
||||
* Tests for {@link PrometheusPropertiesConfigAdapter}. |
||||
* |
||||
* @author Mirko Sobeck |
||||
*/ |
||||
class PrometheusPropertiesConfigAdapterTests { |
||||
|
||||
@Test |
||||
void whenPropertiesDescriptionsIsSetAdapterDescriptionsReturnsIt() { |
||||
PrometheusProperties properties = new PrometheusProperties(); |
||||
properties.setDescriptions(false); |
||||
assertThat(new PrometheusPropertiesConfigAdapter(properties).descriptions()).isFalse(); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesHistogramFlavorIsSetAdapterHistogramFlavorReturnsIt() { |
||||
PrometheusProperties properties = new PrometheusProperties(); |
||||
properties.setHistogramFlavor(HistogramFlavor.VictoriaMetrics); |
||||
assertThat(new PrometheusPropertiesConfigAdapter(properties).histogramFlavor()) |
||||
.isEqualTo(HistogramFlavor.VictoriaMetrics); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesStepIsSetAdapterStepReturnsIt() { |
||||
PrometheusProperties properties = new PrometheusProperties(); |
||||
properties.setStep(Duration.ofSeconds(30)); |
||||
assertThat(new PrometheusPropertiesConfigAdapter(properties).step()).isEqualTo(Duration.ofSeconds(30)); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
/* |
||||
* 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.signalfx; |
||||
|
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
/** |
||||
* Tests for {@link SignalFxPropertiesConfigAdapter}. |
||||
* |
||||
* @author Mirko Sobeck |
||||
*/ |
||||
class SignalFXPropertiesConfigAdapterTests |
||||
extends StepRegistryPropertiesConfigAdapterTests<SignalFxProperties, SignalFxPropertiesConfigAdapter> { |
||||
|
||||
@Override |
||||
protected SignalFxProperties createProperties() { |
||||
SignalFxProperties signalFxProperties = new SignalFxProperties(); |
||||
signalFxProperties.setAccessToken("ABC"); |
||||
return signalFxProperties; |
||||
} |
||||
|
||||
@Override |
||||
protected SignalFxPropertiesConfigAdapter createConfigAdapter(SignalFxProperties properties) { |
||||
return new SignalFxPropertiesConfigAdapter(properties); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesAccessTokenIsSetAdapterAccessTokenReturnsIt() { |
||||
SignalFxProperties properties = createProperties(); |
||||
assertThat(createConfigAdapter(properties).accessToken()).isEqualTo("ABC"); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesUriIsSetAdapterUriReturnsIt() { |
||||
SignalFxProperties properties = createProperties(); |
||||
properties.setUri("https://example.signalfx.com"); |
||||
assertThat(createConfigAdapter(properties).uri()).isEqualTo("https://example.signalfx.com"); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesSourceIsSetAdapterSourceReturnsIt() { |
||||
SignalFxProperties properties = createProperties(); |
||||
properties.setSource("DESKTOP-GA5"); |
||||
assertThat(createConfigAdapter(properties).source()).isEqualTo("DESKTOP-GA5"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
/* |
||||
* 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.simple; |
||||
|
||||
import java.time.Duration; |
||||
|
||||
import io.micrometer.core.instrument.simple.CountingMode; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx.SignalFxPropertiesConfigAdapter; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
/** |
||||
* Tests for {@link SignalFxPropertiesConfigAdapter}. |
||||
* |
||||
* @author Mirko Sobeck |
||||
*/ |
||||
class SimplePropertiesConfigAdapterTests { |
||||
|
||||
@Test |
||||
void whenPropertiesStepIsSetAdapterStepReturnsIt() { |
||||
SimpleProperties properties = new SimpleProperties(); |
||||
properties.setStep(Duration.ofSeconds(30)); |
||||
assertThat(new SimplePropertiesConfigAdapter(properties).step()).isEqualTo(Duration.ofSeconds(30)); |
||||
} |
||||
|
||||
@Test |
||||
void whenPropertiesAccessTokenIsSetAdapterAccessTokenReturnsIt() { |
||||
SimpleProperties properties = new SimpleProperties(); |
||||
properties.setMode(CountingMode.STEP); |
||||
assertThat(new SimplePropertiesConfigAdapter(properties).mode()).isEqualTo(CountingMode.STEP); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue