Create a Service and Implement a Caller
Create an Apex class that is a service that exposes a bulkified service method. The service closes and sets the reason for one or more given case records. Implement an Apex REST class that calls this service.
- Create an Apex class called CaseService that contains a void static method called closeCases that takes a set of Case IDs and a String parameter for the close reason.
- Create a REST Apex class called CaseCloseResource with a URL mapping /case/*/close (where * will be the Id). Implement a POST closeCase method which accepts a String reason and calls the CaseService.closeCases service method passing in the Id and close reason.
Write a Test Method using the Unit of Work
The test class must be named UnitOfWorkTest with a test method named challengeComplete. Call the commitWork method to update the database. Run the test at least once before attempting the challenge. It must pass successfully with the following assertions:
- System.assertEquals(100, [Select Id from Account].size());
- System.assertEquals(500, [Select Id from Contact].size());
- System.assertEquals(500, [Select Id from Note].size());