Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
5.4 kB
1
Indexable
Never
@isTest
public with sharing class NTT_RicercaAddettoTst {
    
    @testSetup
    public static void test(){
        
        //PROVA ANDREA
        wrts_prcgvr.InstallIntegration.install();
        insert TestDataCustomer.createPhaseManagerSettingFileMetadata();
        insert TestDataCustomer.createPhaseManagerSettingOpportunity();
        insert TestDataCustomer.createActivityTemplate('Ko Cerved');
        Account acc = TestDataFactory.account().setName('BusinessName').build();
		insert acc;
 
        Opportunity opp2 = TestDataFactory.opportunity().createOpportunity().build();
        insert opp2;  
        wrts_prcgvr__ActivityTemplate__c temp = new wrts_prcgvr__ActivityTemplate__c(Name= 'Appuntamento - Rischedulazione appuntamento');
        insert temp;  
        wrts_prcgvr__Activity__c act = new wrts_prcgvr__Activity__c( 
                                                                    Account__c = acc.Id, 
                                                                    Opportunity__c = opp2.id, 
                                                                    wrts_prcgvr__ActivityTemplate__c = temp.Id,
                                                                    Detail__c = 'Primo Appuntamento',
                                                                    Reason__c = 'Appuntamento',
                                                                    Commodity__c = 'Electric' 
                                                                    ); 
        insert act;   
        //
        
		//Id recordtypeid = Schema.SObjectType.Account.getRecordTypeInfosByName().get('agency').getRecordTypeId();
		
		insert TestDataCustomer.createPhaseManagerSettingCase();
        Case caseIntCase = new Case();
        caseIntCase.NTT_TipologieAltrePrestazioni__c = 'Prestazioni/Voltura	';
        insert caseIntCase;
        
        Id recordtypeid = [SELECT Id FROM RecordType WHERE sObjectType = 'Account' AND Name = 'agency'].Id;
                           
        Account a = new Account(
            Name = 'AGENZIA D2D 2',
            RecordTypeId = recordtypeid
        );
        Database.insert(a);
        
        Contact c = new Contact(
            FirstName = 'Test',
            LastName = 'Paolo',    
            RunnerCode__c = '23432423',
            AccountId = a.Id
        );
        Database.insert(c); 
        
        Runner__c r = New Runner__c(
            RunnerCode__c = '3232'
        );
        Database.insert(r);
        //insert TestDataCustomer.createPhaseManagerSettingFileMetadata(); RIGO 9
        //insert TestDataCustomer.createPhaseManagerSettingOpportunity();  RIGO 10
        Opportunity opp = new Opportunity(Name = 'Opp Di prova',
                                          fiscalCode__c = 'DSTRCR93R12H501G',
                                          Stagename = 'closed won',
                                          CloseDate = Date.today(),
                                          SubChannel__c = 'Store WINDTRE'/*,
                                          Runner__c = [SELECT id FROM Runner__c LIMIT 1].id*/);
        insert opp;
		
        ServicePoint__c servicePoint = TestDataFactory.servicePoint().createServicePoint().build();
        insert servicePoint;
          
    }
	@isTest
    public static void ricercaAddettoTest(){
        Contact cc = [SELECT FirstName, RunnerCode__c FROM Contact];
        List<Map<String, String>> a = NTT_RicercaAddetto.ricercaAddetto('','', cc.FirstName,'','','', cc.RunnerCode__c,'');
        //List<Map<String, String>> b = NTT_RicercaAddetto.ricercaAddetto('','', '','','','', cc.RunnerCode__c,'');
    }
            
            
    @isTest
    public static void getRunnerIdTest(){
        Runner__c rr = [SELECT RunnerCode__c FROM Runner__c];
        //String idEsistente = '3232';
        String runID = NTT_RicercaAddetto.GetRunnerId(rr.RunnerCode__c);
    }
    
    @isTest
    public static void UpdateRunnerTest(){
        Runner__c runner = [SELECT Id, RunnerCode__c FROM Runner__c];
        Opportunity opp = [SELECT Id,Runner__c FROM Opportunity limit 1];
        System.assertEquals(true, NTT_RicercaAddetto.UpdateRunner(opp.id, runner.id));
    }
    /*@isTest
    public static void createActivityTest(){
        Case cas = [SELECT Id FROM Case LIMIT 1];
        List<Id> caseIds = new List<Id>();
        caseIds.add(cas.id);
        NTT_RicercaAddetto.createActivity(caseIds);
    }*/
    @isTest
    public static void updateNoteTest(){
        opportunity opp = [SELECT Id,Runner__c FROM Opportunity LIMIT 1];
        Boolean result = NTT_RicercaAddetto.updateNote(opp.id, 'test note');
    }
    @isTest
    public static void getOpportunityCompanyChannelTest(){
        ServicePoint__c sp = [SELECT id,CurrentAsset__r.CompanyChannel__c FROM ServicePoint__c LIMIT 1];
        String idStr = sp.id;
        String strg = NTT_RicercaAddetto.getOpportunityCompanyChannel(idStr);
    }
    
    @istest
    public static void CreateActivity()
    {
        test.startTest();
        list<id> listaid = new list<id>();
        list<case> lista2 = [select id from Case];
        for(case ca : lista2)
        {
            listaid.add(ca.id);
        }
        
        NTT_RicercaAddetto.CreateActivity(listaid);
        test.stopTest();
    }
    
}