Untitled

 avatar
unknown
plain_text
3 years ago
8.6 kB
4
Indexable
/**
 * @description       : 
 * @author            : ChangeMeIn@UserSettingsUnder.SFDoc
 * @group             : 
 * @last modified on  : 08-05-2021
 * @last modified by  : ChangeMeIn@UserSettingsUnder.SFDoc
**/
@isTest
public with sharing class CustomerInteractionQueriesTst{ 
    
    @isTest
    public static void listByInteractionIdAndAccountIdTest() { 

        Test.startTest();
        Account acc = new Account();
        acc.Name = 'TEST';
        insert acc;
        
        
        Interaction__c intr = new Interaction__c();
        intr.LastModifiedSubChannel__c = 'Call Center Inbound';
        insert intr;
        
        CustomerInteraction__c cint = new CustomerInteraction__c();
        cint.Interaction__c = intr.Id;
        cint.Customer__c = acc.Id;
        insert cint;
        
        
        
        String userId = UserInfo.getUserId();

        system.assertEquals(cint.Id,CustomerInteractionQueries.getInstance().listByInteractionIdAndAccountId( acc.Id, intr.Id )[0].Id);
        //CustomerInteractionQueries.getInstance().listByInteractionIdAndAccountId( 'accountId', 'interactionId' );    
        Test.stopTest();
    }
    
    @isTest
    public static void getInterlocutorByCustomerInteractionIdTest() { 

        Test.startTest();
        Account acc = new Account();
        acc.Name = 'TEST';
        Individual ind = new Individual();
        ind.LastName='RONALDO';
        insert ind;
        acc.Individual__c = ind.Id;
        insert acc;
        
        Interaction__c intr = new Interaction__c();
       	intr.Interlocutor__c=ind.Id;
        intr.Status__c='New';
        intr.LastModifiedSubChannel__c = 'Call Center Inbound';
        insert intr;
        
        CustomerInteraction__c cint = new CustomerInteraction__c();
        cint.Interaction__c = intr.Id;
        cint.Customer__c = acc.Id;
        insert cint;
        
     
        
        String userId = UserInfo.getUserId();

       system.assertEquals(ind.Id,CustomerInteractionQueries.getInstance().getInterlocutorByCustomerInteractionId( cint.Id )[0].Interaction__r.Interlocutor__c);

       //CustomerInteractionQueries.getInstance().getInterlocutorByCustomerInteractionId( 'customerInteractionId' );
       
        
        Test.stopTest();
    }
 
    @isTest
    public static void getByIdAndAccountIdTest() { 

        Test.startTest();
        Account acc = new Account();
        acc.Name = 'TEST';
        insert acc;
        
        Interaction__c intr = new Interaction__c();
        intr.LastModifiedSubChannel__c = 'Call Center Inbound';
        insert intr;
        
        CustomerInteraction__c cint = new CustomerInteraction__c();
        cint.Interaction__c = intr.Id;
        cint.Customer__c = acc.Id;
        insert cint;
        
        String userId = UserInfo.getUserId();
	
        system.assertEquals(cint.Id,CustomerInteractionQueries.getInstance().getByIdAndAccountId(cint.Customer__c, cint.Id )[0].Id);

        //CustomerInteractionQueries.getInstance().getByIdAndAccountId( 'accountId', 'interactionId' );
        
        Test.stopTest();
    }
    
          
     @isTest
    public static void listCustomerInteractionByInteractionIdAndAccountIdTest() { 

        Test.startTest();
        Account acc = new Account();
        acc.Name = 'TEST';
        insert acc;
        
        Interaction__c intr = new Interaction__c();
        intr.LastModifiedSubChannel__c = 'Call Center Inbound';
        insert intr;
        
        CustomerInteraction__c cint = new CustomerInteraction__c();
        cint.Interaction__c = intr.Id;
        cint.Customer__c = acc.Id;
        insert cint;
        
        String userId = UserInfo.getUserId();
		
        system.assertEquals(cint.Id,CustomerInteractionQueries.getInstance().listCustomerInteractionByInteractionIdAndAccountId( intr.Id, cint.Customer__c )[0].Id);


        //CustomerInteractionQueries.getInstance().listCustomerInteractionByInteractionIdAndAccountId( 'interactionId', 'accountId' );
       
        
        Test.stopTest();
    }
     @isTest
    public static void listByInteractionIdTest() { 

        Test.startTest();
        Account acc = new Account();
        acc.Name = 'TEST';
        insert acc;
        
        Interaction__c intr = new Interaction__c();
        intr.LastModifiedSubChannel__c = 'Call Center Inbound';
        insert intr;
        
        CustomerInteraction__c cint = new CustomerInteraction__c();
        cint.Interaction__c = intr.Id;
        cint.Customer__c = acc.Id;
        insert cint;
        
        String userId = UserInfo.getUserId();
        
		system.assertEquals(cint.Id,CustomerInteractionQueries.getInstance().listByInteractionId( intr.Id )[0].Id);
		//CustomerInteractionQueries.getInstance().listByInteractionId( 'interactionId' );
        
        Test.stopTest();
    }
     @isTest
    public static void listCustomerInteractionTest() { 

        Test.startTest();
        Account acc = new Account();
        acc.Name = 'TEST';
        insert acc;
        
        Interaction__c intr = new Interaction__c();
        intr.LastModifiedSubChannel__c = 'Call Center Inbound';
        insert intr;
        
        CustomerInteraction__c cint = new CustomerInteraction__c();
        cint.Interaction__c = intr.Id;
        cint.Customer__c = acc.Id;
        insert cint;
        
        String userId = UserInfo.getUserId();

		system.assertEquals(cint.Id,CustomerInteractionQueries.getInstance().listCustomerInteraction( intr.Id )[0].Id);
		//CustomerInteractionQueries.getInstance().listCustomerInteraction( 'interactionId' );
        
       
        
        Test.stopTest();
    }
     @isTest
    public static void findByIdTest() { 

        Test.startTest();
        Account acc = new Account();
        acc.Name = 'TEST';
        insert acc;
        
        Interaction__c intr = new Interaction__c();
        intr.LastModifiedSubChannel__c = 'Call Center Inbound';
        insert intr;
        
        CustomerInteraction__c cint = new CustomerInteraction__c();
        cint.Interaction__c = intr.Id;
        cint.Customer__c = acc.Id;
       
        insert cint;
        
        String userId = UserInfo.getUserId();

 		system.assertEquals(cint.Id,CustomerInteractionQueries.getInstance().findById(cint.Id).Id);
		system.assertEquals(null,CustomerInteractionQueries.getInstance().findById(acc.Id));

        //CustomerInteractionQueries.getInstance().findById( 'customerInteractionId');
        
        Test.stopTest();
    }
     
     @isTest
    public static void getLastInteractionByUserAndAccountTest() { 

        Test.startTest();
        Account acc = new Account();
        acc.Name = 'TEST';
        insert acc;
        
        Interaction__c intr = new Interaction__c();
        intr.Status__c='New';
        intr.LastModifiedSubChannel__c = 'Call Center Inbound';
        insert intr;
        
        CustomerInteraction__c cint = new CustomerInteraction__c();
        cint.Interaction__c = intr.Id;
        cint.Customer__c = acc.Id;
        
        insert cint;
        
        String userId = UserInfo.getUserId();

        system.assertEquals(cint.Id,CustomerInteractionQueries.getInstance().getLastInteractionByUserAndAccount( acc.Id, userId ).Id);
        system.assertEquals(null,CustomerInteractionQueries.getInstance().getLastInteractionByUserAndAccount( intr.Id, userId ));

        //CustomerInteractionQueries.getInstance().getLastInteractionByUserAndAccount( 'accountId', 'userid' );
        
        Test.stopTest();
    }

    @isTest static void getCountCustomerIntTest(){

        Test.startTest();
        Account acc = new Account(); 
        acc.Name = 'TEST';
        insert acc;
        
        Interaction__c intr = new Interaction__c();
        intr.Status__c='New';
        intr.LastModifiedSubChannel__c = 'Call Center Inbound';
        insert intr;  
        
        CustomerInteraction__c cint = new CustomerInteraction__c();
        cint.Interaction__c = intr.Id;
        cint.Customer__c = acc.Id;
        insert cint;
        
        String userId = UserInfo.getUserId();
        Integer result = CustomerInteractionQueries.getInstance().getCountCustomerInt(cint.Interaction__c); 
        Test.stopTest();  
        System.assertEquals(1, result, 'The result of the method getCountCustomerInt would be different of null');
}
    
}
Editor is loading...