@@ -712,41 +712,49 @@ public void testApiNamingConventions() throws Exception {
712
712
713
713
assertTrue ("method [" + apiName + "] is not final" ,
714
714
Modifier .isFinal (method .getClass ().getModifiers ()) || Modifier .isFinal (method .getModifiers ()));
715
- assertTrue (Modifier .isPublic (method .getModifiers ()));
715
+ assertTrue ("method [" + method + "] should be public" , Modifier .isPublic (method .getModifiers ()));
716
716
717
717
//we convert all the method names to snake case, hence we need to look for the '_async' suffix rather than 'Async'
718
718
if (apiName .endsWith ("_async" )) {
719
719
assertTrue ("async method [" + method .getName () + "] doesn't have corresponding sync method" ,
720
720
methods .containsKey (apiName .substring (0 , apiName .length () - 6 )));
721
- assertThat (method .getReturnType (), equalTo (Void .TYPE ));
722
- assertEquals (0 , method .getExceptionTypes ().length );
721
+ assertThat ("async method [" + method + "] should return void" , method .getReturnType (), equalTo (Void .TYPE ));
722
+ assertEquals ("async method [" + method + "] should not throw any exceptions" , 0 , method .getExceptionTypes ().length );
723
723
if (apiName .equals ("security.get_ssl_certificates_async" )) {
724
724
assertEquals (2 , method .getParameterTypes ().length );
725
725
assertThat (method .getParameterTypes ()[0 ], equalTo (RequestOptions .class ));
726
726
assertThat (method .getParameterTypes ()[1 ], equalTo (ActionListener .class ));
727
727
} else {
728
- assertEquals (3 , method .getParameterTypes ().length );
729
- assertThat (method .getParameterTypes ()[0 ].getSimpleName (), endsWith ("Request" ));
730
- assertThat (method .getParameterTypes ()[1 ], equalTo (RequestOptions .class ));
731
- assertThat (method .getParameterTypes ()[2 ], equalTo (ActionListener .class ));
728
+ assertEquals ("async method [" + method + "] has the wrong number of arguments" , 3 , method .getParameterTypes ().length );
729
+ assertThat ("the first parameter to async method [" + method + "] should be a request type" ,
730
+ method .getParameterTypes ()[0 ].getSimpleName (), endsWith ("Request" ));
731
+ assertThat ("the second parameter to async method [" + method + "] is the wrong type" ,
732
+ method .getParameterTypes ()[1 ], equalTo (RequestOptions .class ));
733
+ assertThat ("the third parameter to async method [" + method + "] is the wrong type" ,
734
+ method .getParameterTypes ()[2 ], equalTo (ActionListener .class ));
732
735
}
733
736
} else {
734
737
//A few methods return a boolean rather than a response object
735
738
if (apiName .equals ("ping" ) || apiName .contains ("exist" )) {
736
- assertThat (method .getReturnType ().getSimpleName (), equalTo ("boolean" ));
739
+ assertThat ("the return type for method [" + method + "] is incorrect" ,
740
+ method .getReturnType ().getSimpleName (), equalTo ("boolean" ));
737
741
} else {
738
- assertThat (method .getReturnType ().getSimpleName (), endsWith ("Response" ));
742
+ assertThat ("the return type for method [" + method + "] is incorrect" ,
743
+ method .getReturnType ().getSimpleName (), endsWith ("Response" ));
739
744
}
740
745
741
- assertEquals (1 , method .getExceptionTypes ().length );
746
+ assertEquals ("incorrect number of exceptions for method [" + method + "]" , 1 , method .getExceptionTypes ().length );
742
747
//a few methods don't accept a request object as argument
743
748
if (apiName .equals ("ping" ) || apiName .equals ("info" ) || apiName .equals ("security.get_ssl_certificates" )) {
744
- assertEquals (1 , method .getParameterTypes ().length );
745
- assertThat (method .getParameterTypes ()[0 ], equalTo (RequestOptions .class ));
749
+ assertEquals ("incorrect number of arguments for method [" + method + "]" , 1 , method .getParameterTypes ().length );
750
+ assertThat ("the parameter to method [" + method + "] is the wrong type" ,
751
+ method .getParameterTypes ()[0 ], equalTo (RequestOptions .class ));
746
752
} else {
747
- assertEquals (apiName , 2 , method .getParameterTypes ().length );
748
- assertThat (method .getParameterTypes ()[0 ].getSimpleName (), endsWith ("Request" ));
749
- assertThat (method .getParameterTypes ()[1 ], equalTo (RequestOptions .class ));
753
+ assertEquals ("incorrect number of arguments for method [" + method + "]" , 2 , method .getParameterTypes ().length );
754
+ assertThat ("the first parameter to method [" + method + "] is the wrong type" ,
755
+ method .getParameterTypes ()[0 ].getSimpleName (), endsWith ("Request" ));
756
+ assertThat ("the second parameter to method [" + method + "] is the wrong type" ,
757
+ method .getParameterTypes ()[1 ], equalTo (RequestOptions .class ));
750
758
}
751
759
752
760
boolean remove = apiSpec .remove (apiName );
0 commit comments