@@ -30,31 +30,21 @@ public RouterTest() {
3030 }
3131
3232 @ Test
33- public void hasRouteTrueWhenARouteAllowsPath () throws Exception {
33+ public void canRespondTrueWhenARouteAllowsPath () throws Exception {
3434 when (routeMock1 .allows (any ())).thenReturn (false );
3535 when (routeMock2 .allows (any ())).thenReturn (true );
3636
3737 assertTrue (router .canRespond (null ));
3838 }
3939
4040 @ Test
41- public void hasRouteFalseWhenNoRouteAllowsPath () throws Exception {
41+ public void canRespondFalseWhenNoRouteAllowsPath () throws Exception {
4242 when (routeMock1 .allows (any ())).thenReturn (false );
4343 when (routeMock2 .allows (any ())).thenReturn (false );
4444
4545 assertFalse (router .canRespond (null ));
4646 }
4747
48- @ Test
49- public void returnsRouteForRequest () throws Exception {
50- when (routeMock1 .allows (any ())).thenReturn (false );
51- when (routeMock2 .allows (any ())).thenReturn (true );
52-
53- Route actual = router .routeForRequest (null );
54-
55- assertEquals (actual , routeMock2 );
56- }
57-
5848 @ Test
5949 public void respondsToRequest () throws Exception {
6050 when (routeMock1 .allows (any ())).thenReturn (false );
@@ -69,7 +59,7 @@ public void respondsToRequest() throws Exception {
6959 }
7060
7161 @ Test
72- public void returns500WhenRouteRespondErrors () throws Exception {
62+ public void returns500WhenRouteRespondThrowsIOException () throws Exception {
7363 when (routeMock1 .allows (any ())).thenReturn (false );
7464 when (routeMock2 .allows (any ())).thenReturn (true );
7565 when (routeMock2 .respond (any (), any ())).thenThrow (new IOException ());
@@ -78,4 +68,14 @@ public void returns500WhenRouteRespondErrors() throws Exception {
7868
7969 assertEquals (500 , response .getStatusCode ());
8070 }
71+
72+ @ Test
73+ public void returns500WhenRouteRespondThrowsNullPointerException () throws Exception {
74+ when (routeMock1 .allows (any ())).thenReturn (false );
75+ when (routeMock2 .allows (any ())).thenReturn (false );
76+
77+ Response response = router .respond (appConfigMock , requestMock );
78+
79+ assertEquals (500 , response .getStatusCode ());
80+ }
8181}
0 commit comments