|
| 1 | +/* |
| 2 | + * Copyright 2012-2023 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.boot.actuate.autoconfigure.metrics.export.atlas; |
| 18 | + |
| 19 | +import java.time.Duration; |
| 20 | + |
| 21 | +import org.junit.jupiter.api.Test; |
| 22 | + |
| 23 | +import static org.assertj.core.api.Assertions.assertThat; |
| 24 | + |
| 25 | +/** |
| 26 | + * Tests for {@link AtlasPropertiesConfigAdapter}. |
| 27 | + * |
| 28 | + * @author Mirko Sobeck |
| 29 | + */ |
| 30 | +class AtlasPropertiesConfigAdapterTests { |
| 31 | + |
| 32 | + @Test |
| 33 | + void whenPropertiesStepIsSetAdapterStepReturnsIt() { |
| 34 | + AtlasProperties properties = new AtlasProperties(); |
| 35 | + properties.setStep(Duration.ofMinutes(15)); |
| 36 | + assertThat(new AtlasPropertiesConfigAdapter(properties).step()).isEqualTo(Duration.ofMinutes(15)); |
| 37 | + } |
| 38 | + |
| 39 | + @Test |
| 40 | + void whenPropertiesEnabledIsSetAdapterEnabledReturnsIt() { |
| 41 | + AtlasProperties properties = new AtlasProperties(); |
| 42 | + properties.setEnabled(false); |
| 43 | + assertThat(new AtlasPropertiesConfigAdapter(properties).enabled()).isFalse(); |
| 44 | + } |
| 45 | + |
| 46 | + @Test |
| 47 | + void whenPropertiesConnectTimeoutIsSetAdapterConnectTimeoutReturnsIt() { |
| 48 | + AtlasProperties properties = new AtlasProperties(); |
| 49 | + properties.setConnectTimeout(Duration.ofSeconds(12)); |
| 50 | + assertThat(new AtlasPropertiesConfigAdapter(properties).connectTimeout()).isEqualTo(Duration.ofSeconds(12)); |
| 51 | + } |
| 52 | + |
| 53 | + @Test |
| 54 | + void whenPropertiesReadTimeoutIsSetAdapterReadTimeoutReturnsIt() { |
| 55 | + AtlasProperties properties = new AtlasProperties(); |
| 56 | + properties.setReadTimeout(Duration.ofSeconds(42)); |
| 57 | + assertThat(new AtlasPropertiesConfigAdapter(properties).readTimeout()).isEqualTo(Duration.ofSeconds(42)); |
| 58 | + } |
| 59 | + |
| 60 | + @Test |
| 61 | + void whenPropertiesNumThreadsIsSetAdapterNumThreadsReturnsIt() { |
| 62 | + AtlasProperties properties = new AtlasProperties(); |
| 63 | + properties.setNumThreads(8); |
| 64 | + assertThat(new AtlasPropertiesConfigAdapter(properties).numThreads()).isEqualTo(8); |
| 65 | + } |
| 66 | + |
| 67 | + @Test |
| 68 | + void whenPropertiesBatchSizeIsSetAdapterBatchSizeReturnsIt() { |
| 69 | + AtlasProperties properties = new AtlasProperties(); |
| 70 | + properties.setBatchSize(10042); |
| 71 | + assertThat(new AtlasPropertiesConfigAdapter(properties).batchSize()).isEqualTo(10042); |
| 72 | + } |
| 73 | + |
| 74 | + @Test |
| 75 | + void whenPropertiesUriIsSetAdapterUriReturnsIt() { |
| 76 | + AtlasProperties properties = new AtlasProperties(); |
| 77 | + properties.setUri("https://atlas.example.com"); |
| 78 | + assertThat(new AtlasPropertiesConfigAdapter(properties).uri()).isEqualTo("https://atlas.example.com"); |
| 79 | + } |
| 80 | + |
| 81 | + @Test |
| 82 | + void whenPropertiesLwcEnabledIsSetAdapterLwcEnabledReturnsIt() { |
| 83 | + AtlasProperties properties = new AtlasProperties(); |
| 84 | + properties.setLwcEnabled(true); |
| 85 | + assertThat(new AtlasPropertiesConfigAdapter(properties).lwcEnabled()).isTrue(); |
| 86 | + } |
| 87 | + |
| 88 | + @Test |
| 89 | + void whenPropertiesConfigRefreshFrequencyIsSetAdapterConfigRefreshFrequencyReturnsIt() { |
| 90 | + AtlasProperties properties = new AtlasProperties(); |
| 91 | + properties.setConfigRefreshFrequency(Duration.ofMinutes(5)); |
| 92 | + assertThat(new AtlasPropertiesConfigAdapter(properties).configRefreshFrequency()) |
| 93 | + .isEqualTo(Duration.ofMinutes(5)); |
| 94 | + } |
| 95 | + |
| 96 | + @Test |
| 97 | + void whenPropertiesConfigTimeToLiveIsSetAdapterConfigTTLReturnsIt() { |
| 98 | + AtlasProperties properties = new AtlasProperties(); |
| 99 | + properties.setConfigTimeToLive(Duration.ofMinutes(6)); |
| 100 | + assertThat(new AtlasPropertiesConfigAdapter(properties).configTTL()).isEqualTo(Duration.ofMinutes(6)); |
| 101 | + } |
| 102 | + |
| 103 | + @Test |
| 104 | + void whenPropertiesConfigUriIsSetAdapterConfigUriReturnsIt() { |
| 105 | + AtlasProperties properties = new AtlasProperties(); |
| 106 | + properties.setConfigUri("https://atlas.example.com/config"); |
| 107 | + assertThat(new AtlasPropertiesConfigAdapter(properties).configUri()) |
| 108 | + .isEqualTo("https://atlas.example.com/config"); |
| 109 | + } |
| 110 | + |
| 111 | + @Test |
| 112 | + void whenPropertiesEvalUriIsSetAdapterEvalUriReturnsIt() { |
| 113 | + AtlasProperties properties = new AtlasProperties(); |
| 114 | + properties.setEvalUri("https://atlas.example.com/evaluate"); |
| 115 | + assertThat(new AtlasPropertiesConfigAdapter(properties).evalUri()) |
| 116 | + .isEqualTo("https://atlas.example.com/evaluate"); |
| 117 | + } |
| 118 | + |
| 119 | +} |
0 commit comments