Background: I am doing the unit test in ECLIPSE 2021-06 (4.20.0) on method viewSpecificResult() in HallSystem. In testHallSystem testViewSpecificResult5(), I am trying to test finding the existing application status after process application. Steps to Reproduce: 1. Run the package with testHall_Admission 2. Run the method “void testViewSpecificResult5” in testHallSystem class Actual result: It seems the system cannot find the application in the system as the system returned “null” Expected result: It should return “Admitted to Hall 2”.
I just tried this test case, there is a null problem. I suspect the code of application searching or application storage has some problems. I will pass it to the developer to solve this error.
The system was able the find the Application, but once the application was found, it got replaced to null due to the next application the system searched not fulfilling the search condition. As in the program loop, it keep updating the outData value via this code “outData = processResult.findInAdmit(target);”. To solve the keep updating problem, a break condition is added. Solution: =============== public String findResultStatus(Application target) { for (ProcessResult processResult : allResults) { outData = processResult.findInAdmit(target); if(outData!=null) break; } if(outData == null) { outData = ProcessResult.findInWaiting(target); } if(outData == null) { outData = ProcessResult.findInReject(target); } return outData; } }