11package com .reajason .javaweb .boot .controller ;
22
3- import com .reajason .javaweb .boot .entity .Config ;
43import org .junit .jupiter .api .Test ;
54import org .springframework .beans .factory .annotation .Autowired ;
65import org .springframework .boot .test .context .SpringBootTest ;
76import org .springframework .boot .test .web .client .TestRestTemplate ;
87import org .springframework .http .HttpStatus ;
98import org .springframework .http .ResponseEntity ;
109
10+ import java .util .List ;
11+ import java .util .Map ;
12+
1113import static org .junit .jupiter .api .Assertions .assertEquals ;
1214import static org .junit .jupiter .api .Assertions .assertNotNull ;
1315
@@ -24,14 +26,31 @@ public class ConfigControllerIntegrationTest {
2426
2527 @ Test
2628 public void testConfigEndpoint () {
27- ResponseEntity <Config > response = restTemplate .getForEntity ("/config" , Config .class );
29+ ResponseEntity <Map > response = restTemplate .getForEntity ("/config" , Map .class );
30+
31+ assertEquals (HttpStatus .OK , response .getStatusCode ());
32+
33+ Map body = response .getBody ();
34+ assertNotNull (body );
35+ }
36+
37+ @ Test
38+ public void testConfigServersEndpoint () {
39+ ResponseEntity <Map > response = restTemplate .getForEntity ("/config/servers" , Map .class );
40+
41+ assertEquals (HttpStatus .OK , response .getStatusCode ());
42+
43+ Map body = response .getBody ();
44+ assertNotNull (body );
45+ }
46+
47+ @ Test
48+ public void testConfigPackersEndpoint () {
49+ ResponseEntity <List > response = restTemplate .getForEntity ("/config/packers" , List .class );
2850
2951 assertEquals (HttpStatus .OK , response .getStatusCode ());
3052
31- Config config = response .getBody ();
32- assertNotNull (config );
33- assertNotNull (config .getServers ());
34- assertNotNull (config .getCore ());
35- assertNotNull (config .getPackers ());
53+ List <String > body = response .getBody ();
54+ assertNotNull (body );
3655 }
3756}
0 commit comments