Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class OrdertoRisk {
- public static Id recordTypeId = [Select Id From RecordType Where DeveloperName = 'Churn_Retention' Limit 1].Id;
- public static boolean ordertoriskvalue=true;
- public static void OrdertoRiskclone(List<Case> RiskwithChurn)
- {
- Map<Id,String> CaseDetails= new Map<Id,String>();
- Map<String,Case> Churncasedetails= new Map<String,case>();
- for(Integer i=0;i<RiskwithChurn.size();++i)
- {
- if(RiskwithChurn[i].RecordTypeId == recordTypeId && RiskwithChurn[i].Main_Case_Reference__c !=null)
- {
- System.debug('First Loop');
- CaseDetails.put(RiskwithChurn[i].id,RiskwithChurn[i].Main_Case_Reference__c);
- }
- }
- If(CaseDetails <> null && !CaseDetails.isEmpty())
- {
- for(case churn:[Select id,CaseNumber,Date_Order_Received__c,Rate_Plan_type_for_Case__c from case where casenumber=:CaseDetails.values()])
- {
- Churncasedetails.put(churn.casenumber,churn);
- System.debug('Second Loop');
- }
- }
- If(CaseDetails <> null && !CaseDetails.isEmpty())
- {
- for(case caseupdate:RiskwithChurn)
- {
- If(CaseDetails.containskey(caseupdate.id))
- {
- System.debug('values to check '+Churncasedetails.get(Caseupdate.Main_Case_Reference__c));
- if(Churncasedetails.get(Caseupdate.Main_Case_Reference__c) != null)
- {
- caseupdate.Date_Order_Received__c = Churncasedetails.get(Caseupdate.Main_Case_Reference__c).Date_Order_Received__c;
- caseupdate.Rate_Plan_type_for_Case__c = Churncasedetails.get(Caseupdate.Main_Case_Reference__c).Rate_Plan_type_for_Case__c;
- }
- If(Churncasedetails.get(Caseupdate.Main_Case_Reference__c) == null)
- {
- System.debug('Third Loop');
- caseupdate.addError('There is no case associated with this number '+CaseDetails.get(caseupdate.id));
- }
- }
- }
- }
- }
- }
- @istest
- public class TestOrdertoRisk {
- Static Profile standardProf = [select id from profile where name='Standard User'];
- Static User su = new User(alias = 'standt', email='ARPUTest@azugacase.com',emailencodingkey='UTF-8',FirstName='ARPU',
- lastname='Testing',languagelocalekey='en_US',localesidkey='en_US',
- profileid = standardProf.Id,timezonesidkey='America/Los_Angeles',
- username='ARPUTest@azugacase.com');
- static testmethod void TestARPUInsert()
- {
- System.runAs(su){
- Account a =new Account(Name='Internal TestARPU');
- insert a;
- List<Case> ARPUCases =new List<Case>();
- Id recordTypeId = [Select Id From RecordType Where DeveloperName = 'Customer_Order'].Id;
- Id Churnrecordtypeid= [Select id from RecordType Where DeveloperName = 'Churn_Retention'].Id;
- Id account =[Select id from account where name=:'Internal TestARPU'].id;
- Case c1 = new Case(AccountId =a.ID,Status='New',RecordTypeId=recordTypeId,Origin='Internal',
- Case_Details__c='Hard Churn',Churn_under_180_days__c='No',Reason_for_Churn__c='Product - Device',
- Revenue_effective__c=Date.today(),Azuga_Invoice_no__c='1234',Rate_Plan_type_for_Case__c='Azuga G2 Flex',
- Date_Order_Received__c=Date.today(),Contract_Term__c=1,Subscription_Rate__c=19.99,
- Payment_No__c='20',FSS_Rep__c='Francis Xavier',X3G_VZW_CDMA_OBD2_US_ONLY__c=-5,
- Subscription_Amendment_No__c='Yes',Order_Signup_date__c=Date.today(),Trial_units_billed_in_this_order__c='No',LGS_Rep__c='NA');
- insert c1;
- String cssp=[Select id,Casenumber from case where id=:c1.id].Casenumber;
- System.debug('Case DEtails '+cssp);
- //System.debug('Case MRR '+c1.Total_order_MRR__c);
- Integer count=database.countQuery('select count() from case where casenumber=:cssp');
- System.debug('Case Count'+count);
- Case c2 = new Case(AccountId =a.id,Status='New',RecordTypeId=Churnrecordtypeid,Assigned_Group__c='Risk Group',
- Case_Assigned_Staff__c='Nina Javier',Case_Category__c='Account Related',Case_Type__c='Churn',
- Case_Subtype__c='Hard Churn',Case_Reason_New__c='Product - Device',Vehicle_Make_model__c='Test',
- Vehicle_Year__c='1996',Subject='Churn_Case_Check',Main_Case_Reference__c=cssp);
- insert c2;
- System.debug('Date order info'+c2.Date_Order_Received__c);
- decimal css=[Select id,Total_order_MRR__c from case where id=:c2.id].Total_order_MRR__c;
- System.assertEquals(0.00, css);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement