You need to sign in to do that
Don't have an account?
Shriya Bhalchandran
I would like to know reason for not covering the class?
<b>Apex Class</b> public class RenewOppEndate { public static final string CRenewOppEndate = 'RenewOppEndate'; public static final string UPDATEENDATE = 'updateEndate'; public static void updateEndate(List<Opportunity> oppNewList) { try { set<Id> accIdSet = new set<Id>(); Date TempEffDate = NULL; for(Opportunity opp: oppNewList) { if(opp.AccountId != NULL && opp.Type == Label.Renewal) { accIdSet.add(opp.AccountId); } } Map<ID,Account> accMap = new Map<ID,Account>([select Id,(select Id,Effective_Date__c from Opportunities Order By Effective_Date__c DESC LIMIT 1) from Account where ID IN:accIdSet LIMIT 50000]); for(Opportunity opp : oppNewList) { if(String.isNotBlank(opp.AccountId) && opp.Type == Label.Renewal){ Account accObj = accMap.get(opp.AccountId); List<Opportunity> oldOppList = accObj.opportunities; if(oldOppList != NULL && !oldOppList.isEmpty()){ Date tempEffectiveDate = oldOppList[0].Effective_Date__c; opp.Effective_Date__c = tempEffectiveDate != NULL ? tempEffectiveDate.addYears(1) : tempEffectiveDate ; } } } } catch(exception ex) {UTIL_LoggingService.logHandledException(ex);} } } <b>Test Class </b> <b>@isTest public class RenewOppEndate_Test { private static testMethod void renewOpptyTest() { User testUser = Util02_TestData.createUser(); Account testAccount = Util02_TestData.createAccountData(); System.runAs(testUser) { Database.insert(testAccount); Opportunity opp = Util02_TestData.createOpportunity(); opp.AccountId = testAccount.id; opp.stageName = Label.Renewal; database.insert(opp); } } } </b>
Please check once below sample code :
Hope this helps you!
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
All Answers
Please check once below sample code :
Hope this helps you!
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
Hi,
it is showing error:
Final members can only be assigned in their declaration, init blocks, or constructors: RenewOppEndate