summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBilal Alsharifi <bilal.alsharifi@gmail.com>2020-10-20 16:05:02 -0400
committerBilal Alsharifi <bilal.alsharifi@gmail.com>2020-10-20 16:05:02 -0400
commitef71ec51858b66403a1a5143d7c0ae5c79664350 (patch)
tree43eb7c297a34e91f8349f5f1fbca4b2a24617f3b
parent65fceb42ea3818ccb7c55592da5e2f20c1372e37 (diff)
downloadsdl_android-ef71ec51858b66403a1a5143d7c0ae5c79664350.tar.gz
Add testEnums()
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCGenericTests.java45
1 files changed, 44 insertions, 1 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCGenericTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCGenericTests.java
index df4a81357..49dc1637b 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCGenericTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCGenericTests.java
@@ -701,7 +701,7 @@ public class RPCGenericTests {
errors.add(errMsg);
}
- // Loop through all params for the current RPC and make sure everyone has a a setter and a getter
+ // Loop through all params for the current RPC and make sure everyone has a setter and a getter
List<Parameter> parameters = rpcAllParamsMapFromXml.get(rpcName).parameters;
for (int i = 0; i < parameters.size(); i++) {
Parameter parameter = parameters.get(i);
@@ -750,4 +750,47 @@ public class RPCGenericTests {
assertTrue("There are " + errors.size() + " errors: \n" + errors, errors.isEmpty());
}
+
+ /**
+ * This method makes sure that for every enum RPC, the class exists in the code
+ * and its annotations match the RPC spec. And for every element in that enum:
+ * - The element exists and its name & annotations match the RPC spec
+ */
+ @Test
+ public void testEnums() {
+ List<String> errors = new ArrayList<>();
+
+ // Loop through all RPCs that were loaded from RPC spec XML file
+ for (String rpcName : rpcAllParamsMapFromXml.keySet()) {
+ if (rpcAllParamsMapFromXml.get(rpcName).skip || rpcAllParamsMapFromXml.get(rpcName).type.equals("function") || rpcAllParamsMapFromXml.get(rpcName).type.equals("struct")) {
+ continue;
+ }
+
+ Class aClass;
+ try {
+ aClass = Class.forName(ENUM_PACKAGE_PREFIX + rpcName);
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ errors.add("Class not found for rpc: " + rpcName + ". \n");
+ continue;
+ }
+
+ if (aClass != null && isDeprecated(aClass) != rpcAllParamsMapFromXml.get(rpcName).isDeprecated) {
+ String errMsg = rpcName + " deprecation status does not match RPC spec" + ". \n";
+ errors.add(errMsg);
+ }
+
+ // Loop through all elements for the current RPC and make sure everyone matches the RPC spec
+ List<Element> elements = rpcAllParamsMapFromXml.get(rpcName).elements;
+ for (int i = 0; i < elements.size(); i++) {
+ Element element = elements.get(i);
+
+ if (element.skip) {
+ continue;
+ }
+ }
+ }
+
+ assertTrue("There are " + errors.size() + " errors: \n" + errors, errors.isEmpty());
+ }
}