While testing the rdk rule for calculating LCS I am getting below errors. Have validated the rule in the rule validator utility and showing success status.
Below is the error:
<[INFO] Changes detected - recompiling the module! :source
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 3 source files with javac [debug target 11] to target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users//Documents/SailPoint IDN Rules/rule-development-kit/src/main/java/CalculateLifecycleState.java:[110,5] illegal start of type
[ERROR] /C:/Users//Documents/SailPoint IDN Rules/rule-development-kit/src/main/java/CalculateLifecycleState.java:[110,12] invalid method declaration; return type required
[ERROR] /C:/Users//Documents/SailPoint IDN Rules/rule-development-kit/src/main/java/CalculateLifecycleState.java:[110,41] <identifier> expected
[ERROR] /C:/Users//Documents/SailPoint IDN Rules/rule-development-kit/src/main/java/CalculateLifecycleState.java:[110,58] <identifier> expected
[ERROR] /C:/Users//Documents/SailPoint IDN Rules/rule-development-kit/src/main/java/CalculateLifecycleState.java:[110,70] <identifier> expected
[ERROR] /C:/Users//Documents/SailPoint IDN Rules/rule-development-kit/src/main/java/CalculateLifecycleState.java:[110,72] illegal start of type
[INFO] 6 errors/>
Would you be able to share your CalculateLifecycleState.java file and the corresponding xml rule that you’ve validated using the rule validator utility?
This will help myself and other community members dig into what might be the error.
This error is showing us issues with the .java file. Since we are dealing in two different languages beanshell via xml and java the syntax and structure of the file needs to be different.
Moved the getAttribute and return determineLifecycleState function into a main() function block.
With using java all variables must be instantiated, I initialize the identity object where in beanshell we pass this object into the beanshell context.
This file does not need to exist for the tests to run. It must be in java and helps us write the rule giving us syntax highlighting and code completion.
This code is in java as well. When you look in the src/test/java/sailpoint/ directory we setup tests where we create a beanshell interpreter.
Interpreter i = new Interpreter();
Since our rule xml file does not initialize identity we have to pass that in. (You can look at other tests in the RDK to see examples passing in more than just identity). We can mock the identity class and when certain functions are called within our xml it will return our result we’ve defined in that test. This allows you to test different logic and make sure you get the results you expect.