Skip to content

Commit 55a7732

Browse files
committed
chore: fix errors in IDE
1 parent eb96539 commit 55a7732

File tree

3 files changed

+103
-8
lines changed

3 files changed

+103
-8
lines changed

spring-boot-admin-server-ui/src/main/java/de/codecentric/boot/admin/server/ui/web/UiController.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import com.fasterxml.jackson.annotation.JsonInclude;
2424
import com.fasterxml.jackson.annotation.JsonInclude.Include;
25-
import org.springframework.boot.context.properties.ConstructorBinding;
25+
import org.jetbrains.annotations.Nullable;
2626
import org.springframework.http.MediaType;
2727
import org.springframework.util.Assert;
2828
import org.springframework.web.bind.annotation.GetMapping;
@@ -87,10 +87,8 @@ public List<UiExtension> getJsExtensions() {
8787
return this.uiExtensions.getJsExtensions();
8888
}
8989

90-
// FIXME: add @Nullable to principal parameter
91-
// see https://github.com/spring-projects/spring-framework/issues/25981
9290
@ModelAttribute(value = "user", binding = false)
93-
public Map<String, Object> getUser(Principal principal) {
91+
public Map<String, Object> getUser(@Nullable Principal principal) {
9492
if (principal != null) {
9593
return singletonMap("name", principal.getName());
9694
}
@@ -151,7 +149,6 @@ public static class Settings {
151149

152150
@lombok.Data
153151
@JsonInclude(Include.NON_EMPTY)
154-
@ConstructorBinding
155152
public static class ExternalView {
156153

157154
/**
@@ -187,7 +184,6 @@ public ExternalView(String label, String url, Integer order, boolean iframe) {
187184

188185
@lombok.Data
189186
@JsonInclude(Include.NON_EMPTY)
190-
@ConstructorBinding
191187
public static class ViewSettings {
192188

193189
/**

spring-boot-admin-server-ui/src/main/java/de/codecentric/boot/admin/server/ui/web/servlet/HomepageForwardingFilter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ public HomepageForwardingFilter(HomepageForwardingFilterConfig filterConfig) {
6666
@Override
6767
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
6868
throws IOException, ServletException {
69-
if (request instanceof HttpServletRequest) {
70-
HttpServletRequest httpRequest = (HttpServletRequest) request;
69+
if (request instanceof HttpServletRequest httpRequest) {
7170
if (this.matcher.test(httpRequest)) {
7271
log.trace("Forwarding request with URL {} to index", httpRequest.getRequestURI());
7372
request.getRequestDispatcher(this.homepage).forward(request, response);
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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

Comments
 (0)