Bug 273 - [RecommendSys] java.lang.NullPointerException thrown when doing New Recommendation with invalid keyword
Summary: [RecommendSys] java.lang.NullPointerException thrown when doing New Recommend...
Status: RESOLVED FIXED
Alias: None
Product: MovieXXX
Classification: Unclassified
Component: MovieAnalysisEngine (show other bugs)
Version: 2.0
Hardware: PC Windows
: High blocker
Deadline: 2018-11-24
Assignee: salinang3-c
URL:
Depends on:
Blocks:
 
Reported: 2018-11-30 00:44 HKT by tomfong521
Modified: 2018-11-30 01:17 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tomfong521 2018-11-30 00:44:22 HKT
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)
Comment 1 salinang3-c 2018-11-30 01:17:57 HKT
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