Details: After enter keyword to filter recommendation, an java.lang.NullPointerException is thrown Reproducible steps 1. Enter "2" to select "Film Recommendation" in [System Home] 2. Enter "1" to select "Start New Recommendation" in [Office Box Prediction] 3. Enter invalid keyword (e.g. "-B salina") to process recommendation Expected results: - At step (3), error message indicating invalid input should be shown - After error message prompted, terminate new recommendation and go back to [Film Recommendation] home Actual results: - At step (3), java.lang.NumberFormatException is thrown and the program is interrupted Detailed console output: >> Enter any keyword with proper prefix to filter your customised recommendation >> -Y releaseYear >> -G genre >> -R region >> -L language >> -C directorOrActor >> Separate different types with a comma (,) and separate keywords of same type with stroke(|) >> E.g. -Y 2016, -G Romance|war, -L Finnish, -C Jacky chan|jacky keung >> >> -B salina >> Exception in thread "main" java.lang.NullPointerException >> at movieRating.RecommendSys.doNewRecommendation(RecommendSys.java:50) >> at movieRating.RecommendSys.enter(RecommendSys.java:113) >> at movieRating.Main.main(Main.java:28)
Root cause - Checking for validation of input is missing in RecommendSys::doNewRecommendation() How to fix - Added RecommendSys::isOptValid() to check validation of input, terminate new recommendation and go back to [Film Recommendation] home if invalid Expected behavior - If input is invalid, accurate error message indicating violated input rule should be shown - After error message prompted, terminate new recommendation and go back to [Film Recommendation] home Potential affected areas - RecommendSys Affected versions - >=v3 Test cases 1. Enter "2" to select "Film Recommendation" in [System Home] 2. Enter "1" to select "Start New Recommendation" in [Office Box Prediction] 3. Enter invalid keyword (e.g. "-B salina") to process recommendation Test result - At testing step(3), error message "Invalid prefix (not exist): -B salina" is shown - After error message, new recommendation is terminated and go back to [Film Recommendation] home