File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
main/java/io/kafbat/ui/config Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 22
33import io .kafbat .ui .model .MetricsConfig ;
44import jakarta .annotation .PostConstruct ;
5+ import jakarta .validation .constraints .NotEmpty ;
6+ import jakarta .validation .constraints .NotNull ;
57import java .util .ArrayList ;
68import java .util .HashMap ;
79import java .util .HashSet ;
@@ -33,7 +35,9 @@ public class ClustersProperties {
3335
3436 @ Data
3537 public static class Cluster {
38+ @ NotEmpty
3639 String name ;
40+ @ NotEmpty
3741 String bootstrapServers ;
3842
3943 TruststoreConfig ssl ;
Original file line number Diff line number Diff line change 1+ package io .kafbat .ui ;
2+
3+ import static org .junit .jupiter .api .Assertions .assertThrows ;
4+
5+ import io .kafbat .ui .config .ClustersProperties ;
6+ import org .junit .jupiter .api .Test ;
7+ import org .springframework .beans .factory .annotation .Autowired ;
8+ import org .springframework .boot .context .properties .bind .BindException ;
9+ import org .springframework .boot .test .context .SpringBootTest ;
10+ import org .springframework .test .context .TestPropertySource ;
11+
12+ @ SpringBootTest
13+ //@EnableConfigurationProperties(ClustersProperties.class)
14+ @ TestPropertySource (properties = {
15+ "kafka.clusters.0.name=" ,
16+ })
17+ class ConfigurationTests {
18+
19+ @ Autowired
20+ private ClustersProperties clustersProperties ;
21+
22+ @ Test
23+ void shouldFailWithotName () {
24+ assertThrows (BindException .class , () -> clustersProperties .getClusters ());
25+ }
26+
27+ }
You can’t perform that action at this time.
0 commit comments