|
| 1 | +/* |
| 2 | + * Copyright 2014-2022 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 | + * http://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 de.codecentric.boot.admin.server.ui.config; |
| 18 | + |
| 19 | +import java.time.Duration; |
| 20 | + |
| 21 | +import org.assertj.core.api.WithAssertions; |
| 22 | +import org.junit.jupiter.api.Nested; |
| 23 | +import org.junit.jupiter.api.Test; |
| 24 | +import org.junit.jupiter.api.extension.ExtendWith; |
| 25 | +import org.springframework.beans.factory.annotation.Autowired; |
| 26 | +import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| 27 | +import org.springframework.boot.test.context.SpringBootTest; |
| 28 | +import org.springframework.test.context.TestPropertySource; |
| 29 | +import org.springframework.test.context.junit.jupiter.SpringExtension; |
| 30 | + |
| 31 | +@SpringBootTest(classes = AdminServerUiProperties.class) |
| 32 | +@ExtendWith(SpringExtension.class) |
| 33 | +@TestPropertySource(properties = { |
| 34 | + "spring.boot.admin.ui.cache.maxAge: -1s", |
| 35 | + "spring.boot.admin.ui.cache.noCache: true", |
| 36 | + "spring.boot.admin.ui.cache.noStore: true", |
| 37 | + "spring.boot.admin.ui.theme.color: #ffffff", |
| 38 | + "spring.boot.admin.ui.theme.palette.50: #50", |
| 39 | + "spring.boot.admin.ui.theme.palette.100: #100", |
| 40 | + "spring.boot.admin.ui.theme.palette.200: #200", |
| 41 | + "spring.boot.admin.ui.theme.palette.300: #300", |
| 42 | + "spring.boot.admin.ui.theme.palette.400: #400", |
| 43 | + "spring.boot.admin.ui.theme.palette.500: #500", |
| 44 | + "spring.boot.admin.ui.theme.palette.600: #600", |
| 45 | + "spring.boot.admin.ui.theme.palette.700: #700", |
| 46 | + "spring.boot.admin.ui.theme.palette.800: #800", |
| 47 | + "spring.boot.admin.ui.theme.palette.900: #900" |
| 48 | +}) |
| 49 | +@EnableConfigurationProperties({AdminServerUiProperties.class}) |
| 50 | +class AdminServerUiPropertiesTest implements WithAssertions { |
| 51 | + |
| 52 | + @Autowired |
| 53 | + private AdminServerUiProperties adminServerUiProperties; |
| 54 | + |
| 55 | + @Nested |
| 56 | + class CacheTest { |
| 57 | + @Test |
| 58 | + void maxAge() { |
| 59 | + assertThat(adminServerUiProperties.getCache().getMaxAge()).isEqualTo(Duration.ofSeconds(-1)); |
| 60 | + } |
| 61 | + |
| 62 | + @Test |
| 63 | + void noCache() { |
| 64 | + assertThat(adminServerUiProperties.getCache().getNoCache()).isEqualTo(true); |
| 65 | + } |
| 66 | + |
| 67 | + @Test |
| 68 | + void noStore() { |
| 69 | + assertThat(adminServerUiProperties.getCache().getNoStore()).isEqualTo(true); |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + @Nested |
| 74 | + class ThemeTest { |
| 75 | + @Test |
| 76 | + void color() { |
| 77 | + assertThat(adminServerUiProperties.getTheme().getColor()).isEqualTo("#ffffff"); |
| 78 | + } |
| 79 | + |
| 80 | + @Nested |
| 81 | + class PaletteTest { |
| 82 | + @Test |
| 83 | + void shades() { |
| 84 | + AdminServerUiProperties.UiTheme theme = adminServerUiProperties.getTheme(); |
| 85 | + AdminServerUiProperties.Palette palette = theme.getPalette(); |
| 86 | + |
| 87 | + assertThat(palette.getShade50()).isEqualTo("#50"); |
| 88 | + assertThat(palette.getShade100()).isEqualTo("#100"); |
| 89 | + assertThat(palette.getShade200()).isEqualTo("#200"); |
| 90 | + assertThat(palette.getShade300()).isEqualTo("#300"); |
| 91 | + assertThat(palette.getShade400()).isEqualTo("#400"); |
| 92 | + assertThat(palette.getShade500()).isEqualTo("#500"); |
| 93 | + assertThat(palette.getShade600()).isEqualTo("#600"); |
| 94 | + assertThat(palette.getShade700()).isEqualTo("#700"); |
| 95 | + assertThat(palette.getShade800()).isEqualTo("#800"); |
| 96 | + assertThat(palette.getShade900()).isEqualTo("#900"); |
| 97 | + } |
| 98 | + } |
| 99 | + } |
| 100 | +} |
0 commit comments