Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
3.5 kB
1
Indexable
Never
@IsTest
public with sharing class CEP_TRH_AccountTst {

    @TestSetup
    static void setup(){
        wrts_prcgvr.InstallIntegration.install();
        insert TestDataCustomer.createPhaseManagerSettingCase();
        insert TestDataCustomer.createPhaseManagerSettingFileMetadata();
        insert TestDataCustomer.createPhaseManagerSettingIntegrationCase();
        insert TestDataCustomer.createPhaseManagerSettingOpportunity();

		User user = TestDataCustomer.user().admindUser().build();	

        CompanyDivision__c cdSetup = new CompanyDivision__c();
        cdSetup.Name = 'Harley Davidson Motor';
        cdSetup.VATNumber__c = '13033020150';
        cdSetup.JointVentureCode__c = 'IT02-R01';
        insert cdSetup;
        User rfkam = TestDataCustomer.user().internalUser().setCompany(cdSetup.Id, cdSetup.Name).build();
        rfkam.UserName ='referente@kam.kam';
        insert rfkam;

        User u = TestDataCustomer.user().internalUser().setCompany(cdSetup.Id, cdSetup.Name).build();
        u.ReferentKAM__c =rfkam.Id;
        insert u;
        
		insert user;
        
        Account accountReseller = TestDataCustomer.account().resellrAccount().build();
        insert accountReseller;
        List < Account > listAccount = new list < Account > ();
        listAccount.add(TestDataCustomer.account().physicalPersonAccount().build());
        Account endResellerAcc = TestDataCustomer.account().build();
        endResellerAcc.Name = 'Finale Reseller';
        endResellerAcc.Segment__c = 'Reseller';
        endResellerAcc.FiscalCode__c = '12yyyyyaa';
        endResellerAcc.ParentId = accountReseller.Id;
        endResellerAcc.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_ResellerEndCustomer').getRecordTypeId();
        System.debug('** endResellerAcc rt name: '+endResellerAcc.RecordTypeDeveloperName__c);
        listAccount.add(endResellerAcc);
        listAccount.add(TestDataCustomer.account().businessAccount().setRecordtype(Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_Organization').getRecordTypeId()).build());
        listAccount[0].BusinessType__c = 'Persona fisica - ditta individuale';
        listAccount[0].Segment__c = 'Mass Market';
        listAccount[0].JointVenture__c = cdSetup.Id;

        //listAccount.add(TestDataCustomer.account().resellrAccount().build());
        insert listAccount;       
    }
    /*
    @IsTest 
    static void createCompanyDivisionForResellerAccountTest(){
        List<Account> accList = [SELECT ID, RecordTypeDeveloperName__c FROM Account];
        Test.startTest();
        CEP_TRH_Account trhAccount = new CEP_TRH_Account();
        trhAccount.createCompanyDivisionForResellerAccount(accList);
        Test.stopTest();
    }
    */
    @IsTest 
    static void updateTst(){
        Account acc = [SELECT ID, RecordTypeDeveloperName__c FROM Account Limit 1];
        Test.startTest();
        acc.Firstname__c = 'pippo';
        User u = [select id from user where username = 'userdivisiobadInternal@enel.com'];
        //System.runAs(u){
            update acc;
        //}            
        Test.stopTest();
    }

    @IsTest 
    static void deleteTst(){
        List<Account> accList = [SELECT ID, RecordTypeDeveloperName__c FROM Account];
        Test.startTest();
        delete accList;
        undelete accList;
        Test.stopTest();
    }
}