@@ -701,7 +701,7 @@ public void testFunctionsAndStructs() {
701701 errors .add (errMsg );
702702 }
703703
704- // Loop through all params for the current RPC and make sure everyone has a a setter and a getter
704+ // Loop through all params for the current RPC and make sure everyone has a setter and a getter
705705 List <Parameter > parameters = rpcAllParamsMapFromXml .get (rpcName ).parameters ;
706706 for (int i = 0 ; i < parameters .size (); i ++) {
707707 Parameter parameter = parameters .get (i );
@@ -750,4 +750,47 @@ public void testFunctionsAndStructs() {
750750
751751 assertTrue ("There are " + errors .size () + " errors: \n " + errors , errors .isEmpty ());
752752 }
753+
754+ /**
755+ * This method makes sure that for every enum RPC, the class exists in the code
756+ * and its annotations match the RPC spec. And for every element in that enum:
757+ * - The element exists and its name & annotations match the RPC spec
758+ */
759+ @ Test
760+ public void testEnums () {
761+ List <String > errors = new ArrayList <>();
762+
763+ // Loop through all RPCs that were loaded from RPC spec XML file
764+ for (String rpcName : rpcAllParamsMapFromXml .keySet ()) {
765+ if (rpcAllParamsMapFromXml .get (rpcName ).skip || rpcAllParamsMapFromXml .get (rpcName ).type .equals ("function" ) || rpcAllParamsMapFromXml .get (rpcName ).type .equals ("struct" )) {
766+ continue ;
767+ }
768+
769+ Class aClass ;
770+ try {
771+ aClass = Class .forName (ENUM_PACKAGE_PREFIX + rpcName );
772+ } catch (ClassNotFoundException e ) {
773+ e .printStackTrace ();
774+ errors .add ("Class not found for rpc: " + rpcName + ". \n " );
775+ continue ;
776+ }
777+
778+ if (aClass != null && isDeprecated (aClass ) != rpcAllParamsMapFromXml .get (rpcName ).isDeprecated ) {
779+ String errMsg = rpcName + " deprecation status does not match RPC spec" + ". \n " ;
780+ errors .add (errMsg );
781+ }
782+
783+ // Loop through all elements for the current RPC and make sure everyone matches the RPC spec
784+ List <Element > elements = rpcAllParamsMapFromXml .get (rpcName ).elements ;
785+ for (int i = 0 ; i < elements .size (); i ++) {
786+ Element element = elements .get (i );
787+
788+ if (element .skip ) {
789+ continue ;
790+ }
791+ }
792+ }
793+
794+ assertTrue ("There are " + errors .size () + " errors: \n " + errors , errors .isEmpty ());
795+ }
753796}
0 commit comments