3232
3333import de .codecentric .boot .admin .model .Application ;
3434import de .codecentric .boot .admin .registry .ApplicationRegistry ;
35+ import de .codecentric .boot .admin .zuul .ApplicationRouteLocator .ApplicationRoute ;
3536
3637public class ApplicationRouteLocatorTest {
3738
@@ -47,42 +48,46 @@ public void setup() {
4748
4849 @ Test
4950 public void getRoutes_healthOnly () {
50- when (registry .getApplications ()).thenReturn (singletonList (Application .create ("app1" )
51- .withHealthUrl ("http://localhost/health" ).withId ("1234" ).build ()));
51+ Application application = Application .create ("app1" )
52+ .withHealthUrl ("http://localhost/health" )
53+ .withId ("1234" )
54+ .build ();
55+ when (registry .getApplications ()).thenReturn (singletonList (application ));
5256
5357 assertEquals (1 , locator .getRoutes ().size ());
54- assertEquals (asList (new Route ( "1234-health" , "/**" , "http://localhost/health" ,
55- "/api/applications/1234/health" , false , null )), locator .getRoutes ());
58+ assertEquals (singletonList (new ApplicationRoute ( application , "1234-health" , "/**" , "http://localhost/health" ,
59+ "/api/applications/1234/health" )), locator .getRoutes ());
5660
5761 Route matchingRoute = locator .getMatchingRoute ("/api/applications/1234/health" );
58- assertEquals (new Route ( "1234-health" , "" , "http://localhost/health" ,
59- "/api/applications/1234/health" , false , null ), matchingRoute );
62+ assertEquals (new ApplicationRoute ( application , "1234-health" , "" , "http://localhost/health" ,
63+ "/api/applications/1234/health" ), matchingRoute );
6064
6165 assertNull (locator .getMatchingRoute ("/api/applications/1234/danger" ));
6266 }
6367
6468 @ Test
6569 public void getRoutes () {
66- when (registry .getApplications ()).thenReturn (
67- singletonList (Application .create ("app1" ).withHealthUrl ("http://localhost/health" )
68- .withManagementUrl ("http://localhost" ).withId ("1234" ).build ()));
70+ Application application = Application .create ("app1" )
71+ .withHealthUrl ("http://localhost/health" )
72+ .withManagementUrl ("http://localhost" )
73+ .withId ("1234" )
74+ .build ();
75+ when (registry .getApplications ()).thenReturn (singletonList (application ));
6976
7077 assertEquals (2 , locator .getRoutes ().size ());
7178
72- assertEquals (asList (
73- new Route ("1234-health" , "/**" , "http://localhost/health" ,
74- "/api/applications/1234/health" , false , null ),
75- new Route ("1234-env" , "/**" , "http://localhost/env" , "/api/applications/1234/env" ,
76- false , null )),
77- locator .getRoutes ());
79+ assertEquals (asList (new ApplicationRoute (application , "1234-health" , "/**" , "http://localhost/health" ,
80+ "/api/applications/1234/health" ),
81+ new ApplicationRoute (application , "1234-env" , "/**" , "http://localhost/env" ,
82+ "/api/applications/1234/env" )), locator .getRoutes ());
7883
7984 Route matchingHealth = locator .getMatchingRoute ("/api/applications/1234/health" );
80- assertEquals (new Route ( "1234-health" , "" , "http://localhost/health" ,
81- "/api/applications/1234/health" , false , null ), matchingHealth );
85+ assertEquals (new ApplicationRoute ( application , "1234-health" , "" , "http://localhost/health" ,
86+ "/api/applications/1234/health" ), matchingHealth );
8287
8388 Route matchingEnv = locator .getMatchingRoute ("/api/applications/1234/env/reset" );
84- assertEquals (new Route ( "1234-env" , "/reset" , "http://localhost/env" ,
85- "/api/applications/1234/env" , false , null ), matchingEnv );
89+ assertEquals (new ApplicationRoute ( application , "1234-env" , "/reset" , "http://localhost/env" ,
90+ "/api/applications/1234/env" ), matchingEnv );
8691
8792 assertNull (locator .getMatchingRoute ("/api/applications/1234/danger" ));
8893 }
0 commit comments