Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global with sharing class SchedularForBatchApex implements Schedulable {
- global void execute(SchedulableContext sc) {
- String CLASS_NAME1 = 'Ru_Actual__c';
- try {
- BatchTargtUpdate b = new BatchTargtUpdate(CLASS_NAME1);
- Database.executeBatch(b);
- }catch(Exception ex){
- system.debug('Exception in BatchTargtUpdate(Ru_Actual__c) Execute Process submision and error is--->'+ex);
- BatchUtil.trackErrorLogs(CLASS_NAME1, 'Execute', 'Exception Line Number:' + ex.getLineNumber() + '~ Exception Type-' + ex.getTypeName()+ '~ Exception Message-' + ex.getmessage());
- }
- String CLASS_NAME2 = 'Revenue_Actual__c';
- try {
- BatchTargtUpdate b1 = new BatchTargtUpdate(CLASS_NAME2);
- Database.executeBatch(b1);
- }catch(Exception ex){
- system.debug('Exception in BatchTargtUpdate(Revenue_Actual__c) Execute Process submision and error is--->'+ex);
- BatchUtil.trackErrorLogs(CLASS_NAME1, 'Execute', 'Exception Line Number:' + ex.getLineNumber() + '~ Exception Type-' + ex.getTypeName()+ '~ Exception Message-' + ex.getmessage());
- }
- String CLASS_NAME3 = 'Direct_Revenue_Actual__c';
- try {
- BatchTargtUpdate b = new BatchTargtUpdate(CLASS_NAME3);
- Database.executeBatch(b);
- }catch(Exception ex){
- system.debug('Exception in BatchTargtUpdate(Direct_Revenue_Actual__c) Execute Process submision and error is--->'+ex);
- BatchUtil.trackErrorLogs(CLASS_NAME1, 'Execute', 'Exception Line Number:' + ex.getLineNumber() + '~ Exception Type-' + ex.getTypeName()+ '~ Exception Message-' + ex.getmessage());
- }
- String CLASS_NAME4 = 'Actual_Cost__c';
- try {
- BatchTargtUpdate b = new BatchTargtUpdate(CLASS_NAME4);
- Database.executeBatch(b);
- }catch(Exception ex){
- system.debug('Exception in BatchTargtUpdate(Actual_Cost__c) Execute Process submision and error is--->'+ex);
- BatchUtil.trackErrorLogs(CLASS_NAME1, 'Execute', 'Exception Line Number:' + ex.getLineNumber() + '~ Exception Type-' + ex.getTypeName()+ '~ Exception Message-' + ex.getmessage());
- }
- String CLASS_NAME5 = 'Average_Deal__c';
- try {
- BatchTargtUpdate b = new BatchTargtUpdate(CLASS_NAME5);
- Database.executeBatch(b);
- }catch(Exception ex){
- system.debug('Exception in BatchTargtUpdate(Average_Deal__c) Execute Process submision and error is--->'+ex);
- BatchUtil.trackErrorLogs(CLASS_NAME1, 'Execute', 'Exception Line Number:' + ex.getLineNumber() + '~ Exception Type-' + ex.getTypeName()+ '~ Exception Message-' + ex.getmessage());
- }
- String CLASS_NAME6 = 'Forecast_Actual__c';
- try {
- BatchTargtUpdate b = new BatchTargtUpdate(CLASS_NAME6);
- Database.executeBatch(b);
- }catch(Exception ex){
- system.debug('Exception in BatchTargtUpdate(Forecast_Actual__c) Execute Process submision and error is--->'+ex);
- BatchUtil.trackErrorLogs(CLASS_NAME1, 'Execute', 'Exception Line Number:' + ex.getLineNumber() + '~ Exception Type-' + ex.getTypeName()+ '~ Exception Message-' + ex.getmessage());
- }
- String CLASS_NAME7 = 'Number_of_Won_Opportunities__c';
- try {
- BatchTargtUpdate b = new BatchTargtUpdate(CLASS_NAME7);
- Database.executeBatch(b);
- }catch(Exception ex){
- system.debug('Exception in BatchTargtUpdate(Number_of_Won_Opportunities__c) Execute Process submision and error is--->'+ex);
- BatchUtil.trackErrorLogs(CLASS_NAME1, 'Execute', 'Exception Line Number:' + ex.getLineNumber() + '~ Exception Type-' + ex.getTypeName()+ '~ Exception Message-' + ex.getmessage());
- }
- String CLASS_NAME8 = 'Number_of_No_Decision_Opportunities__c';
- try {
- BatchTargtUpdate b = new BatchTargtUpdate(CLASS_NAME8);
- Database.executeBatch(b);
- }catch(Exception ex){
- system.debug('Exception in BatchTargtUpdate(Number_of_No_Decision_Opportunities__c) Execute Process submision and error is--->'+ex);
- BatchUtil.trackErrorLogs(CLASS_NAME1, 'Execute', 'Exception Line Number:' + ex.getLineNumber() + '~ Exception Type-' + ex.getTypeName()+ '~ Exception Message-' + ex.getmessage());
- }
- String CLASS_NAME9 = 'Ru_Actual__c';
- try {
- BatchTargtUpdate b = new BatchTargtUpdate(CLASS_NAME9);
- Database.executeBatch(b);
- }catch(Exception ex){
- system.debug('Exception in BatchTargtUpdate(Ru_Actual__c) Execute Process submision and error is--->'+ex);
- BatchUtil.trackErrorLogs(CLASS_NAME1, 'Execute', 'Exception Line Number:' + ex.getLineNumber() + '~ Exception Type-' + ex.getTypeName()+ '~ Exception Message-' + ex.getmessage());
- }
- String CLASS_NAME10 = 'Number_of_Closed_Opportunities__c';
- try {
- BatchTargtUpdate b = new BatchTargtUpdate(CLASS_NAME10);
- Database.executeBatch(b);
- }catch(Exception ex){
- system.debug('Exception in BatchTargtUpdate(Number_of_Closed_Opportunities__c) Execute Process submision and error is--->'+ex);
- BatchUtil.trackErrorLogs(CLASS_NAME1, 'Execute', 'Exception Line Number:' + ex.getLineNumber() + '~ Exception Type-' + ex.getTypeName()+ '~ Exception Message-' + ex.getmessage());
- }
- String CLASS_NAME11 = 'Account_Revenue__c';
- try {
- BatchTargtUpdate b = new BatchTargtUpdate(CLASS_NAME11);
- Database.executeBatch(b);
- }catch(Exception ex){
- system.debug('Exception in BatchTargtUpdate(Account_Revenue__c) Execute Process submision and error is--->'+ex);
- BatchUtil.trackErrorLogs(CLASS_NAME1, 'Execute', 'Exception Line Number:' + ex.getLineNumber() + '~ Exception Type-' + ex.getTypeName()+ '~ Exception Message-' + ex.getmessage());
- }
- String CLASS_NAME12 = 'Fulfillment_Form__c';
- try {
- BatchTargtUpdate b = new BatchTargtUpdate(CLASS_NAME12);
- Database.executeBatch(b);
- }catch(Exception ex){
- system.debug('Exception in BatchTargtUpdate(Fulfillment_Form__c) Execute Process submision and error is--->'+ex);
- BatchUtil.trackErrorLogs(CLASS_NAME12, 'Execute',
- 'Exception Line Number:' + ex.getLineNumber() +
- '~ Exception Type-' + ex.getTypeName()+
- '~ Exception Message-' + ex.getmessage());
- }
- try {
- SalesPersonBatchTargtUpdate b16 = new SalesPersonBatchTargtUpdate('Revenue_Actual__c','Actual_Revenue_for_oppty');
- Database.executeBatch(b16);
- }catch(Exception ex){
- system.debug('Exception in SalesPersonBatchTargtUpdate(Fulfillment_Form__c) Execute Process submision and error is--->'+ex);
- BatchUtil.trackErrorLogs(CLASS_NAME1, 'Execute', 'Exception Line Number:' + ex.getLineNumber() + '~ Exception Type-' + ex.getTypeName()+ '~ Exception Message-' + ex.getmessage());
- }
- try {
- SFBatchTargetUpdate b17 = new SFBatchTargetUpdate();
- Database.executeBatch(b17);
- }catch(Exception ex){
- system.debug('Exception in SFBatchTargetUpdate() Execute Process submision and error is--->'+ex);
- BatchUtil.trackErrorLogs(CLASS_NAME1, 'Execute', 'Exception Line Number:' + ex.getLineNumber() + '~ Exception Type-' + ex.getTypeName()+ '~ Exception Message-' + ex.getmessage());
- }
- }
- }
- @isTest(SeeAllData='true')
- private class SchedularForBatchApexTest {
- public static Datetime dt = Datetime.now().addMinutes(1);
- public static String CRON_EXP = '0 '+ dt.minute() + ' * ' + dt.day() + ' ' + dt.month() + ' ? ' + dt.year();
- public static testMethod void validateSchedularForBatchApex() {
- System.SchedulableContext SC;
- Database.QueryLocator QL;
- Database.BatchableContext BC;
- List<Target__c> tgtList=new List<Target__c>();
- Database.DMLOptions dml = new Database.DMLOptions();
- dml.DuplicateRuleHeader.AllowSave = true;
- //Record For BatchTargtUpdate
- Target__c t1=new Target__c(
- RecordTypeId =Schema.SObjectType.Target__c.getRecordTypeInfosByName().get('BCC').getRecordTypeId(),
- Financial_Year__c='FY2018',
- Vertical__c='Marketing',
- Forecast_Type__c='Monthly',
- Forecast_Period__c='B1-(Apr)',
- Bill_Target__c=1500000,
- Bill_Actual__c=1500000,
- Revenue_Target__c=1500000,
- Revenue_Actual__c=1500000,
- Direct_Revenue_Target__c=1500000,
- Direct_Revenue_Actual__c=1500000,
- Margin_Target__c=0.5,
- Strategic_Account__c=1500000,
- Fulfillment_Target__c=12,
- Contribution__c=1500000,
- Utilization_Target__c=0.5,
- Demand_Fulfillment__c=10,
- Forecast_Target__c=0.5,
- Forecast_Actual__c=0.5,
- Net_Win_Rate_Target__c=0.5,
- Average_Deal_Size_Actual__c=1500000,
- Rate_Target__c=0.5,
- Actual_Cost__c=1500000
- );
- tgtList.add(t1);
- Database.SaveResult sr=Database.Insert(t1,dml);
- if (sr.isSuccess()) {
- System.debug('Duplicate account has been inserted in Salesforce!');
- }
- BatchTargtUpdate obj=new GCPBatchTargtUpdate('Actual_Cost__c');
- SchedularForBatchApex obje=new SchedularForBatchApex();
- Test.startTest();
- Id jobId = System.schedule('Batch Apex Scheduler', CRON_EXP, new SchedularForBatchApex());
- System.assert(jobId != null);
- obje.execute(SC);
- Test.stopTest();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement