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