SHARE
TWEET

Untitled

a guest Jun 20th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class OrdertoRisk {
  2.     public static Id recordTypeId = [Select Id From RecordType Where DeveloperName = 'Churn_Retention' Limit 1].Id;
  3.         public static boolean ordertoriskvalue=true;
  4.         public static void OrdertoRiskclone(List<Case> RiskwithChurn)
  5.         {
  6.             Map<Id,String> CaseDetails= new Map<Id,String>();
  7.             Map<String,Case> Churncasedetails= new Map<String,case>();
  8.             for(Integer i=0;i<RiskwithChurn.size();++i)
  9.             {
  10.                 if(RiskwithChurn[i].RecordTypeId == recordTypeId && RiskwithChurn[i].Main_Case_Reference__c !=null)
  11.                 {
  12.                     System.debug('First Loop');
  13.                     CaseDetails.put(RiskwithChurn[i].id,RiskwithChurn[i].Main_Case_Reference__c);
  14.                 }
  15.             }
  16.             If(CaseDetails <> null && !CaseDetails.isEmpty())
  17.             {
  18.             for(case churn:[Select id,CaseNumber,Date_Order_Received__c,Rate_Plan_type_for_Case__c from case where casenumber=:CaseDetails.values()])
  19.         {
  20.             Churncasedetails.put(churn.casenumber,churn);
  21.             System.debug('Second Loop');
  22.         }
  23.         }
  24. If(CaseDetails <> null && !CaseDetails.isEmpty())
  25.         {
  26.         for(case caseupdate:RiskwithChurn)
  27.         {
  28.             If(CaseDetails.containskey(caseupdate.id))
  29.             {
  30.                 System.debug('values to check '+Churncasedetails.get(Caseupdate.Main_Case_Reference__c));
  31.                 if(Churncasedetails.get(Caseupdate.Main_Case_Reference__c) != null)
  32.                 {
  33.                     caseupdate.Date_Order_Received__c = Churncasedetails.get(Caseupdate.Main_Case_Reference__c).Date_Order_Received__c;
  34.                     caseupdate.Rate_Plan_type_for_Case__c = Churncasedetails.get(Caseupdate.Main_Case_Reference__c).Rate_Plan_type_for_Case__c;
  35.  }
  36.             If(Churncasedetails.get(Caseupdate.Main_Case_Reference__c) == null)
  37.             {
  38.                 System.debug('Third Loop');
  39.                 caseupdate.addError('There is no case associated with this number '+CaseDetails.get(caseupdate.id));
  40.             }
  41.  
  42.             }
  43.         }
  44.         }
  45.     }
  46. }
  47.      
  48. @istest
  49. public class TestOrdertoRisk {
  50.     Static Profile standardProf = [select id from profile where name='Standard User'];
  51.     Static User su = new User(alias = 'standt', email='ARPUTest@azugacase.com',emailencodingkey='UTF-8',FirstName='ARPU',
  52.                            lastname='Testing',languagelocalekey='en_US',localesidkey='en_US',
  53.                            profileid = standardProf.Id,timezonesidkey='America/Los_Angeles',
  54.                            username='ARPUTest@azugacase.com');
  55.     static testmethod void TestARPUInsert()
  56.     {
  57.         System.runAs(su){
  58.         Account a =new Account(Name='Internal TestARPU');
  59.             insert a;
  60.             List<Case> ARPUCases =new List<Case>();
  61.             Id recordTypeId = [Select Id From RecordType Where DeveloperName = 'Customer_Order'].Id;
  62.             Id Churnrecordtypeid= [Select id from RecordType Where DeveloperName = 'Churn_Retention'].Id;
  63.             Id account =[Select id from account where name=:'Internal TestARPU'].id;
  64.             Case c1 = new Case(AccountId =a.ID,Status='New',RecordTypeId=recordTypeId,Origin='Internal',
  65.                                Case_Details__c='Hard Churn',Churn_under_180_days__c='No',Reason_for_Churn__c='Product - Device',
  66.                                Revenue_effective__c=Date.today(),Azuga_Invoice_no__c='1234',Rate_Plan_type_for_Case__c='Azuga G2 Flex',
  67.                                Date_Order_Received__c=Date.today(),Contract_Term__c=1,Subscription_Rate__c=19.99,
  68.                                Payment_No__c='20',FSS_Rep__c='Francis Xavier',X3G_VZW_CDMA_OBD2_US_ONLY__c=-5,
  69.                                Subscription_Amendment_No__c='Yes',Order_Signup_date__c=Date.today(),Trial_units_billed_in_this_order__c='No',LGS_Rep__c='NA');
  70.             insert c1;
  71.         String cssp=[Select id,Casenumber from case where id=:c1.id].Casenumber;
  72.         System.debug('Case DEtails '+cssp);
  73.         //System.debug('Case MRR '+c1.Total_order_MRR__c);
  74.         Integer count=database.countQuery('select count() from case where casenumber=:cssp');
  75.         System.debug('Case Count'+count);
  76.             Case c2 = new Case(AccountId =a.id,Status='New',RecordTypeId=Churnrecordtypeid,Assigned_Group__c='Risk Group',
  77.                                Case_Assigned_Staff__c='Nina Javier',Case_Category__c='Account Related',Case_Type__c='Churn',
  78.                                Case_Subtype__c='Hard Churn',Case_Reason_New__c='Product - Device',Vehicle_Make_model__c='Test',
  79.                                Vehicle_Year__c='1996',Subject='Churn_Case_Check',Main_Case_Reference__c=cssp);
  80.             insert c2;
  81.         System.debug('Date order info'+c2.Date_Order_Received__c);
  82.             decimal css=[Select id,Total_order_MRR__c from case where id=:c2.id].Total_order_MRR__c;
  83.             System.assertEquals(0.00, css);
  84.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top