You need to sign in to do that
Don't have an account?
fiona gentry
Need a test class for helper method
Dear Gurus,
I will be very grateful if you could provide me a test class for below apex code
Sincere Thanks in Advance
Fiona
I will be very grateful if you could provide me a test class for below apex code
public with sharing class MaintenanceRequestHelper { public static void updateWorkOrders(Map<Id,Case>applicableCases) { // TODO: Complete the method to update workorders System.debug('*******Inside MaintenanceRequestHelper Class*******'); Map<Id, Integer> mapProduct = new Map<Id, Integer>(); List<Case> newCaseList = new List<Case>(); List<Product2> listProduct = [select Id, Maintenance_Cycle__c from Product2]; for (Product2 p : listProduct) { if (p != null) { if(p.Maintenance_Cycle__c != null){ mapProduct.put(p.Id, Integer.valueOf(p.Maintenance_Cycle__c)); } } } for(Case a: applicableCases.values()){ Case newCase = new Case(); newCase.Vehicle__c = a.Vehicle__c; newCase.Equipment__c = a.Equipment__c; newCase.Type = 'Routine Maintenance'; newCase.Subject = String.isBlank(a.Subject) ? 'Routine Maintenance Request' : a.Subject; newCase.Date_Reported__c = Date.today(); newCase.Status = 'New'; newCase.Product__c = a.Product__c; newCase.AccountId = a.AccountId; newCase.ContactId = a.ContactId; newCase.AssetId = a.AssetId; newCase.Origin = a.Origin; newCase.Reason = a.Reason; newCase.Date_Due__c = (mapProduct.get(a.Id) != null) ? (Date.today().addDays(Integer.valueOf(mapProduct.get(a.Id)))) : (Date.today()); newCaseList.add(newCase); } if(newCaseList.size() > 0){ insert newCaseList; } } }
Sincere Thanks in Advance
Fiona
Hello flona,
Please use below code.
If this code is helpful for you. then Please mark as best answer.
Thanks