Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
106 kB
1
Indexable
Never
/**
 * Created by BADJI on 02/12/2020.
 */

@IsTest
private class CEP_ApexActionTst {

    private static Id integrationRecordType = CEP_UTL_RecordType.getRecordTypeIdByDeveloperName('CEP_RT_SwitchInGas', 'IntegrationCase__c');
 
    @TestSetup
    static void setup(){ 
        wrts_prcgvr.InstallIntegration.install();
        insert TestDataCustomer.createPhaseManagerSettingFileMetadata();
        insert TestDataCustomer.createPhaseManagerSettingCase();
        insert TestDataCustomer.createPhase('START');  
        insert TestDataCustomer.createPhase('ANNULLAMENTO');
        insert TestDataCustomer.createPhase('INLAVORAZIONE');
        insert TestDataCustomer.createPhase('ANNULLATO');
        insert TestDataCustomer.createPhase('CHIUSO'); 
        insert TestDataCustomer.createPhase('Creato');
        insert TestDataCustomer.createPhaseManagerSettingIntegrationCase();
        insert TestDataCustomer.createPhaseManagerSettingOpportunity();
        insert TestDataCustomer.createPhase('In Archiviazione');
        insert TestDataCustomer.createPhase('Annullamento Integrato'); 
        

        //User u = TestDataCustomer.user().admindUser().build();
        wrts_prcgvr__PhaseTransition__c pt = new wrts_prcgvr__PhaseTransition__c(
            wrts_prcgvr__Code__c = 'code',
            wrts_prcgvr__Type__c = 'A',
            wrts_prcgvr__RecordTypeId__c = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get('SwitchIn_GAS').getRecordTypeId(),
            wrts_prcgvr__RecordTypeName__c = 'SwitchIn_GAS',
            wrts_prcgvr__OriginPhase__c = 'RE010',
            wrts_prcgvr__DestinationPhase__c = 'RC010',
            wrts_prcgvr__Tags__c = 'Annullamento Integrato'
        );
        insert pt;

        wrts_prcgvr__PhaseTransition__c pt1 = new wrts_prcgvr__PhaseTransition__c(
            wrts_prcgvr__Code__c = 'code1',
            wrts_prcgvr__Type__c = 'A',
            wrts_prcgvr__RecordTypeId__c = Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CEP_RT_PDC').getRecordTypeId(),
            wrts_prcgvr__RecordTypeName__c = 'CEP_RT_PDC',
            wrts_prcgvr__OriginPhase__c = 'Confermata',
            wrts_prcgvr__DestinationPhase__c = 'Non Accettata',
            wrts_prcgvr__Tags__c = 'Annullamento Integrato'
        );
        insert pt1;

        wrts_prcgvr__PhaseTransition__c pt2 = new wrts_prcgvr__PhaseTransition__c(
            wrts_prcgvr__Code__c = 'code2',
            wrts_prcgvr__Type__c = 'A',
            wrts_prcgvr__RecordTypeId__c = Schema.SObjectType.IntegrationCase__c.getRecordTypeInfosByDeveloperName().get('CEP_RT_Cancellation').getRecordTypeId(),
            wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation',
            wrts_prcgvr__OriginPhase__c = 'START',
            wrts_prcgvr__DestinationPhase__c = 'INVIO',
            wrts_prcgvr__Tags__c = 'Annullamento Integrato'
        );
        insert pt2;

        wrts_prcgvr__PhaseTransition__c pt3 = new wrts_prcgvr__PhaseTransition__c(
            wrts_prcgvr__Code__c = 'code3',
            wrts_prcgvr__Type__c = 'A',
            wrts_prcgvr__RecordTypeId__c = Schema.SObjectType.IntegrationCase__c.getRecordTypeInfosByDeveloperName().get('CEP_RT_ActivationEle').getRecordTypeId(),
            wrts_prcgvr__RecordTypeName__c = 'CEP_RT_ActivationEle',
            wrts_prcgvr__OriginPhase__c = 'START',
            wrts_prcgvr__DestinationPhase__c = 'INVIO',
            wrts_prcgvr__Tags__c = 'Annullamento Integrato'
        );
        insert pt3;

        

        wrts_prcgvr__PhaseTransition__c pt4 = new wrts_prcgvr__PhaseTransition__c(
            wrts_prcgvr__Code__c = 'code', 
            wrts_prcgvr__Type__c = 'A', 
            wrts_prcgvr__RecordTypeId__c = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get('Activation_ELE').getRecordTypeId(),
            wrts_prcgvr__OriginPhase__c = 'CHIUSO',  
            wrts_prcgvr__DestinationPhase__c = 'ANNULLATO', 
            wrts_prcgvr__RecordTypeName__c = 'Activation_ELE',
            wrts_prcgvr__Tags__c = 'Annullamento Integrato'
        );  
        insert pt4;  

        wrts_prcgvr__PhaseTransition__c pt5 = new wrts_prcgvr__PhaseTransition__c(
            wrts_prcgvr__Code__c = 'code',
            wrts_prcgvr__Type__c = 'A',
            wrts_prcgvr__RecordTypeId__c = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get('Activation_ELE').getRecordTypeId(),
            wrts_prcgvr__OriginPhase__c = 'ANNULLATO',
            wrts_prcgvr__DestinationPhase__c = 'CHIUSO',  
            wrts_prcgvr__RecordTypeName__c = 'Activation_ELE',
            wrts_prcgvr__Tags__c = 'Annullamento Integrato'
        );
        insert pt5; 

        wrts_prcgvr__PhaseTransition__c pt6 = new wrts_prcgvr__PhaseTransition__c(
        wrts_prcgvr__Code__c = 'code1',
        wrts_prcgvr__Type__c = 'A',
        wrts_prcgvr__RecordTypeId__c = Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CEP_RT_PDC').getRecordTypeId(),
        wrts_prcgvr__RecordTypeName__c = 'CEP_RT_PDC',
        wrts_prcgvr__OriginPhase__c = 'START', 
        wrts_prcgvr__DestinationPhase__c = 'START', 
        wrts_prcgvr__Tags__c = 'Annullamento Integrato'
        );
        insert pt6; 
        Test.startTest();
        CancellationRequest__c cancellationRequestCase = TestDataFactory.cancellationRequest().newCancellationRequestBuilder('Case').build();
        insert cancellationRequestCase;

        CancellationRequest__c cancellationRequestDossier = TestDataFactory.cancellationRequest().newCancellationRequestBuilder('Dossier').build();
        insert cancellationRequestDossier;

        Account acc = TestDataCustomer.account().businessAccount().build();
        insert acc;
        Account accPF = TestDataCustomer.account().physicalPersonAccount().build();
        accPF.Segment__c = 'Mass Market';
        insert accPF;

        Individual individual = TestDataCustomer.individual().createIndividual().build();
        insert individual;

        Contact contact = TestDataCustomer.contact().createContact().build();
        contact.AccountId = acc.Id;
        contact.IndividualId = individual.Id;
        insert contact;

        Opportunity opportunity = TestDataCustomer.opportunity().createOpportunity().build();
        opportunity.AccountId = acc.Id; 
        opportunity.Phase__c = 'Confermata';
        opportunity.RequestType__c = 'Offerta B2B';   
        opportunity.SignatureDate__c = Date.today(); 
        opportunity.RecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CEP_RT_Business').getRecordTypeId();
        opportunity.SignatureDate__c = System.now();
        opportunity.RethinkingDate__c = Date.today();
        insert opportunity;

        ServicePoint__c servicePoint = TestDataCustomer.servicePoint().createServicePoint().build();
        servicePoint.SiteApartment__c = 'Test'; 
        servicePoint.MeterStatus__c = 'Chiuso'; 
        insert servicePoint;

        List<OpportunityServiceItem__c> listOsis = new List<OpportunityServiceItem__c>();
        for (Integer i = 0; i<5; i++){
            OpportunityServiceItem__c opportunityServiceItem = TestDataCustomer.opportunityServiceItem().createOpportunityServiceItem().build();
            opportunityServiceItem.Opportunity__c = opportunity.Id;
            opportunityServiceItem.Contact__c = contact.Id;
            opportunityServiceItem.Account__c = acc.Id;
            opportunityServiceItem.RightToRethink__c = 'si';
            opportunityServiceItem.PointStreetType__c = 'Viale';
            opportunityServiceItem.RethinkingStatus__c = 'In Attesa'; 
            opportunityServiceItem.ServicePoint__c = servicePoint.Id; 
            opportunityServiceItem.RecordTypeId = Schema.SObjectType.OpportunityServiceItem__c.getRecordTypeInfosByDeveloperName().get('Electric').getRecordTypeId();
            opportunityServiceItem.Process__c = 'CAMBIO PRODOTTO';   
            opportunityServiceItem.Market__c = 'Salvaguardia';
            listOsis.add(opportunityServiceItem); 
        }
        insert listOsis;

        ContractAccount__c ca = new ContractAccount__c();
        ca.Account__c = acc.Id; 
        ca.SapCode__c = '002802214269';
        insert ca; 


        

        Asset asset = new Asset();
        asset.Name              = 'AssetEle';
        asset.ServicePoint__c   = servicePoint.id;
        asset.Status            = 'Archiviato';  
        asset.AccountId         = acc.Id;
        asset.UsageEndDate      = Date.today();
        asset.ActivationDate__c = Date.today();
        asset.RecordTypeId      = Schema.SObjectType.Asset.getRecordTypeInfosByDeveloperName().get('CEP_RT_Commodity').getRecordTypeId(); 
        asset.DispatchingContractCode__c = 'DP1005';
        insert asset; 

        servicePoint.CurrentAsset__c = asset.Id; 
        update servicePoint;
        
        Case myCase = TestDataFactory.caseRecordBuilder().newCase().build();
        myCase.AccountId = acc.Id;
        myCase.OpportunityServiceItem__c = listOsis[0].Id; 
        myCase.CalculatedSupplyStartDate__c = Date.today();
        myCase.Opportunity__c = opportunity.Id;
        myCase.SubChannel__c = 'Door to Door app'; 
        insert myCase;
        Test.stopTest();


        Pricebook2 standardPricebook = new Pricebook2(
            Id = Test.getStandardPricebookId(),
            IsActive = true
        );
        update standardPricebook;

        //System.runAs(u){
            IntegrationCase__c ic = TestDataCustomer.integrationCase().createIntegrationCase(myCase.Id, accPF.Id).build();
            ic.RecordTypeId = Schema.SObjectType.IntegrationCase__c.getRecordTypeInfosByDeveloperName().get('CEP_RT_ActivationGas').getRecordTypeId();  
            ic.ServicePoint__c = servicePoint.Id;
            System.debug('listOsis[0].Id' + listOsis[0].Id); 
            ic.OpportunityServiceItem__c = listOsis[0].Id;  
            ic.Case__c = myCase.Id; 
            ic.CancellationReason__c = 'prova1'; 
            ic.ContractAccount__c = ca.Id; 
            ic.Asset__c = asset.Id;   
            ic.TechnicalDataReceivingDate__c = Date.today();
            insert ic; 
        //}

        Product2 pOffer = new Product2();
        pOffer.Name 					= 'OFFERTA';
        pOffer.VisibilityGroup__c 		= 'Mass Market - Small Business';
        pOffer.IsActive 				= true;
        pOffer.MarketSegment__c 		= 'Mass Market';
        pOffer.DedicatedCampaign__c     = 'Wind3';
        pOffer.Key__c 					= 'OFFERTA';
        pOffer.RecordTypeId 			= Schema.SObjectType.Product2.getRecordTypeInfosByDeveloperName().get('CEP_RT_Commodity').getRecordTypeId();
        insert pOffer;

        List<SBQQ__ProductFeature__c> featureIdPrezzo = new List<SBQQ__ProductFeature__c>();
        featureIdPrezzo.add(new SBQQ__ProductFeature__c(SBQQ__Number__c = 1, Name = 'ID PREZZO', SBQQ__ConfiguredSKU__c = pOffer.Id, SBQQ__OptionSelectionMethod__c = 'Click'));
        insert featureIdPrezzo;

        Product2 pIdPrezzo = new Product2();
        pIdPrezzo.Name 					= 'IdPrezzo';
        pIdPrezzo.VisibilityGroup__c 	= 'Mass Market - Small Business';
        pIdPrezzo.IsActive 				= true;
        pIdPrezzo.MarketSegment__c 		= 'Mass Market';
        pIdPrezzo.DedicatedCampaign__c     = 'Wind3'; 
        pIdPrezzo.Commodity__c 			= 'Elettrico';
        pIdPrezzo.RecordTypeId 			= Schema.SObjectType.Product2.getRecordTypeInfosByDeveloperName().get('CEP_RT_IdPrezzo').getRecordTypeId();
        insert pIdPrezzo;


        listOsis[0].Product__c = pIdPrezzo.Id; 

        update listOsis[0]; 


        SBQQ__Quote__c q = new SBQQ__Quote__c();
        q.MarketSegment__c = 'Mass Market';
        q.SBQQ__Opportunity2__c = opportunity.Id;
        q.SBQQ__PricebookId__c = standardPricebook.Id;
        insert q;

        List<SBQQ__QuoteLine__c> qlList = new List<SBQQ__QuoteLine__c>();
        qlList.add(new SBQQ__QuoteLine__c(SBQQ__Quote__c = q.Id,  OpportunityServiceItem__c = listOsis[0].Id, SBQQ__Product__c = pIdPrezzo.Id));
        insert qlList; 
        Asset ast = new Asset();
        ast.AccountId = acc.Id;
        ast.ContactId = contact.Id;
        ast.Name = 'test';
        ast.PurchaseDate = Date.today();
        ast.DispatchingContractCode__c = 'DP1005';
        insert ast;


        FileMetadata__c fileMetaData2 = TestDataCustomer.FileMetadata().build();
        fileMetaData2.Opportunity__c = opportunity.Id;
        fileMetaData2.Case__c = myCase.Id;
        fileMetaData2.RecordId__c = opportunity.Id; 
        //fileMetaData.Phase__c = 'Stampato';
        insert fileMetaData2;
    }

