Bug 641

Summary: Java Object Null Exception when viewResult is run before the Function Process was run
Product: 2021 CS3343 Hall Admission System Reporter: amble3232
Component: System SectionAssignee: Azim <mohamazim2>
Status: RESOLVED FIXED    
Severity: minor CC: chpang22-c
Priority: Normal    
Version: unspecified   
Hardware: PC   
OS: Windows   

Description amble3232 2021-12-04 16:12:04 HKT
Background:
I am doing the unit testing in Eclipse 2021-06 (4.20.0) on method viewResult() in HallSystem class. 
In testHallSystem(), when I try to run the viewResult() before processing the application. 

Steps to Reproduce:
1. Run the package with testHall_Admission
2. Run the method “void testViewResult” in testViewResult class

Actual result:
After the run the above steps, the system returns the error message “Cannot invoke "HallAdmissionSystem.ProcessApplication.getFinalResult()" because "this.processApplication" is null”. 

Expected result:
I expect the system will show “Waiting for processing to finish” if I view the result before the processing is done.
Comment 1 newbie 2021-12-04 16:12:46 HKT
The system should show “waiting for processing to finish” or “need to run process function”, instead of error of null. 

I will pass it to the developer to solve this error.
Comment 2 Azim 2021-12-04 16:13:29 HKT
As the set of process objects have not been created, so the system cannot output any result. But as the code is to run “Display.runDisplay("All Result", content, false);” and will not check if the process function has been run successfully. Therefore the ArrayList is null. 

To solve the showing empty ArrayList problem, a check if the sets of process objects are created needed to be implemented.

Solution:
===============
public void viewResult() {
	if(processApplication != null){
		String content = processApplication.getFinalResult();

		Display.runDisplay("All Result", content, false);
	}
	else {
		String content = "Waiting for processing to finish.";
		Display.runDisplay("All Result",content , false);

	}
}