@@ -109,7 +109,12 @@ public void validRequestWithFullPathAndPathParameter() throws IOException
109109 path = "/api/petstore/v3/store/order/434312" ;
110110 Assert .assertTrue (validator .isValidRequest (null , verb , path , null , headers ), "Request should be valid!" );
111111
112- Assert .assertEquals (validator .getExposurePath2SpecifiedPathMap ().size (), 2 , "Cached paths should be two as the size is limited" );
112+ path = "/api/petstore/v3/store/order/978978" ;
113+ Assert .assertTrue (validator .isValidRequest (null , verb , path , null , headers ), "Request should be valid!" );
114+
115+ // Check the cache
116+ Assert .assertEquals (validator .getExposurePath2SpecifiedPathMap ().size (), 2 , "Cached paths should be two as the size is limited. "
117+ + "Cached paths: " + validator .getExposurePath2SpecifiedPathMap ().toString ());
113118 }
114119
115120 @ Test
@@ -118,7 +123,7 @@ public void invalidRequestWithFullPathAndPathParameter() throws IOException
118123 String swagger = Files .readFile (this .getClass ().getClassLoader ().getResourceAsStream (TEST_PACKAGE + "PetstoreSwagger2.0.json" ));
119124 OpenAPIValidator validator = OpenAPIValidator .getInstance (swagger );
120125
121- String path = "/api/petstore/v3/store/order/invalidPatameter " ;
126+ String path = "/api/petstore/v3/store/order/invalidParameter " ;
122127 String verb = "DELETE" ;
123128 HeaderSet headers = new HeaderSet ();
124129 headers .addHeader ("Content-Type" , "application/json" );
@@ -142,6 +147,20 @@ public void invalidRequestNoMatchToSpec() throws IOException
142147 Assert .assertFalse (validator .isValidRequest (null , verb , path , null , headers ));
143148 }
144149
150+ @ Test
151+ public void invalidNoMatch2SpecAtAll () throws IOException
152+ {
153+ String swagger = Files .readFile (this .getClass ().getClassLoader ().getResourceAsStream (TEST_PACKAGE + "PetstoreSwagger2.0.json" ));
154+ OpenAPIValidator validator = OpenAPIValidator .getInstance (swagger );
155+
156+ String path = "/no/match" ;
157+ String verb = "GET" ;
158+ HeaderSet headers = new HeaderSet ();
159+ headers .addHeader ("Content-Type" , "application/json" );
160+
161+ Assert .assertFalse (validator .isValidRequest (null , verb , path , null , headers ));
162+ }
163+
145164 @ Test
146165 public void validRequestExternalURLSwagger20 () throws IOException
147166 {
@@ -213,5 +232,4 @@ public void validResponsewithoutBody() throws IOException
213232
214233 Assert .assertFalse (validator .isValidResponse (null , verb , path , status , headers ), "Request should be not valid!" );
215234 }
216-
217235}
0 commit comments