    @IsTest
    static void executeTest() {

        //try{
        Test.startTest();
        //User u = [SELECT Id FROM User LIMIT 1];     
        //System.runAs(u){     
            IntegrationCase__c integrationCase = [SELECT Asset__r.PurchaseDate, Asset__r.ActivationDate__c, OpportunityServiceItem__r.Asset__r.ActivationDate__c, ServicePoint__r.MeterStatus__c, CancellationReason__c,Status__c, ServicePoint__r.SiteApartment__c, OpportunityServiceItem__r.ServicePoint__r.CurrentAsset__c, ContractAccount__c, Phase__c, OpportunityServiceItem__c, Process__c,Asset__c, Id , RecordTypeId, Case__c, Case__r.RecordType.DeveloperName, Account__c, Opportunity__c, ServicePoint__c, CustomerCode__c, GasSystem__c, 
            SapContract__c, ReactiveReadingF1__c, PowerReadingF3__c, ReactiveReadingF2__c, ReactiveReadingF0__c, DistributorNotes__c, ReactiveReadingF3__c, PowerReadingF2__c, 
            ActiveReadingF2__c, CorrectorReading__c, ActiveReadingF0__c, MeterProductionYear__c, ActiveReadingF3__c, CorrectorNumber__c, TechnicalDataReceivingDate__c, BelowThreshold__c,
            ActiveReadingF1__c, ActiveReadingF4__c, ReactiveReadingF4__c, MeterReading__c, PowerReadingF1__c, PowerReadingF0__c, ContractualAccountAndAnagraficOutcome__c, Commodity__c,Case__r.CalculatedSupplyStartDate__c,OpportunityRecordType__c FROM IntegrationCase__c LIMIT 1];
            System.debug('>>>integrationCase: ' + integrationCase);       

         

        Opportunity opp = [SELECT SubChannel__c, CancellationReason__c, 
            Id, Name, StageName,ContractSignedDate__c, Pricebook2Id, CreatedById, OwnerId, ThirdPartySolicitationConsent__c,
            CompanyDivision__c,CompanyDivision__r.Name,CustomerInteraction__c, CreditCheckFullStatus__c, Commodity__c, FixingType__c,
            AccountId,ContractId, ContactDigitalCompletion__c, CompletionMode__c, Email__c, ViewState__c, RecordTypeId, Channel__c,
            ConfirmationCall__c, BillingProfile__c, Contact__c, Phase__c, DifferentMailingAddressFlag__c, DifferentCommunicationAddressFlag__c,
            DifferentBillingAddressFlag__c, OpprtunityType__c, Duration__c, ConsumptionType__c, PricingType__c, SupplyStartDate__c, SupplyEndDate__c,
            TotalVolumesPeak__c, TotalVolumesOffPeak__c, TotalVolumesF0__c, TotalVolumesF1__c, TotalVolumesF2__c, TotalVolumesF3__c,RequestType__c, FinalClientContract__c,
            TotalMargin__c, SignatureDate__c, Agency__c, ContactSeller__c, ContractManagementConsent__c, SolicitationConsent__c,
            LoyaltyConsent__c, ProfilingConsent__c, RethinkingDate__c 
            FROM Opportunity  
            LIMIT 1]; 
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__DestinationPhase__c,wrts_prcgvr__Label__c,wrts_prcgvr__Type__c FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];
        Case c = new Case();
        c.AccountId = opp.AccountId; 
        c.ContactDigitalCompletion__c = opp.Contact__c;
		c.Status = 'Chiuso';
		c.Origin = 'Email';
		c.Priority = 'Medium';
		c.Phase__c = 'CHIUSO';
        c.RecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get('Activation_ELE').getRecordTypeId();
        OpportunityServiceItem__c osi = [SELECT Id, Process__c FROM OpportunityServiceItem__c LIMIT 1];
        osi.RightToRethink__c = 'SI'; 
        osi.Process__c = 'CAMBIO PRODOTTO';  
        osi.Effectivedate__c = Date.today();
        update osi;
        c.OpportunityServiceItem__c = osi.Id; 
        insert c;  
        integrationCase.Case__c = c.Id; 
        integrationCase.OpportunityServiceItem__c = osi.Id;  
        integrationCase.RecordTypeId = CEP_UTL_RecordType.getRecordTypeIdByDeveloperName('CEP_RT_VAS', 'IntegrationCase__c');
        update integrationCase;
        Asset ast = [SELECT Id,DispatchingContractCode__c, PurchaseDate FROM Asset LIMIT 1];
        ast.PurchaseDate = Date.today(); 
        ast.DispatchingContractCode__c = 'DP1005';
        integrationCase.Asset__c = ast.Id;
        update integrationCase;
        SObject obj = integrationCase; 
        System.debug('>>>obj: ' + obj);

        //-----------------------method = createAsset--------------
        CEP_TRH_BaseTrigger.skipAll = true;    
        Object params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'createAsset'
        };
        CEP_ApexAction apexAction = new CEP_ApexAction();
        Object result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = calcCaseCalculatedSupplyStartDateEle--------------
        integrationCase.RecordTypeId = CEP_UTL_RecordType.getRecordTypeIdByDeveloperName('CEP_RT_SwitchInEle', 'IntegrationCase__c'); 
        integrationCase.Opportunity__c = opp.Id; 
        update integrationCase; 
        Case caseEle = [SELECT Id, RecordTypeId FROM Case WHERE Id = :integrationCase.Case__c];
        caseEle.RecordTypeId = CEP_UTL_RecordType.getRecordTypeIdByDeveloperName('SwitchIn_ELE', 'Case');
        update caseEle;
        obj = opp;
        params =(Object) new Map<String, Object>{
        'transition' =>transition,
        'sender' => obj,
        'method'=>'calcCaseCalculatedSupplyStartDateEle'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

 
        //-----------------------method = calcCaseCalculatedSupplyStartDateGas--------------
        integrationCase.RecordTypeId = integrationRecordType; 
        System.debug('integrationCase.RecordTypeId' + integrationCase.RecordTypeId); 
        integrationCase.Status__c = 'Distributore Accreditato e Disponibilità Gas REMI';
        update integrationCase;  
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
        'transition' =>transition,
        'sender' => obj, 
        'method'=>'calcCaseCalculatedSupplyStartDateGas'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);
 

        //-----------------------method = startOnConditionProcess--------------
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'startOnConditionProcess'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = closeCancellationCase--------------
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'closeCancellationCase'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = createContract--------------
        obj = opp;
        System.debug('**** obj '+obj);
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'createContract'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = goNextPhaseIntCaseOpp--------------
        /* obj = integrationCase; 
        System.debug('**** obj '+obj);
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'goNextPhaseIntCaseOpp'  
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);  */

        //-----------------------method = rethinkingDeadLineSimulation--------------
        obj = opp;
        System.debug('**** obj '+obj);
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'rethinkingDeadLineSimulation'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        

        //-----------------------method = rethinkingCasePositiveSimulation--------------
        Case cases = [SELECT Id, Opportunity__c FROM Case LIMIT 1];
        obj = cases;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'rethinkingCasePositiveSimulation'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = rethinkingCaseNegativeSimulation--------------
        cases = [SELECT Id, Opportunity__c FROM Case LIMIT 1];
        obj = cases;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'rethinkingCaseNegativeSimulation'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //----------method = createDomiciliationCases------------
        obj = opp;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'createDomiciliationCases'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = updateCaseStatus--------------
        obj = integrationCase;
        System.debug('#### updateCaseStatus Test');
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'updateCaseStatus' 
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);
        
        //-----------------------method = insertCustomRemiderForDistributorSolicit--------------
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'insertCustomRemiderForDistributorSolicit'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = startDomiciliazione--------------
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'startDomiciliazione'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = invokeEbdm--------------
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'invokeEbdm'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = calculateRethinkingStatus--------------
        obj = opp;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'calculateRethinkingStatus'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = moveDomiciliationCaseAndIC--------------
        obj = opp;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'moveDomiciliationCaseAndIC'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = cancelDomiciliationCaseAndIC--------------
        obj = opp;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'cancelDomiciliationCaseAndIC'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = avvioANC--------------
        obj = opp;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'avvioANC'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = updateCaseStatusAnnullato--------------
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'updateCaseStatusAnnullato'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = updateCaseStatusInviato--------------
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'updateCaseStatusInviato'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = updateCaseStatusInLavorazione--------------
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'updateCaseStatusInLavorazione'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = updateCaseStatusChiuso--------------
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'updateCaseStatusChiuso'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = closeSafeGuard--------------
        obj = integrationCase; 
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'closeSafeGuard'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null); 
        
        //-----------------------method = closePrecheckAuthorization--------------
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'closePrecheckAuthorization'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null); 

        //-----------------------method = UpdateAssetMeterStatus--------------
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'UpdateAssetMeterStatus'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = createOffer--------------
        obj = opp;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'createOffer'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);


        //-----------------------method = sendNotificaAggiornamentoApp--------------
        opp.SubChannel__c = 'Door to Door app'; 
        transition.wrts_prcgvr__DestinationPhase__c = 'Chiusa Persa';
        obj = opp; 
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj, 
            'method'=>'sendNotificaAggiornamentoApp'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

         //-----------------------method = updateAccountBrand--------------
         obj = opp;
         params =(Object) new Map<String, Object>{
             'transition' =>transition,
             'sender' => obj,
             'method'=>'updateAccountBrand' 
         };
         result = apexAction.execute(params);
         System.assertEquals(true, result == null);

        //-----------------------method = createOrderManagementChain--------------
        /*         obj = opp;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'createOrderManagementChain'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null); */

        //-----------------------method = usageContractUpdate--------------
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'usageContractUpdate'
        };
        apexAction.execute(params);

        //-----------------------method = usageContractUpdate--------------
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'invokeEbdmSync'
        };
        apexAction.execute(params);
        
        Test.stopTest();
    } /* catch(Exception e){
        System.assertEquals(e.getMessage(), e.getMessage(), 'The Message would be Error Exception');
    }  */
    //}
//}

    @IsTest
    static void executeTest2() {

        //try{
        Test.startTest();
        User u = [SELECT Id FROM User LIMIT 1];  
        //System.runAs(u){  
            IntegrationCase__c integrationCase = [SELECT Status__c,CancellationReason__c, Asset__c, Id , RecordTypeId, RecordType.DeveloperName, Case__c, Case__r.RecordType.DeveloperName, Account__c, Opportunity__c, ServicePoint__c, CustomerCode__c, GasSystem__c, 
            SapContract__c, ReactiveReadingF1__c, PowerReadingF3__c, ReactiveReadingF2__c, ReactiveReadingF0__c, DistributorNotes__c, ReactiveReadingF3__c, PowerReadingF2__c, 
            ActiveReadingF2__c, CorrectorReading__c, ActiveReadingF0__c, MeterProductionYear__c, ActiveReadingF3__c, CorrectorNumber__c, TechnicalDataReceivingDate__c, OpportunityServiceItem__c,
            ActiveReadingF1__c, ActiveReadingF4__c, ReactiveReadingF4__c, MeterReading__c, PowerReadingF1__c, PowerReadingF0__c, ContractualAccountAndAnagraficOutcome__c FROM IntegrationCase__c LIMIT 1];
            System.debug('>>>integrationCase: ' + integrationCase);  

        Opportunity opp = [SELECT Brand__c, 
            Id, Name, StageName,ContractSignedDate__c, Pricebook2Id, CreatedById, OwnerId, ThirdPartySolicitationConsent__c,
            CompanyDivision__c,CompanyDivision__r.Name,CustomerInteraction__c, CreditCheckFullStatus__c, Commodity__c, FixingType__c,
            AccountId,ContractId, ContactDigitalCompletion__c, CompletionMode__c, Email__c, ViewState__c, RecordTypeId, Channel__c,
            ConfirmationCall__c, BillingProfile__c, Contact__c, Phase__c, DifferentMailingAddressFlag__c, DifferentCommunicationAddressFlag__c,
            DifferentBillingAddressFlag__c, OpprtunityType__c, Duration__c, ConsumptionType__c, PricingType__c, SupplyStartDate__c, SupplyEndDate__c,
            TotalVolumesPeak__c, TotalVolumesOffPeak__c, TotalVolumesF0__c, TotalVolumesF1__c, TotalVolumesF2__c, TotalVolumesF3__c,RequestType__c, FinalClientContract__c,
            TotalMargin__c, SignatureDate__c, Agency__c, ContactSeller__c, ContractManagementConsent__c, SolicitationConsent__c,
            LoyaltyConsent__c, ProfilingConsent__c
            FROM Opportunity 
            LIMIT 1]; 
        List<wrts_prcgvr__PhaseTransition__c> transitionList = [SELECT Id, wrts_prcgvr__Tags__c, wrts_prcgvr__DestinationPhase__c, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__Code__c, wrts_prcgvr__RecordTypeName__c, wrts_prcgvr__Type__c, wrts_prcgvr__RecordTypeId__c 
                                                        FROM wrts_prcgvr__PhaseTransition__c ];
        System.debug('>>>transitionList: ' + transitionList);

        Case c = new Case();
        c.AccountId = opp.AccountId;
        c.ContactDigitalCompletion__c = opp.Contact__c;
        c.Status = 'Chiuso';
        c.Origin = 'Email';
        c.Priority = 'Medium';
        c.CalculatedSupplyStartDate__c = Date.today(); 
        c.Phase__c = 'CHIUSO';
        c.RecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get('Activation_ELE').getRecordTypeId();
        insert c;

        integrationCase.Case__c = c.Id;
        update integrationCase;

        SObject obj = integrationCase;
        System.debug('>>>obj: ' + obj);
        
        Object params;
        Object result;
        CEP_ApexAction apexAction = new CEP_ApexAction();
        CEP_TRH_BaseTrigger.skipAll = true;   
        //-----------------------method = startAcg1Process--------------
        wrts_prcgvr__PhaseTransition__c transition = new wrts_prcgvr__PhaseTransition__c();
        for(wrts_prcgvr__PhaseTransition__c pt : transitionList) {
            if(pt.wrts_prcgvr__RecordTypeName__c == integrationCase.RecordType.DeveloperName) { 
                transition = pt;   
            }
        }  
        
        System.debug('transition' + transition);

        /*  System.debug('>>>transition: ' + transition);
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'startAcg1Process'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null); */

        //-----------------------method = createServicePoint--------------
        opportunity opp2 = new Opportunity();
        opp2.Name = 'opportunity1';
        opp2.StageName = 'Prospecting';
        opp2.Channel__c = 'Punti fisici';
        opp2.SubChannel__c = 'Sportello';
        opp2.Phase__c = 'Bozza';
        opp2.RecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CEP_RT_Business').getRecordTypeId();
        opp2.CloseDate = system.today();
        insert opp2;
        OpportunityServiceItem__c  oppSi = TestDataCustomer.opportunityServiceItem().createOpportunityServiceItem().build();
        oppSi.Opportunity__c = opp2.Id;
        oppSi.Process__c = 'ATTIVAZIONE VAS'; 
        oppSi.PointStreetType__c = 'Via';
        oppSi.PointStreetName__c = 'Roma';
        oppSi.PointStreetNumber__c = '10';
        oppSi.PointPostalCode__c = '00012';
        oppSi.PointCity__c = 'Guidonia Montecelio';
        oppSi.PointIstatCode__c = '058047';
        oppSi.PointProvince__c = 'RM';
        oppSi.PointCountry__c = 'Italia';
        insert oppSi; 
        obj = opp2; 
        CEP_TRH_BaseTrigger.skipAll = true;   
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'createServicePoint'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = createCustomReminder--------------
        obj = opp2;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'createCustomReminder'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //------------------------method = invokeNewAppointmentTouchPoint-----------------
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'invokeNewAppointmentTouchPoint'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //------------------------method = goNextPhaseIntCaseOpp-----------------
        /* obj = integrationCase;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'goNextPhaseIntCaseOpp'  
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null); */

        //------------------------method = createOrderManagementChain-----------------
        
    
        obj = opp;  
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj, 
            'method'=>'createOrderManagementChain'
        }; 
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //------------------------method = insertAE1Reminder-----------------
        integrationCase.Case__c = c.Id;   
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'insertAE1Reminder'
        }; 
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //------------------------method = insertACG1Reminder-----------------
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'insertACG1Reminder'
        }; 
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //------------------------method = startAcg1Process-----------------
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'startAcg1Process' 
        }; 
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);
        //-----------------------method = calculateRethinkingDate--------------
        obj = opp2;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'calculateRethinkingDate'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = notifyKamAfterOppApproved--------------
        opp2.RequestType__c = 'Offerta B2B';
        opp2.OwnerId = u.Id;
        //update opp2;  
        obj = opp2;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'notifyKamAfterOppApproved'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = manageRiprendi--------------
        obj = opp2;
        params =(Object) new Map<String, Object>{
        'transition' =>transition,
        'sender' => obj,
        'method'=>'manageRiprendi'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = setProductsTreatment--------------
        obj = opp2;
        params =(Object) new Map<String, Object>{
        'transition' =>transition,
        'sender' => obj, 
        'method'=>'setProductsTreatment'
        }; 
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = invioNotificaRichiestaAcquistoEnergiaEm-------------- 
        obj = opp2;
        params =(Object) new Map<String, Object>{
        'transition' =>transition,
        'sender' => obj,
        'method'=>'invioNotificaRichiestaAcquistoEnergiaEm'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = invioNotificaRichiestaAcquistoEnergiaEm--------------
        obj = opp2;
        params =(Object) new Map<String, Object>{
        'transition' =>transition,
        'sender' => obj,
        'method'=>'invioNotificaRichiestaAcquistoEnergiaEm'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = positiveClosureCA--------------
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
        'transition' =>transition,
        'sender' => obj,
        'method'=>'positiveClosureCA'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = updateDomiciliationCase--------------
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
        'transition' =>transition,
        'sender' => obj,
        'method'=>'updateDomiciliationCase'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = negativeClosureCA--------------
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
        'transition' =>transition,
        'sender' => obj,
        'method'=>'negativeClosureCA'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = ricalculateSwitchDateEle--------------
        obj = integrationCase;
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'ricalculateSwitchDateEle'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = ricalculateSwitchDateGas--------------
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'ricalculateSwitchDateGas'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);
        //-----------------------method = ricalculateTransferDate--------------
        params =(Object) new Map<String, Object>{
            'transition' =>transition,
            'sender' => obj,
            'method'=>'ricalculateTransferDate'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);

        //-----------------------method = customReminderCreation--------------
        /*  obj = opp2;
        System.debug('**** obj '+obj);
        params =(Object) new Map<String, Object>{
        'transition' =>transition,
        'sender' => obj,
        'method'=>'customReminderCreation'
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null); */

        Test.stopTest();
    }/* catch(Exception e){
        System.assertEquals(e.getMessage(), e.getMessage(), 'The Message would be Error Exception');
    } */
    //}
 

    @isTest 
    static void testnegativeClosureCA(){   

        //try{
        Test.startTest(); 

        User u = [SELECT Id FROM User LIMIT 1];  
        //System.runAs(u){   
            IntegrationCase__c integrationCase = [SELECT Phase__c, Status__c,CancellationReason__c, Asset__c, Id , RecordTypeId, RecordType.DeveloperName, Case__c, Case__r.RecordType.DeveloperName, Account__c, Opportunity__c, ServicePoint__c, CustomerCode__c, GasSystem__c, 
            SapContract__c, ReactiveReadingF1__c, PowerReadingF3__c, ReactiveReadingF2__c, ReactiveReadingF0__c, DistributorNotes__c, ReactiveReadingF3__c, PowerReadingF2__c, 
            ActiveReadingF2__c, CorrectorReading__c, ActiveReadingF0__c, MeterProductionYear__c, ActiveReadingF3__c, CorrectorNumber__c, TechnicalDataReceivingDate__c, 
            ActiveReadingF1__c, ActiveReadingF4__c, ReactiveReadingF4__c, MeterReading__c, PowerReadingF1__c, PowerReadingF0__c, ContractualAccountAndAnagraficOutcome__c FROM IntegrationCase__c LIMIT 1];
            System.debug('>>>integrationCase: ' + integrationCase);  

        Opportunity opp = [SELECT  
            Id, Name, StageName,ContractSignedDate__c, Pricebook2Id, CreatedById, OwnerId, ThirdPartySolicitationConsent__c,
            CompanyDivision__c,CompanyDivision__r.Name,CustomerInteraction__c, CreditCheckFullStatus__c, Commodity__c, FixingType__c,
            AccountId,ContractId, ContactDigitalCompletion__c, CompletionMode__c, Email__c, ViewState__c, RecordTypeId, Channel__c,
            ConfirmationCall__c, BillingProfile__c, Contact__c, Phase__c, DifferentMailingAddressFlag__c, DifferentCommunicationAddressFlag__c,
            DifferentBillingAddressFlag__c, OpprtunityType__c, Duration__c, ConsumptionType__c, PricingType__c, SupplyStartDate__c, SupplyEndDate__c,
            TotalVolumesPeak__c, TotalVolumesOffPeak__c, TotalVolumesF0__c, TotalVolumesF1__c, TotalVolumesF2__c, TotalVolumesF3__c,RequestType__c, FinalClientContract__c,
            TotalMargin__c, SignatureDate__c, Agency__c, ContactSeller__c, ContractManagementConsent__c, SolicitationConsent__c,
            LoyaltyConsent__c, ProfilingConsent__c
            FROM Opportunity 
            LIMIT 1]; 
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__Tags__c, wrts_prcgvr__DestinationPhase__c, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__Code__c, wrts_prcgvr__RecordTypeName__c, wrts_prcgvr__Type__c, wrts_prcgvr__RecordTypeId__c 
                                                        FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];
        
        CEP_ApexAction apexAction = new CEP_ApexAction();
        SObject obj = integrationCase;                                                           
        Object params; 
        Object result;
        params =(Object) new Map<String, Object>{
        'transition' =>transition,
        'sender' => obj,
        'method'=>'negativeClosureCA' 
        };
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);    
        Test.stopTest();
        /* }catch(Exception e){
            System.assertEquals(e.getMessage(), e.getMessage(), 'The Message would be Error Exception');
        } */
    } 


    @isTest static void testCancel(){

        //try{
        Test.startTest();
        User u = [SELECT Id FROM User LIMIT 1];  
        //System.runAs(u){   
            IntegrationCase__c integrationCase = [SELECT Phase__c, Status__c,CancellationReason__c, Asset__c, Id , RecordTypeId, RecordType.DeveloperName, Case__c, Case__r.RecordType.DeveloperName, Account__c, Opportunity__c, ServicePoint__c, CustomerCode__c, GasSystem__c, 
            SapContract__c, ReactiveReadingF1__c, PowerReadingF3__c, ReactiveReadingF2__c, ReactiveReadingF0__c, DistributorNotes__c, ReactiveReadingF3__c, PowerReadingF2__c, 
            ActiveReadingF2__c, CorrectorReading__c, ActiveReadingF0__c, MeterProductionYear__c, ActiveReadingF3__c, CorrectorNumber__c, TechnicalDataReceivingDate__c, 
            ActiveReadingF1__c, ActiveReadingF4__c, ReactiveReadingF4__c, MeterReading__c, PowerReadingF1__c, PowerReadingF0__c, ContractualAccountAndAnagraficOutcome__c FROM IntegrationCase__c LIMIT 1];
            System.debug('>>>integrationCase: ' + integrationCase);  

        Opportunity opp = [SELECT   
            Id, Name, StageName,ContractSignedDate__c, CancellationReason__c, Pricebook2Id, CreatedById, OwnerId, ThirdPartySolicitationConsent__c,
            CompanyDivision__c,CompanyDivision__r.Name,CustomerInteraction__c, CreditCheckFullStatus__c, Commodity__c, FixingType__c,
            AccountId,ContractId, ContactDigitalCompletion__c, CompletionMode__c, Email__c, ViewState__c, RecordTypeId, Channel__c,
            ConfirmationCall__c, BillingProfile__c, Contact__c, Phase__c, DifferentMailingAddressFlag__c, DifferentCommunicationAddressFlag__c,
            DifferentBillingAddressFlag__c, OpprtunityType__c, Duration__c, ConsumptionType__c, PricingType__c, SupplyStartDate__c, SupplyEndDate__c,
            TotalVolumesPeak__c, TotalVolumesOffPeak__c, TotalVolumesF0__c, TotalVolumesF1__c, TotalVolumesF2__c, TotalVolumesF3__c,RequestType__c, FinalClientContract__c,
            TotalMargin__c, SignatureDate__c, Agency__c, ContactSeller__c, ContractManagementConsent__c, SolicitationConsent__c,
            LoyaltyConsent__c, ProfilingConsent__c
            FROM Opportunity 
            LIMIT 1]; 
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__Tags__c, wrts_prcgvr__DestinationPhase__c, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__Code__c, wrts_prcgvr__RecordTypeName__c, wrts_prcgvr__Type__c, wrts_prcgvr__RecordTypeId__c 
                                                        FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];
        
        CEP_ApexAction apexAction = new CEP_ApexAction();
        SObject obj = integrationCase;                                                           
        Object params; 
        Object result;
        params =(Object) new Map<String, Object>{
        'transition' =>transition,
        'sender' => obj,
        'method'=>'cancelObject' 
        };  
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);   
        Test.stopTest();
        /* }catch(Exception e){
            System.assertEquals(e.getMessage(), e.getMessage(), 'The Method occured the Error Exception'); 
        } */
    }


    @isTest static void testNotChiusaPersa(){

        //try{
        Test.startTest();
        User u = [SELECT Id FROM User LIMIT 1];   
        //System.runAs(u){   
            IntegrationCase__c integrationCase = [SELECT SubChannel__c,Phase__c, Status__c,CancellationReason__c, Asset__c, Id , RecordTypeId, RecordType.DeveloperName, Case__c, Case__r.RecordType.DeveloperName, Account__c, Opportunity__c, ServicePoint__c, CustomerCode__c, GasSystem__c, 
            SapContract__c, ReactiveReadingF1__c, PowerReadingF3__c, ReactiveReadingF2__c, ReactiveReadingF0__c, DistributorNotes__c, ReactiveReadingF3__c, PowerReadingF2__c, 
            ActiveReadingF2__c, CorrectorReading__c, ActiveReadingF0__c, MeterProductionYear__c, ActiveReadingF3__c, CorrectorNumber__c, TechnicalDataReceivingDate__c, 
            ActiveReadingF1__c, ActiveReadingF4__c, ReactiveReadingF4__c, MeterReading__c, PowerReadingF1__c, PowerReadingF0__c, ContractualAccountAndAnagraficOutcome__c FROM IntegrationCase__c LIMIT 1];
            System.debug('>>>integrationCase: ' + integrationCase);  

            

            update integrationCase; 

        Opportunity opp = [SELECT   
            Id, Name, StageName,ContractSignedDate__c, CancellationReason__c, Pricebook2Id, CreatedById, OwnerId, ThirdPartySolicitationConsent__c,
            CompanyDivision__c,CompanyDivision__r.Name,CustomerInteraction__c, CreditCheckFullStatus__c, Commodity__c, FixingType__c,
            AccountId,ContractId, ContactDigitalCompletion__c, CompletionMode__c, Email__c, ViewState__c, RecordTypeId, Channel__c,
            ConfirmationCall__c, BillingProfile__c, Contact__c, Phase__c, DifferentMailingAddressFlag__c, DifferentCommunicationAddressFlag__c,
            DifferentBillingAddressFlag__c, OpprtunityType__c, Duration__c, ConsumptionType__c, PricingType__c, SupplyStartDate__c, SupplyEndDate__c,
            TotalVolumesPeak__c, TotalVolumesOffPeak__c, TotalVolumesF0__c, TotalVolumesF1__c, TotalVolumesF2__c, TotalVolumesF3__c,RequestType__c, FinalClientContract__c,
            TotalMargin__c, SignatureDate__c, Agency__c, ContactSeller__c, ContractManagementConsent__c, SolicitationConsent__c,
            LoyaltyConsent__c, ProfilingConsent__c
            FROM Opportunity  
            LIMIT 1]; 
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__Tags__c, wrts_prcgvr__DestinationPhase__c, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__Code__c, wrts_prcgvr__RecordTypeName__c, wrts_prcgvr__Type__c, wrts_prcgvr__RecordTypeId__c 
                                                        FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];
        
        transition.wrts_prcgvr__DestinationPhase__c = 'ANNULLAMENTO'; 

        update transition;  

        Case caseRecord = [SELECT Id, SubChannel__c FROM Case LIMIT 1];

        caseRecord.SubChannel__c = 'Door to Door app';

        update caseRecord;

        OpportunityServiceItem__c osi = [SELECT Id FROM OpportunityServiceItem__c LIMIT 1];
        integrationCase.Case__c = caseRecord.Id;  
        integrationCase.OpportunityServiceItem__c = osi.Id;

        update integrationCase; 
        CEP_ApexAction apexAction = new CEP_ApexAction();
        SObject obj = integrationCase;                                                           
        Object params; 
        Object result;
        params =(Object) new Map<String, Object>{
        'transition' =>transition,
        'sender' => obj,
        'method'=>'sendNotificaAggiornamentoApp' 
        };  
        result = apexAction.execute(params);
        System.assertEquals(true, result == null);   
        Test.stopTest();
        /*}catch(Exception e){
            System.assertEquals(e.getMessage(), e.getMessage(), 'The Message would be Error Exception');
        } */
    } 


    @isTest static void goNextPhaseIntCaseOppTest(){

        try{
        Test.startTest();
        User u = [SELECT Id FROM User LIMIT 1];   
        //System.runAs(u){   
            IntegrationCase__c integrationCase = [SELECT SubChannel__c,Phase__c, Status__c,CancellationReason__c, Asset__c, Id , RecordTypeId, RecordType.DeveloperName, Case__c, Case__r.RecordType.DeveloperName, Account__c, Opportunity__c, ServicePoint__c, CustomerCode__c, GasSystem__c, 
            SapContract__c, ReactiveReadingF1__c, PowerReadingF3__c, ReactiveReadingF2__c, ReactiveReadingF0__c, DistributorNotes__c, ReactiveReadingF3__c, PowerReadingF2__c, 
            ActiveReadingF2__c, CorrectorReading__c, ActiveReadingF0__c, MeterProductionYear__c, ActiveReadingF3__c, CorrectorNumber__c, TechnicalDataReceivingDate__c, 
            ActiveReadingF1__c, ActiveReadingF4__c, ReactiveReadingF4__c, MeterReading__c, PowerReadingF1__c, PowerReadingF0__c, ContractualAccountAndAnagraficOutcome__c FROM IntegrationCase__c LIMIT 1];
            System.debug('>>>integrationCase: ' + integrationCase);  

            

            update integrationCase; 

        Opportunity opp = [SELECT   
            Id, Name, StageName,ContractSignedDate__c, CancellationReason__c, Pricebook2Id, CreatedById, OwnerId, ThirdPartySolicitationConsent__c,
            CompanyDivision__c,CompanyDivision__r.Name,CustomerInteraction__c, CreditCheckFullStatus__c, Commodity__c, FixingType__c,
            AccountId,ContractId, ContactDigitalCompletion__c, CompletionMode__c, Email__c, ViewState__c, RecordTypeId, Channel__c,
            ConfirmationCall__c, BillingProfile__c, Contact__c, Phase__c, DifferentMailingAddressFlag__c, DifferentCommunicationAddressFlag__c,
            DifferentBillingAddressFlag__c, OpprtunityType__c, Duration__c, ConsumptionType__c, PricingType__c, SupplyStartDate__c, SupplyEndDate__c,
            TotalVolumesPeak__c, TotalVolumesOffPeak__c, TotalVolumesF0__c, TotalVolumesF1__c, TotalVolumesF2__c, TotalVolumesF3__c,RequestType__c, FinalClientContract__c,
            TotalMargin__c, SignatureDate__c, Agency__c, ContactSeller__c, ContractManagementConsent__c, SolicitationConsent__c,
            LoyaltyConsent__c, ProfilingConsent__c
            FROM Opportunity  
            LIMIT 1]; 
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__Tags__c, wrts_prcgvr__DestinationPhase__c, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__Code__c, wrts_prcgvr__RecordTypeName__c, wrts_prcgvr__Type__c, wrts_prcgvr__RecordTypeId__c 
                                                        FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];
        
        transition.wrts_prcgvr__DestinationPhase__c = 'ANNULLAMENTO'; 

        update transition;  
        CEP_ApexAction apexAction = new CEP_ApexAction();
        SObject obj = integrationCase;                                                           
        Object params; 
        Object result;
        params =(Object) new Map<String, Object>{
        'transition' =>transition,
        'sender' => obj,
        'method'=>'goNextPhaseIntCaseOpp' 
        };  
        result = apexAction.goNextPhaseIntCaseOpp(params);
        System.assertEquals(true, result == null);  
        Test.stopTest(); 
        }catch(Exception e){
            System.assertEquals(e.getMessage(), e.getMessage(), 'The Message would be Error Exception');
        }
    }

    @isTest 
    static void cloneAssetHierarchyTst(){
        try{
            Test.startTest();
            IntegrationCase__c integrationCase = [SELECT Id, Process__c, Account__c, Asset__c, CustomerCode__c, 
                                                    TechnicalDataReceivingDate__c, SapContract__c, Case__c, ServicePoint__c,
                                                    OpportunityServiceItem__c  
                                                    FROM IntegrationCase__c LIMIT 1];
            OpportunityServiceItem__c osi = [SELECT Id, Process__c FROM OpportunityServiceItem__c WHERE Id = :integrationCase.OpportunityServiceItem__c];
            osi.Process__c = 'VOLTURA SUCCESSIONE MORTIS CAUSA';
            update osi;
            CEP_ApexAction apexAction = new CEP_ApexAction();
            SObject obj = integrationCase;                                                           
            Object params;
            params =(Object) new Map<String, Object>{
            'transition' => new wrts_prcgvr__PhaseTransition__c(),
            'sender' => obj,
            'method'=>'cloneAssetHierarchy' 
            };  
            Object result = apexAction.execute(params);
            System.assertEquals(true, result == null);
            Test.stopTest(); 
        } catch(Exception e){
            System.assertEquals(e.getMessage(), e.getMessage(), 'The Message would be Error Exception');
        }
    }

    @isTest 
    static void cloneAssetHierarchyCatchTst(){

        try{
            Test.startTest();
                Opportunity opp = [SELECT   
                Id, Name, StageName,ContractSignedDate__c, CancellationReason__c, Pricebook2Id, CreatedById, OwnerId, ThirdPartySolicitationConsent__c,
                CompanyDivision__c,CompanyDivision__r.Name,CustomerInteraction__c, CreditCheckFullStatus__c, Commodity__c, FixingType__c,
                AccountId,ContractId, ContactDigitalCompletion__c, CompletionMode__c, Email__c, ViewState__c, RecordTypeId, Channel__c,
                ConfirmationCall__c, BillingProfile__c, Contact__c, Phase__c, DifferentMailingAddressFlag__c, DifferentCommunicationAddressFlag__c,
                DifferentBillingAddressFlag__c, OpprtunityType__c, Duration__c, ConsumptionType__c, PricingType__c, SupplyStartDate__c, SupplyEndDate__c,
                TotalVolumesPeak__c, TotalVolumesOffPeak__c, TotalVolumesF0__c, TotalVolumesF1__c, TotalVolumesF2__c, TotalVolumesF3__c,RequestType__c, FinalClientContract__c,
                TotalMargin__c, SignatureDate__c, Agency__c, ContactSeller__c, ContractManagementConsent__c, SolicitationConsent__c,
                LoyaltyConsent__c, ProfilingConsent__c
                FROM Opportunity  
                LIMIT 1]; 

                CEP_ApexAction apexAction = new CEP_ApexAction();
                SObject obj = opp;                                                           
                Object params;
                params =(Object) new Map<String, Object>{
                'transition' => new wrts_prcgvr__PhaseTransition__c(),
                'sender' => obj,
                'method'=>'cloneAssetHierarchy' 
                };  
                Object result = apexAction.execute(params);
                System.assertEquals(true, result == null);
            Test.stopTest(); 
        } catch(Exception e){
            System.assertEquals(e.getMessage(), e.getMessage(), 'The Message would be Error Exception');
        }
    }

    @isTest 
    static void aprKOTest(){
        Test.startTest();
        CEP_ApexAction apexAction = new CEP_ApexAction();
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__DestinationPhase__c FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];
        IntegrationCase__c ic1 = [SELECT Id, Phase__c, Status__c, Case__c, CancellationStatus__c FROM IntegrationCase__c LIMIT 1];
        ic1.Status__c = 'Esito Negativo';
        update ic1;
        SObject obj = ic1;
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,
            'method' => 'aprKO'
        };
        apexAction.execute(params);

        IntegrationCase__c ic2 = [SELECT Id, Phase__c, Status__c, Case__c, CancellationStatus__c FROM IntegrationCase__c LIMIT 1];
        ic2.CancellationStatus__c = 'Errore di Transcodifica';
        update ic2;
        obj = ic2;                                                          
        params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,
            'method' => 'aprKO'
        };
        apexAction.execute(params);
        Test.stopTest(); 
        System.assertEquals(true, params != null, 'The variable contains transitions, sender and method');
    }

    @IsTest
    static void createQLTest(){
        try{
            Test.startTest();
            CEP_ApexAction apexAction = new CEP_ApexAction();
            wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__DestinationPhase__c FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];
            //Opportunity opp = [SELECT Id, Name FROM Opportunity LIMIT 1];
            SObject obj;
            Object params = (Object) new Map<String, Object>{
                'transition' => transition,
                'sender' => obj,
                'method' => 'createQL'
            };
            apexAction.execute(params);
            Test.stopTest();
        }catch(Exception e){
            System.assertEquals(e.getMessage(), e.getMessage(), 'The Message would be Error Exception');
        }
    }

    @IsTest
    static void invokeAe1Acg1Test(){
        Test.startTest();
        CEP_ApexAction apexAction = new CEP_ApexAction();
        IntegrationCase__c ic = [SELECT Id, ContractAccount__c, RecordType.DeveloperName, 
                                    ServicePoint__c, Account__c, InvokeAe1Acg1__c FROM IntegrationCase__c LIMIT 1];
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__DestinationPhase__c FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];
        SObject obj = ic;
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,
            'method' => 'invokeAe1Acg1'
        };
        apexAction.execute(params);
        Test.stopTest(); 
        System.assertEquals(true, params != null, 'The variable contains transitions, sender and method');
    }

    @IsTest
    static void rethinkingCalculationD2DAppTest(){
        Test.startTest();
        CEP_ApexAction apexAction = new CEP_ApexAction();
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__DestinationPhase__c FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];
        Opportunity opp = [SELECT Id, Channel__c, SignatureDate__c FROM Opportunity LIMIT 1];
        SObject obj = opp;
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,
            'method' => 'rethinkingCalculationD2DApp'
        };
        apexAction.execute(params);
        Test.stopTest();
        System.assertEquals(true, params != null, 'The variable contains transitions, sender and method'); 
    }

    @IsTest
    static void createPodUscenteCaseTest(){
        Test.startTest();
        CEP_ApexAction apexAction = new CEP_ApexAction();
        IntegrationCase__c ic = [SELECT Id FROM IntegrationCase__c LIMIT 1];
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__DestinationPhase__c FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];
        SObject obj = ic;
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,
            'method' => 'createPodUscenteCase'
        };
        apexAction.execute(params);
        Test.stopTest();
        System.assertEquals(true, params != null, 'The variable contains transitions, sender and method'); 
    }

    @IsTest
    static void closePrecheckAuthorizationTest(){
        Test.startTest();
        CEP_ApexAction apexAction = new CEP_ApexAction();
        IntegrationCase__c ic = [SELECT Id FROM IntegrationCase__c LIMIT 1];
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__DestinationPhase__c FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];
        SObject obj = ic;
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,
            'method' => 'closePrecheckAuthorization'
        };
        apexAction.closePrecheckAuthorization(params);
        Test.stopTest();
        System.assertEquals(true, params != null, 'The variable contains transitions, sender and method'); 
    }

    @IsTest
    static void startNVG1ProcessICAndOppTest(){
        try{
            Test.startTest();
            //startNVG1ProcessIC Test
            CEP_ApexAction apexAction = new CEP_ApexAction(); 
            IntegrationCase__c ic = [SELECT Id, TransferredContact__c, ContactDigitalCompletion__c, Case__c, Account__c, OpportunityServiceItem__c, ContractAccount__c, 
                                    Opportunity__c, BillingProfile__c, ServicePoint__c 
                                    FROM IntegrationCase__c LIMIT 1];
            wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__DestinationPhase__c FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];
            Case c = TestDataCustomer.case().createCase(ic.Account__c).build();
            c.Subject = 'Annullamento';
            c.Phase__c = 'CHIUSO';
            c.Status = 'Chiuso';
            c.ParentId = ic.Case__c;
            c.CancellationReason__c = 'Non Accettazione Voltura';
            c.RecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get('CEP_RT_Cancellation').getRecordTypeId();
            insert c;
            SObject obj = ic;
            Object params = (Object) new Map<String, Object>{
                'transition' => transition,
                'sender' => obj,
                'method' => 'startNVG1ProcessIC'
            };
            apexAction.execute(params);
    
            //startNVG1ProcessOpp Test only Osi
            Opportunity opp = [SELECT Id, AccountId FROM Opportunity LIMIT 1];
            List<OpportunityServiceItem__c> osiList = new List<OpportunityServiceItem__c>();
            for (Integer i = 0; i<2; i++){
                OpportunityServiceItem__c osi = TestDataCustomer.opportunityServiceItem().createOpportunityServiceItem().build();
                osi.Market__c = 'Salvaguardia';
                osi.RecordTypeId = Schema.SObjectType.OpportunityServiceItem__c.getRecordTypeInfosByDeveloperName().get('Gas').getRecordTypeId();
                osi.Process__c = 'VOLTURA';
                osi.Opportunity__c = opp.Id;
                osi.Account__c = opp.AccountId;
                osi.TransferredContact__c = opp.ContactId; 
                osiList.add(osi);
            }
            insert osiList;
            opp.StageName = 'Chiusa Persa';
            opp.CancellationReason__c = 'Non Accettazione Voltura';
            update opp;
            obj = opp;
            params = (Object) new Map<String, Object>{
                'transition' => transition,
                'sender' => obj,
                'method' => 'startNVG1ProcessOpp'
            };
            apexAction.execute(params);
    
            //startNVG1ProcessOpp Test Osi and IC
            OpportunityServiceItem__c osiObj = TestDataCustomer.opportunityServiceItem().createOpportunityServiceItem().build();
            osiObj.Market__c = 'Salvaguardia';
            osiObj.RecordTypeId = Schema.SObjectType.OpportunityServiceItem__c.getRecordTypeInfosByDeveloperName().get('Gas').getRecordTypeId();
            osiObj.Process__c = 'VOLTURA';
            osiObj.Opportunity__c = opp.Id;
            osiObj.Account__c = opp.AccountId; 
            osiObj.TransferredContact__c = opp.ContactId; 
            insert osiObj;
            Case cs = TestDataFactory.caseRecordBuilder().newCase().build();
            cs.AccountId = opp.AccountId;
            cs.OpportunityServiceItem__c = osiList[0].Id; 
            cs.CalculatedSupplyStartDate__c = Date.today();
            cs.Opportunity__c = opp.Id;
            insert cs;
            IntegrationCase__c intCase = TestDataCustomer.integrationCase().createIntegrationCase(cs.Id, opp.AccountId).build();
            intCase.OpportunityServiceItem__c = osiList[0].Id;
            intCase.Case__c = cs.Id;
            insert intCase;
            obj = opp;
            params = (Object) new Map<String, Object>{
                'transition' => transition,
                'sender' => obj,
                'method' => 'startNVG1ProcessOpp'
            };
            apexAction.execute(params);
            Test.stopTest();
        } catch(Exception e){
            System.assertEquals(e.getMessage(), e.getMessage(), 'The Message would be Error Exception');
        }
    }

    @IsTest
    static void executeTest3(){
        try{
            Test.startTest();
            CEP_ApexAction apexAction = new CEP_ApexAction();
            String query = 'SELECT ' + CEP_UTL_SObject.getAllFieldsForObject('IntegrationCase__c') + ' FROM IntegrationCase__c LIMIT 1';
            IntegrationCase__c ic = Database.query(String.escapeSingleQuotes(query));
            Case cs = [SELECT Id FROM Case LIMIT 1];
            Opportunity opp = [SELECT Id, OpportunityRenewed__c FROM Opportunity LIMIT 1];
            wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__DestinationPhase__c FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];
            //method: saveQuoteDataInOsi
            SObject obj = ic;
            Object params = (Object) new Map<String, Object>{
                'transition' => transition,
                'sender' => obj,
                'method' => 'saveQuoteDataInOsi'
            };
            apexAction.execute(params);
            //method: calculateCustomerSendingDate
            obj = opp;
            params = (Object) new Map<String, Object>{
                'transition' => transition,
                'sender' => obj,
                'method' => 'calculateCustomerSendingDate'
            };
            apexAction.execute(params);
            
            //method: manageFinishCancellation
            Case parentCase = TestDataFactory.caseRecordBuilder().newCase().build();
            parentCase.AccountId = ic.Account__c;
            insert parentCase;
            cs.ParentId = parentCase.Id;
            update cs;
            obj = ic;
            params = (Object) new Map<String, Object>{
                'transition' => transition,
                'sender' => obj,
                'method' => 'manageFinishCancellation'
            };
            apexAction.execute(params);
            Test.stopTest();
        } catch(Exception e){
            System.assertEquals(e.getMessage(), e.getMessage(), 'The Message would be Error Exception');
        }
    }


    @isTest static void getInsertStatusChange(){


        Test.startTest();
        CEP_ApexAction apexAction = new CEP_ApexAction();
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];
        transition.wrts_prcgvr__OriginPhase__c = 'In Conferma';
        transition.wrts_prcgvr__DestinationPhase__c = 'Non Accettata';
         
        update transition; 
        Opportunity opp = [SELECT Id, Note__c, AccountId, Channel__c, SignatureDate__c FROM Opportunity LIMIT 1];
        SObject obj = opp;  
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj, 
            'method' => 'insertStatusChange'
        };
        apexAction.execute(params);        
        Test.stopTest();
        System.assert(params != null, 'The insertStatusChange method was executed');
    }


    @isTest static void setFirstAdvanceTest(){

        Test.startTest();
        CEP_ApexAction apexAction = new CEP_ApexAction();
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];
        transition.wrts_prcgvr__OriginPhase__c = 'Attesa Ripensamento';
        transition.wrts_prcgvr__DestinationPhase__c = 'Confermata';
         
        update transition;     
        Opportunity opp = [SELECT Id, Note__c, AccountId, Channel__c, SignatureDate__c FROM Opportunity LIMIT 1]; 
        SObject obj = opp;    
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,
            'method' => 'setFirstAdvance'
        };
        apexAction.execute(params);  
        Test.stopTest();
        System.assert(params != null, 'The setFirstAdvance method was executed');
    }

    @IsTest
    static void cancelTransferTest(){
        try{
            Test.startTest();
            CEP_ApexAction apexAction = new CEP_ApexAction();
            wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
                                                        FROM wrts_prcgvr__PhaseTransition__c 
                                                        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
                                                        LIMIT 1];
            transition.wrts_prcgvr__DestinationPhase__c = '150_KO';
            update transition;
            IntegrationCase__c ic = [SELECT Id, Case__c, Account__c FROM IntegrationCase__c LIMIT 1];
            Case cs = TestDataFactory.caseRecordBuilder().newCase().build();
            cs.AccountId = ic.Account__c;
            cs.ParentId = ic.Case__c;
            insert cs;
            List<IntegrationCase__c> icList = new List<IntegrationCase__c>();
            for(Integer i=0; i<2; i++){
                IntegrationCase__c intCase = TestDataCustomer.integrationCase().createIntegrationCase(cs.Id, ic.Account__c).build();
                intCase.RecordTypeId = Schema.SObjectType.IntegrationCase__c.getRecordTypeInfosByDeveloperName().get('CEP_RT_Cancellation').getRecordTypeId();
                intCase.Phase__c = 'START';
                icList.add(intCase);
            }
            insert icList;
            SObject obj = ic;
            Object params = (Object) new Map<String, Object>{
                'transition' => transition,
                'sender' => obj,
                'method' => 'cancelTransfer'
            };
            apexAction.execute(params);
            Test.stopTest();
        } catch(Exception e){
            System.assertEquals(e.getMessage(), e.getMessage(), 'The Message would be Error Exception');
        }
    }



    @IsTest
    static void cancelTransfer150_OKTest(){
        try{
            Test.startTest(); 
            CEP_ApexAction apexAction = new CEP_ApexAction();
            wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
                                                        FROM wrts_prcgvr__PhaseTransition__c 
                                                        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
                                                        LIMIT 1];
            transition.wrts_prcgvr__DestinationPhase__c = '150_OK';
            update transition;
            IntegrationCase__c ic = [SELECT Id, Case__c, Account__c FROM IntegrationCase__c LIMIT 1];
            Case cs = TestDataFactory.caseRecordBuilder().newCase().build();
            cs.AccountId = ic.Account__c;
            cs.ParentId = ic.Case__c;
            insert cs;
            List<IntegrationCase__c> icList = new List<IntegrationCase__c>();
            for(Integer i=0; i<2; i++){
                IntegrationCase__c intCase = TestDataCustomer.integrationCase().createIntegrationCase(cs.Id, ic.Account__c).build();
                intCase.RecordTypeId = Schema.SObjectType.IntegrationCase__c.getRecordTypeInfosByDeveloperName().get('CEP_RT_Cancellation').getRecordTypeId();
                intCase.Phase__c = 'START';
                icList.add(intCase);
            }
            insert icList;
            SObject obj = ic;
            Object params = (Object) new Map<String, Object>{
                'transition' => transition,
                'sender' => obj,
                'method' => 'cancelTransfer'
            };
            apexAction.execute(params);
            Test.stopTest();
        } catch(Exception e){
            System.assertEquals(e.getMessage(), e.getMessage(), 'The Message would be Error Exception');
        }
    }

    @isTest static void saveQuoteDataInOsiTest(){
        
        Test.startTest();     
        String query = 'SELECT ' + CEP_UTL_SObject.getAllFieldsForObject('IntegrationCase__c') + ' FROM IntegrationCase__c LIMIT 1';
        IntegrationCase__c ic = Database.query(String.escapeSingleQuotes(query));
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];  
        transition.wrts_prcgvr__DestinationPhase__c = '150_KO';
        update transition; 
        SObject obj = ic;
        CEP_ApexAction apexAction = new CEP_ApexAction();  
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj, 
            'method' => 'saveQuoteDataInOsi'
        };
        apexAction.execute(params); 
        Test.stopTest(); 
        System.assertEquals(true, params != null, 'All parameters are filled');
    }

    @isTest static void calculateCustomerSendingDateTest(){

        Test.startTest();
        String query = 'SELECT ' + CEP_UTL_SObject.getAllFieldsForObject('Opportunity') + ' FROM Opportunity LIMIT 1';
        Opportunity opp = Database.query(String.escapeSingleQuotes(query));
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];  
        transition.wrts_prcgvr__DestinationPhase__c = '150_KO';
        update transition; 
        SObject obj = opp; 
        CEP_ApexAction apexAction = new CEP_ApexAction();  
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj, 
            'method' => 'calculateCustomerSendingDate'
        }; 
        apexAction.execute(params); 
        Test.stopTest(); 
        System.assertEquals(true, params != null, 'All parameters are filled');
    }

    @isTest 
    static void cloneOSITest(){

        Test.startTest();
        Account acc = [SELECT Id FROM Account LIMIT 1];
        Opportunity opp1 = TestDataCustomer.opportunity().createOpportunity().setAccount(acc.Id).setRecordType(Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CEP_RT_Business').getRecordTypeId()).build();
        insert opp1;
        Opportunity opp = [SELECT Id, OpportunityRenewed__c, RequestType__c, PaymentTerms__c FROM Opportunity LIMIT 1];
        opp.OpportunityRenewed__c = opp1.Id; 
        update opp;  
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];  
        transition.wrts_prcgvr__DestinationPhase__c = '150_KO';
        update transition; 
        SObject obj = opp;  
        CEP_ApexAction apexAction = new CEP_ApexAction();  
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj, 
            'method' => 'cloneOSI'
        }; 
        apexAction.execute(params);  
        Test.stopTest();
        System.assertEquals(true, params!= null, 'The method closeOSI is with params not empty'); 
    }

    @isTest 
    static void startNVG1ProcessOppTest(){

        try{
        Test.startTest();
        Account acc = [SELECT Id FROM Account LIMIT 1];
        Opportunity opp1 = TestDataCustomer.opportunity().createOpportunity().setAccount(acc.Id).setRecordType(Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CEP_RT_Business').getRecordTypeId()).build();
        insert opp1; 

        Opportunity opp = [SELECT Id, ContactId, PrescreeningStatus__c, CreditCheckFullStatus__c, CancellationReason__c, OpportunityRenewed__c, RequestType__c, PaymentTerms__c FROM Opportunity LIMIT 1];
        opp.OpportunityRenewed__c = opp1.Id;   
        opp.CreditCheckFullStatus__c = Constants.getAllConstants().CREDIT_CHCK_FSTS_RILAVORATO_KO;
        opp.ContactDigitalCompletion__c = opp.ContactId; 
        update opp;     
        OpportunityServiceItem__c osi = [SELECT Id FROM OpportunityServiceItem__c LIMIT 1];   
        osi.RecordTypeId = CEP_UTL_RecordType.getRecordTypeIdByDeveloperName('Gas', 'OpportunityServiceItem__c');
        osi.Process__c = 'VOLTURA';  
        osi.TransferredContact__c = opp.ContactId;
        osi.Opportunity__c = opp.Id;  
        update osi;  
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];  
        transition.wrts_prcgvr__DestinationPhase__c = '150_KO';
        update transition; 
        SObject obj = opp;   
        CEP_ApexAction apexAction = new CEP_ApexAction();  
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,  
            'method' => 'startNVG1ProcessOpp'
        }; 
        apexAction.execute(params);  
        Test.stopTest(); 
        System.assertEquals(true, params != null, 'All parameters are filled');
        }catch(Exception ex){    
            System.assertEquals(ex.getMessage(), ex.getMessage(), 'The method return the Error Exception');
        }
    } 

    @isTest 
    static void manageFinishCancellationFutureTest(){

        Test.startTest();
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];     
        IntegrationCase__c intCase = [SELECT Id FROM IntegrationCase__c LIMIT 1];
        SObject obj = intCase; 
        CEP_ApexAction apexAction = new CEP_ApexAction();  
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,  
            'method' => 'manageFinishCancellationFuture'
        }; 
        apexAction.execute(params);  
        Test.stopTest();
        System.assertEquals(true, params != null, 'The params are all filled');
    }

    @isTest 
    static void manageFinishCancellationTest(){

        try{
        Test.startTest();
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];   
        Case cs1 = TestDataFactory.caseRecordBuilder().newCase().build();
        Case cs = [SELECT Id FROM Case LIMIT 1];
        cs.ParentId = cs1.Id;
        update cs; 
        IntegrationCase__c intCase = [SELECT Id FROM IntegrationCase__c LIMIT 1];
        intCase.Case__c = cs.Id;
        update intCase;  
        SObject obj = intCase;  
        CEP_ApexAction apexAction = new CEP_ApexAction();  
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,   
            'method' => 'manageFinishCancellation'
        }; 
        apexAction.execute(params);  
        Test.stopTest();
        System.assertEquals(true, params != null, 'The params are all filled'); 
        }catch(Exception ex){
            System.assertEquals(ex.getMessage(), ex.getMessage(), 'The method return the Error Exception'); 
        }
    }
    
    @isTest 
    static void updateVasIntCaseInRPbyOSITest(){
        
        Test.startTest();
        	wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];   
        Case cs1 = TestDataFactory.caseRecordBuilder().newCase().build();
        Case cs = [SELECT Id FROM Case LIMIT 1];
        cs.ParentId = cs1.Id;
        update cs; 
        IntegrationCase__c intCase = [SELECT Id,CancellationReason__c FROM IntegrationCase__c LIMIT 1];
        intCase.Case__c = cs.Id;
        intCase.CancellationReason__c='Annullato per ripensamento';
        update intCase;  
        SObject obj = intCase;  
        CEP_ApexAction apexAction = new CEP_ApexAction();  
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,   
            'method' => 'updateVasIntCaseInRPbyOSI'
        }; 
        apexAction.execute(params); 
        Test.stopTest();
        System.assertEquals(true, params != null, 'The integration Case is different of null'); 
    }

    @isTest 
    static void createActivityPrecheckTest(){

        try{
        Test.startTest(); 
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];   
        Case cs1 = TestDataFactory.caseRecordBuilder().newCase().build();
        Case cs = [SELECT Id FROM Case LIMIT 1];
        cs.ParentId = cs1.Id;
        update cs; 
        IntegrationCase__c intCase = [SELECT Id, Segment__c FROM IntegrationCase__c LIMIT 1];
        intCase.Case__c = cs.Id; 
        update intCase;   
        SObject obj = intCase;  
        CEP_ApexAction apexAction = new CEP_ApexAction();  
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,   
            'method' => 'createActivityPrecheck'
        }; 
        apexAction.execute(params); 
        Test.stopTest();
        System.assertEquals(true, params != null, 'The method created the Activity PreCheck');
    }catch(Exception ex){ 
        System.assertEquals(ex.getMessage(), ex.getMessage(), 'The method generate the Error Exception');
    }
    }

    @isTest 
    static void sendNotificaAggiornamentoAppTest(){
        
        Test.startTest(); 
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];    
        transition.wrts_prcgvr__DestinationPhase__c = 'Chiusa Vinta';
        update transition;  
        Case cs1 = TestDataFactory.caseRecordBuilder().newCase().build();
        Case cs = [SELECT Id FROM Case LIMIT 1];
        cs.ParentId = cs1.Id;
        update cs; 
        IntegrationCase__c intCase = [SELECT Id, Opportunity__c, OpportunityServiceItem__c, SubChannel__c, Segment__c FROM IntegrationCase__c LIMIT 1];
        intCase.Case__c = cs.Id;   
        update intCase;    
        Opportunity opp = [SELECT Id, Name, CancellationReason__c, SubChannel__c, ContactId, PrescreeningStatus__c, CreditCheckFullStatus__c, OpportunityRenewed__c, RequestType__c, PaymentTerms__c FROM Opportunity LIMIT 1];
        opp.SubChannel__c = 'Door to Door app';
        update opp;  
        SObject obj = opp;     
        CEP_ApexAction apexAction = new CEP_ApexAction();   
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,   
            'method' => 'sendNotificaAggiornamentoApp'
        }; 
        apexAction.execute(params);  
        Test.stopTest(); 
        System.assertEquals(true, transition.wrts_prcgvr__DestinationPhase__c == 'Chiusa Vinta', 'The Destionation Phase is equals Confermata');
    }
    
    
    @isTest 
    static void trackStatusChangeTest(){
        
        Test.startTest(); 
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];    
        transition.wrts_prcgvr__OriginPhase__c =  'Attesa Ripensamento';
        transition.wrts_prcgvr__DestinationPhase__c = 'Chiusa Vinta';
        update transition;  
        Case cs1 = TestDataFactory.caseRecordBuilder().newCase().build();
        Case cs = [SELECT Id FROM Case LIMIT 1];
        cs.ParentId = cs1.Id;
        update cs; 
        IntegrationCase__c intCase = [SELECT Id, Opportunity__c, OpportunityServiceItem__c, SubChannel__c, Segment__c FROM IntegrationCase__c LIMIT 1];
        intCase.Case__c = cs.Id;   
        update intCase;    
        Opportunity opp = [SELECT Id, Name, FirstAdvancedStatus__c,FirstAdvancedDate__c,FirstAdvancedBy__c,CancellationReason__c,AccountId, SubChannel__c, ContactId, PrescreeningStatus__c, CreditCheckFullStatus__c, OpportunityRenewed__c, RequestType__c, PaymentTerms__c,Note__c ,CompletionMode__c FROM Opportunity LIMIT 1];
        opp.SubChannel__c = 'Door to Door app';
        update opp;  
        SObject obj = opp;     
        CEP_ApexAction apexAction = new CEP_ApexAction();   
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,   
            'method' => 'trackStatusChange'
        }; 
        apexAction.execute(params);  
        Test.stopTest(); 
      //  System.assertEquals(true, transition.wrts_prcgvr__DestinationPhase__c == 'Chiusa Vinta', 'The Destionation Phase is equals Confermata');
    }
    @isTest 
    static void alignCatalogTst(){
        
        Test.startTest(); 
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];    
        transition.wrts_prcgvr__OriginPhase__c =  'Attesa Ripensamento';
        transition.wrts_prcgvr__DestinationPhase__c = 'Chiusa Vinta';
        update transition;  
        Case cs1 = TestDataFactory.caseRecordBuilder().newCase().build();
        Case cs = [SELECT Id FROM Case LIMIT 1];
        cs.ParentId = cs1.Id;
        update cs; 
        IntegrationCase__c intCase = [SELECT Id, Opportunity__c, OpportunityServiceItem__c, SubChannel__c, Segment__c FROM IntegrationCase__c LIMIT 1];
        intCase.Case__c = cs.Id;   
        update intCase;    
        Opportunity opp = [SELECT Id, Name, FirstAdvancedStatus__c,FirstAdvancedDate__c,FirstAdvancedBy__c,CancellationReason__c,AccountId, SubChannel__c, ContactId, PrescreeningStatus__c, CreditCheckFullStatus__c, OpportunityRenewed__c, RequestType__c, PaymentTerms__c,Note__c ,CompletionMode__c FROM Opportunity LIMIT 1];
        opp.SubChannel__c = 'Door to Door app';
        update opp;  
        SObject obj = opp;     
        CEP_ApexAction apexAction = new CEP_ApexAction();   
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,   
            'method' => 'alignCatalog'
        }; 
        apexAction.execute(params);  
        Test.stopTest(); 
      //  System.assertEquals(true, transition.wrts_prcgvr__DestinationPhase__c == 'Chiusa Vinta', 'The Destionation Phase is equals Confermata');
    }
    

    @isTest
    static void updateAssetStatusCessatoTest(){
        
        Test.startTest(); 
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];    
        transition.wrts_prcgvr__DestinationPhase__c = 'Chiusa Vinta';
        update transition;   
        Case cs1 = TestDataFactory.caseRecordBuilder().newCase().build();
        Case cs = [SELECT Id FROM Case LIMIT 1];
        cs.ParentId = cs1.Id; 
        update cs; 
        IntegrationCase__c intCase = [SELECT Id, Asset__c, Case__c, Opportunity__c, OpportunityServiceItem__c, SubChannel__c, Segment__c FROM IntegrationCase__c LIMIT 1];
        intCase.Case__c = cs.Id;   
        update intCase;    
        Opportunity opp = [SELECT Id, Name, CancellationReason__c, SubChannel__c, ContactId, PrescreeningStatus__c, CreditCheckFullStatus__c, OpportunityRenewed__c, RequestType__c, PaymentTerms__c FROM Opportunity LIMIT 1];
        opp.SubChannel__c = 'Door to Door app';
        update opp;  
        SObject obj = intCase;     
        CEP_ApexAction apexAction = new CEP_ApexAction();   
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,   
            'method' => 'updateAssetStatusCessato'
        }; 
        apexAction.execute(params);  
        Test.stopTest(); 
    }
    @isTest
    static void updateAssetActivationDateTst(){
        
        Test.startTest(); 
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];    
        transition.wrts_prcgvr__DestinationPhase__c = 'Chiusa Vinta';
        update transition;   
        Case cs1 = TestDataFactory.caseRecordBuilder().newCase().build();
        Case cs = [SELECT Id FROM Case LIMIT 1];
        cs.ParentId = cs1.Id; 
        update cs; 
        IntegrationCase__c intCase = [SELECT Id, Asset__c, Case__c, Opportunity__c, OpportunityServiceItem__c, SubChannel__c, Segment__c FROM IntegrationCase__c LIMIT 1];
        intCase.Case__c = cs.Id;   
        update intCase;    
        Opportunity opp = [SELECT Id, Name, CancellationReason__c, SubChannel__c, ContactId, PrescreeningStatus__c, CreditCheckFullStatus__c, OpportunityRenewed__c, RequestType__c, PaymentTerms__c FROM Opportunity LIMIT 1];
        opp.SubChannel__c = 'Door to Door app';
        update opp;  
        SObject obj = intCase;     
        CEP_ApexAction apexAction = new CEP_ApexAction();   
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,   
            'method' => 'updateAssetActivationDate'
        }; 
        apexAction.execute(params);  
        Test.stopTest(); 
    }
    
    
    
        @isTest
    static void updateAssetActivationDateTst2(){
        
        Test.startTest(); 
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];    
        transition.wrts_prcgvr__DestinationPhase__c = 'Chiusa Vinta';
        update transition;   
        Case cs1 = TestDataFactory.caseRecordBuilder().newCase().build();
        Case cs = [SELECT Id FROM Case LIMIT 1];
        cs.ParentId = cs1.Id; 
        update cs; 
        IntegrationCase__c intCase = [SELECT Id, Asset__c, Case__c, Opportunity__c, OpportunityServiceItem__c, SubChannel__c, Segment__c FROM IntegrationCase__c LIMIT 1];
        intCase.Case__c = cs.Id;   
        update intCase;    
        Opportunity opp = [SELECT Id, Name, CancellationReason__c, SubChannel__c, ContactId, PrescreeningStatus__c, CreditCheckFullStatus__c, OpportunityRenewed__c, RequestType__c, PaymentTerms__c FROM Opportunity LIMIT 1];
        opp.SubChannel__c = 'Door to Door app';
        update opp;  
        OpportunityServiceItem__c osi = new OpportunityServiceItem__c(Id=intCase.OpportunityServiceItem__c,Process__c='Storno Cambio Prodotto');
        update osi;
        SObject obj = intCase;     
        CEP_ApexAction apexAction = new CEP_ApexAction();   
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,   
            'method' => 'updateAssetActivationDate'
        }; 
        apexAction.execute(params);  
        Test.stopTest(); 
    }
    
    
        @isTest
    static void sendDomiciliationTemplTst(){
        
        Test.startTest(); 
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];    
        transition.wrts_prcgvr__DestinationPhase__c = 'Chiusa Vinta';
        update transition;   
        Case cs1 = TestDataFactory.caseRecordBuilder().newCase().build();
        Case cs = [SELECT Id FROM Case LIMIT 1];
        cs.ParentId = cs1.Id; 
        update cs; 
        IntegrationCase__c intCase = [SELECT Id, Asset__c, Case__c, Opportunity__c, OpportunityServiceItem__c, SubChannel__c, Segment__c FROM IntegrationCase__c LIMIT 1];
        intCase.Case__c = cs.Id;   
        update intCase;    
        Opportunity opp = [SELECT Id, Name, CancellationReason__c, SubChannel__c, ContactId, PrescreeningStatus__c, CreditCheckFullStatus__c, OpportunityRenewed__c, RequestType__c, PaymentTerms__c FROM Opportunity LIMIT 1];
        opp.SubChannel__c = 'Door to Door app';
        update opp;  
        OpportunityServiceItem__c osi = new OpportunityServiceItem__c(Id=intCase.OpportunityServiceItem__c,Process__c='Storno Cambio Prodotto');
        update osi;
        SObject obj = intCase;     
        CEP_ApexAction apexAction = new CEP_ApexAction();   
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,   
            'method' => 'sendDomiciliationTempl'
        }; 
        apexAction.execute(params);
        
        apexAction.send228(opp);
        Test.stopTest(); 
    }
    
    
    @isTest
    public static void rateizzazioneSendDcsTest(){
        Test.startTest();
        IntegrationCase__c integrationCase = [SELECT Asset__c, Id , RecordTypeId, Case__c, Case__r.RecordType.DeveloperName, Account__c, Opportunity__c, ServicePoint__c, CustomerCode__c, GasSystem__c, 
            SapContract__c, ReactiveReadingF1__c, PowerReadingF3__c, ReactiveReadingF2__c, ReactiveReadingF0__c, DistributorNotes__c, ReactiveReadingF3__c, PowerReadingF2__c, 
            ActiveReadingF2__c, CorrectorReading__c, ActiveReadingF0__c, MeterProductionYear__c, ActiveReadingF3__c, CorrectorNumber__c, TechnicalDataReceivingDate__c, 
            ActiveReadingF1__c, ActiveReadingF4__c, ReactiveReadingF4__c, MeterReading__c, PowerReadingF1__c, PowerReadingF0__c, ContractualAccountAndAnagraficOutcome__c FROM IntegrationCase__c LIMIT 1];
        System.debug('>>>integrationCase: ' + integrationCase);

        Case myCase = [SELECT Id,BlockStatus__c FROM Case LIMIT 1];
        System.debug('>>>Case: ' + myCase);

        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id FROM wrts_prcgvr__PhaseTransition__c LIMIT 1];

        //-----------------------method = callBlockPrescription--------------
        SObject obj = myCase;
        
       
       CEP_ApexAction apexAction = new CEP_ApexAction();   
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,   
            'method' => 'rateizzazioneSendDcs'
        }; 
        apexAction.execute(params);
        

        Test.stopTest();
        
    }
    
    
         @isTest
    static void updatePDRTypeOnServicePointTst(){
        
        Test.startTest(); 
        wrts_prcgvr__PhaseTransition__c transition = [SELECT Id, wrts_prcgvr__OriginPhase__c, wrts_prcgvr__DestinationPhase__c 
        FROM wrts_prcgvr__PhaseTransition__c    
        WHERE wrts_prcgvr__RecordTypeName__c = 'CEP_RT_Cancellation' 
        LIMIT 1];    
        transition.wrts_prcgvr__DestinationPhase__c = 'Chiusa Vinta';
        update transition;   
        Case cs1 = TestDataFactory.caseRecordBuilder().newCase().build();
        Case cs = [SELECT Id FROM Case LIMIT 1];
        cs.ParentId = cs1.Id; 
        update cs; 
        IntegrationCase__c intCase = [SELECT Id, Asset__c, Case__c, Opportunity__c, OpportunityServiceItem__c, SubChannel__c, Segment__c,ServicePoint__c FROM IntegrationCase__c LIMIT 1];
        intCase.Case__c = cs.Id;   
        update intCase;    
        Opportunity opp = [SELECT Id, Name, CancellationReason__c, SubChannel__c, ContactId, PrescreeningStatus__c, CreditCheckFullStatus__c, OpportunityRenewed__c, RequestType__c, PaymentTerms__c FROM Opportunity LIMIT 1];
        opp.SubChannel__c = 'Door to Door app';
        update opp;  
        OpportunityServiceItem__c osi = new OpportunityServiceItem__c(Id=intCase.OpportunityServiceItem__c,Process__c='Modifica Tipologia PDR'); 
        update osi;
        SObject obj = intCase;     
        CEP_ApexAction apexAction = new CEP_ApexAction();   
        Object params = (Object) new Map<String, Object>{
            'transition' => transition,
            'sender' => obj,   
            'method' => 'updatePDRTypeOnServicePoint'
        }; 
        apexAction.execute(params);
        
        Test.stopTest(); 
    }
     
    
}