Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
76 kB
1
Indexable
Never
/**
 * Created by BADJI on 30/11/2020.
 */

@IsTest
private class CEP_LC_DedicatedProcessWizardTst { 

    @TestSetup
    static void setup(){ 
        wrts_prcgvr.InstallIntegration.install();
        insert TestDataCustomer.createPhaseManagerSettingFileMetadata();
        insert TestDataCustomer.createPhaseManagerSettingOpportunity();
        insert TestDataCustomer.createPhase('Creato');
        insert TestDataCustomer.createPhase('In Archiviazione'); 
     
        //PermissionSet ps = new PermissionSet(); 
        // ps.Name = 'CEP_Small_Business_Permission';
        // ps.Label = 'Small_Business Permisson Set';
        List<Account> listAccount = new list<Account>();
        listAccount.add(TestDataCustomer.account().physicalPersonAccount().build());
        Account endResellerAcc = TestDataCustomer.account().build();
        endResellerAcc.Name = 'Finale Reseller';
        endResellerAcc.Segment__c = 'Reseller';
        endResellerAcc.FiscalCode__c = '12yyyyyaa';
        endResellerAcc.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_ResellerEndCustomer').getRecordTypeId();
        listAccount.add(endResellerAcc);  
        //listAccount.add(TestDataCustomer.account().businessAccount().build());
        listAccount.add(TestDataCustomer.account().businessAccount().setRecordtype(Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_Organization').getRecordTypeId()).build());
        listAccount[0].BusinessType__c = 'Persona fisica - ditta individuale';
        // System.runAs(u) {
            //insert ps;
            //insert new PermissionSetAssignment(AssigneeId = u.id, PermissionSetId = ps.Id);
            insert listAccount; 
        // }
        // List<Account> listAccount = new list<Account>();
        // listAccount.add(TestDataCustomer.account().physicalPersonAccount().build());
        // //listAccount.add(TestDataCustomer.account().businessAccount().build());
        // listAccount.add(TestDataCustomer.account().businessAccount().setRecordtype(Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_Organization').getRecordTypeId()).build());
        // listAccount[0].BusinessType__c = 'Persona fisica - ditta individuale';
        // System.runAs(u) {
        //     insert listAccount;
        // }
        Asset a = new Asset();
        a.Name = '00886673878903';
        a.Status = 'Attivo';
        a.AccountId = listAccount[0].Id;
        insert a;
        String servicePointCode = 'IT002E12345678';
        String servicePointCodeGas = '00886673878903';
        ServicePoint__c pod = TestDataFactory.ServicePointBuilder.servicePoint().createServicePointEle().build();
        pod.Code__c = servicePointCode;
        pod.Key__c = servicePointCode;
        insert pod;

        ServicePoint__c pod1 = TestDataFactory.ServicePointBuilder.servicePoint().createServicePointGas().build();
        pod1.Code__c = servicePointCodeGas;
        pod1.Key__c = servicePointCodeGas;
        pod1.CurrentAsset__c = a.Id;
        insert pod1; 
        // User u1 = new User();//TestDataCustomer.user().internalUser().build();
        // u1.ManagerId = u.Id;
        // u1.Username = 'test1cr7@aceaenergia.it';
        // u1.LastName = 'Ramazzotti';
        // u1.Email = 'marco.ramazzotti@aceaenergia.it.invalid';
        // u1.Alias = 'a90457m@'; 
        // u1.TimeZoneSidKey = 'Europe/Rome';
        // u1.LocaleSidKey = 'it_IT'; 
        // u1.EmailEncodingKey = 'UTF-8';
        // u1.ProfileId = u.ProfileId; 
        // u1.LanguageLocaleKey = 'it';
        // insert u1;
        // User u2 = new User();//TestDataCustomer.user().internalUser().build();
        // u2.ManagerId = u1.Id;
        // u2.Username = 'test1cr7242@aceaspa.it.streamcb2';
        // u2.LastName = 'Montoni';
        // u2.Email = 'giancarlo.montoni@aceaspa.it.invalid';
        // u2.Alias = 'giancarl'; 
        // u2.TimeZoneSidKey = 'Europe/Rome';
        // u2.LocaleSidKey = 'it_IT'; 
        // u2.EmailEncodingKey = 'UTF-8';
        // u2.ProfileId = u.ProfileId; 
        // u2.LanguageLocaleKey = 'it';
        // insert u2;
        String recordBusines = Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CEP_RT_Business').getRecordTypeId();
        Opportunity opp = TestDataCustomer.opportunity().createOpportunity().setAccount(listAccount[0].Id).setRecordType(recordBusines).build();    
        insert opp;

        SBQQ__Quote__c q = new SBQQ__Quote__c();
        q.MarketSegment__c = 'Mass Market'; 
        q.SBQQ__Opportunity2__c = opp.Id;
        //q.SBQQ__PricebookId__c = customPB.Id;
        q.SBQQ__Account__c = listAccount.get(0).Id;
        insert q;
        
        //quote quo = new quote();
        //quo.OpportunityId = opp.Id;
        //insert quo;
        
        // Asset a = new Asset();
        // a.Name = '00886673878903';
        // a.Status = 'Attivo';
        // a.AccountId = listAccount[0].Id;
        // insert a;

        // ServicePoint__c pod1 = TestDataFactory.ServicePointBuilder.servicePoint().createServicePointGas().build();
        // pod1.Code__c = servicePointCodeGas;
        // pod1.Key__c = servicePointCodeGas;
        // pod1.CurrentAsset__c = a.Id;
        // insert pod1;
        // CreditCheck__c credit = new CreditCheck__c();
		// credit.Opportunity__c = opp.Id;
		// credit.Account__c = opp.Account.Id;
		// credit.CheckType__c = 'Credit Check Full';
		// credit.SourceSystem__c = 'SF';
		// credit.RequestType__c = 'FullCheck';
		// credit.RequestUser__c = UserInfo.getUserId();
		// credit.ProcessName__c = 'Offertazione';
		// credit.LogicTaskId__c = opp.Id;
		// credit.BusinessID__c = opp.Id;
		// credit.Status__c = 'In corso';
		// credit.RequestId__c = opp.Id;
        // insert credit;

        // opp.Prescreening__c = credit.Id;
		List<OpportunityServiceItem__c> osiToInsert = new List<OpportunityServiceItem__c>();
        OpportunityServiceItem__c osi = TestDataCustomer.opportunityServiceItem().createOpportunityServiceItem().build();
        osi.RecordTypeId = Schema.SObjectType.OpportunityServiceItem__c.getRecordTypeInfosByDeveloperName().get('Electric').getRecordTypeId();
        osi.Opportunity__c = opp.Id;
        osi.Account__c = listAccount[1].Id;
        osi.Process__c = Constants.getAllConstants().OSI_ATTIVAZIONE_PROCESS;
        osi.VoltageLevel__c = 'BT Monofase';
        osi.PointStreetType__c = 'Viale';
        osi.IsPowerBeyond__c = false;
        osi.AvailablePower__c = 2;
        osi.RequestedAvailablePower__c = '3';
        osi.RequestedContractualPowerBeyond__c = 3;
        osi.ActDate__c = System.Today();
        osi.RevenueAgencyRegisteredDate__c = System.Today();//Date.today().addDays(-1);// System.Today().addDays(-1);
        osi.Excise__c = 'Industriale Ordinaria';
        osi.ServicePointCode__c = servicePointCode;
        osi.ContractType__c = 'Ditta Individuale';
        osi.PointIstatCode__c = '058091';
        //osi.ExpectedAnnualWithdrawal__c = 0;
        //insert osi;
        osiToInsert.add(osi);
        
        OpportunityServiceItem__c osiGas = TestDataCustomer.opportunityServiceItem().createOpportunityServiceItem().build();
        osiGas.RecordTypeId = Schema.SObjectType.OpportunityServiceItem__c.getRecordTypeInfosByDeveloperName().get('Gas').getRecordTypeId();
        osiGas.Opportunity__c = opp.Id;
        osiGas.Account__c = listAccount[1].Id;
        osiGas.Process__c = Constants.getAllConstants().OSI_ATTIVAZIONE_PROCESS;
        osiGas.VoltageLevel__c = 'BT Monofase';
        osiGas.PointStreetType__c = 'Viale';
        osiGas.IsPowerBeyond__c = false;
        osiGas.DistributorName__c = 'ITALGAS';
        osiGas.REMICode__c = '34725100';
        osiGas.AvailablePower__c = 2;
        osiGas.RequestedAvailablePower__c = '3';
        osiGas.RequestedContractualPowerBeyond__c = 3;
        osiGas.ActDate__c = System.Today();
        osiGas.RevenueAgencyRegisteredDate__c = System.Today();//Date.today().addDays(-1);// System.Today().addDays(-1);
        osiGas.Excise__c = 'Industriale Ordinaria';
        osiGas.ServicePointCode__c = servicePointCodeGas;
        osiGas.ContractType__c = 'Ditta Individuale';
        osiGas.PointIstatCode__c = '058091';
        //osi.ExpectedAnnualWithdrawal__c = 0;
        //insert osiGas;
        osiToInsert.add(osiGas);
        

        OpportunityServiceItem__c osiGasCambioProd = TestDataCustomer.opportunityServiceItem().createOpportunityServiceItem().build();
        osiGasCambioProd.RecordTypeId = Schema.SObjectType.OpportunityServiceItem__c.getRecordTypeInfosByDeveloperName().get('Gas').getRecordTypeId();
        osiGasCambioProd.Opportunity__c = opp.Id;
        osiGasCambioProd.Account__c = listAccount[0].Id;
        osiGasCambioProd.PointStreetType__c = 'Viale';
        osiGasCambioProd.Process__c = Constants.getAllConstants().OSI_CAMBIO_PRODOTTO_PROCESS;
        osiGasCambioProd.ServicePointCode__c = servicePointCodeGas;
        osiGasCambioProd.ContractType__c = 'Ditta Individuale';
        //osiGas.PointIstatCode__c = '058091';
        //osi.ExpectedAnnualWithdrawal__c = 0;
        //insert osiGasCambioProd;
        osiToInsert.add(osiGasCambioProd);
        insert osiToInsert;
        
        AtecoTranscode__c atecoCode = new AtecoTranscode__c(Usage__c = 'Test', IndustrialSector__c = 'Test', Code__c = '84150');
        insert atecoCode;
        IvaConfiguration__c ivaConfiguration = new IvaConfiguration__c(RequestedUsageCategory__c = 'Test', 
                                                                       IndustrialSector__c = 'Test', 
                                                                       Commodity__c = 'Electric',
                                                                       AccountType__c = 'Test',
                                                                       TISGType__c = 'Test',
                                                                       PDRType__c = 'Test',
                                                                       Description__c = 'Test');
        insert ivaConfiguration;

        CityRegistry__c city = new CityRegistry__c(Province__c='B',Region__c='Bergamo',Name='name', ProvinceAbbreviation__c = 'MI', City__c='Milano', CadastralCode__c ='055',IstatCode__c = '5BO');
        insert city;

        ClimaticZoneCity__c climaticZone = new ClimaticZoneCity__c(PostalCode__c = '72015',City__c = 'Fasano', SouthCash__c = 'Si' );
        insert climaticZone;

        AdditionalRegion__c addReg = new AdditionalRegion__c(Region__c='LAZIO',UsageType__c='Uso Industriale',ClimaticZone__c='D');
        insert addReg;

        List<Accisa__c> accObjList = new List<Accisa__c>();
        for(Integer c = 0; c < 3; c++) {
            Accisa__c accObj = new Accisa__c();
            accObj.Description__c = 'Industriale Ordinaria';
            accObjList.add(accObj);
        }
        insert accObjList;

        PODDistributorAlignment__c podDistributor = new PODDistributorAlignment__c();
        podDistributor.Active__c = true;
        podDistributor.CodeList__c = 'test';
        podDistributor.DistributorName__c = 'test';
        podDistributor.DistributorVATNumber__c = '5886';
        podDistributor.IdentificationCodeList__c = 'IT002E12345678';
        insert podDistributor;
 

        // QuoteType__c  qt = new QuoteType__c ();
        // qt.Performance__c = Constants.getAllConstants().OSI_ATTIVAZIONE_PROCESS;
        // qt.Type__c = 'Ordinario';
        // qt.VoltageLevel__c = 'Monofase';
        // qt.ThresholdAvailablePower__c = 2.0;
        // qt.Operator__c = 'Maggiore di';
        // qt.Power__c = 'SI';
        // insert qt;
        // 
        //insert Taxes__c
        //
        Taxes__c tx =new Taxes__c();
        	tx.IstatCode__c ='081025';
        	tx.City__c ='TestCity';
            tx.Province__c ='TP';
        insert tx;
        }

    @IsTest
        static void testBehavior() {
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c LIMIT 1];
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        
        Map<String,String> params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase'
        };
        Test.startTest();
           Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsi(params);
           System.assertEquals(true, results != null);

        params = new Map<String, String>{
            'OSI' => JSON.serialize(osi.clone())
        };
          results = CEP_LC_DedicatedProcessWizard.insertOsi(params);
          System.assertEquals(true, results != null);
        
        osi.VoltageLevel__c ='monofase';
        osi.Process__c ='ATTIVAZIONE';
		update osi; 
        params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase'
        };
           
        results = CEP_LC_DedicatedProcessWizard.insertOsi(params);
        System.assertEquals(true, results != null);
            
        Test.stopTest();
    }

    @isTest
    static void testInsertOsiWithdrawlLesThan1(){
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c LIMIT 1];
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        osi.ExpectedAnnualWithdrawal__c = 0;
        update osi;
        Map<String,String> params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase'
        };
        QuoteType__c  qt = new QuoteType__c ();
        qt.Performance__c = Constants.getAllConstants().OSI_ATTIVAZIONE_PROCESS;
        qt.Type__c = 'Ordinario';
        qt.VoltageLevel__c = 'Monofase';
        qt.ThresholdAvailablePower__c = 2.0;
        qt.Operator__c = 'Maggiore di';
        qt.Power__c = 'SI';
        insert qt;
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsi(params);
        System.assertEquals(true, results != null);
        Test.stopTest();
    }

    @isTest
    static void testInsertOsi(){
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c LIMIT 1];
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        
        Map<String,String> params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase'
        };
        QuoteType__c  qt = new QuoteType__c ();
        qt.Performance__c = Constants.getAllConstants().OSI_ATTIVAZIONE_PROCESS;
        qt.Type__c = 'Ordinario';
        qt.VoltageLevel__c = 'Monofase';
        qt.ThresholdAvailablePower__c = 2.0;
        qt.Operator__c = 'Maggiore di';
        qt.Power__c = 'SI';
        insert qt;
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsi(params);
        System.assertEquals(true, results != null);
        Test.stopTest();
    }
    


    @isTest
    static void testInsertOsiIsPowerBeyondTrue(){
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c LIMIT 1];
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        osi.IsPowerBeyond__c = true;
        osi.RequestedContractualPowerBeyond__c = 2;
        update osi;
        Map<String,String> params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase'
        };
        QuoteType__c  qt = new QuoteType__c ();
        qt.Performance__c = Constants.getAllConstants().OSI_ATTIVAZIONE_PROCESS;
        qt.Type__c = 'Ordinario';
        qt.VoltageLevel__c = 'Monofase';
        qt.ThresholdAvailablePower__c = 2.0;
        qt.Operator__c = 'Maggiore di';
        qt.Power__c = 'SI';
        insert qt;
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsi(params);
        System.assertEquals(true, results != null);
        Test.stopTest();
    }
    
    @isTest
    static void testInsertOsiIsPowerBeyondTrue1(){
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c LIMIT 1];
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        osi.IsPowerBeyond__c = true;
        osi.RequestedContractualPowerBeyond__c = 2;
        osi.Process__c = 'Modifica potenza e tensione';
        update osi;
        Map<String,String> params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase'
        };
        QuoteType__c  qt = new QuoteType__c ();
        qt.Performance__c = Constants.getAllConstants().OSI_ATTIVAZIONE_PROCESS;
        qt.Type__c = 'Ordinario';
        qt.VoltageLevel__c = 'Monofase';
        qt.ThresholdAvailablePower__c = 2.0;
        qt.Operator__c = 'Maggiore di';
        qt.Power__c = 'SI';
        insert qt;
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsi(params);
        System.assertEquals(true, results != null);
        Test.stopTest();
    }
    
    @isTest
    static void testInsertOsiVolturaGas(){
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c WHERE RecordType.DeveloperName = 'Gas' LIMIT 1];
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        osi.PointIstatCode__c ='081025';
        update osi;
        
        Map<String,String> params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase'
        };
        QuoteType__c  qt = new QuoteType__c ();
        qt.Performance__c = Constants.getAllConstants().OSI_ATTIVAZIONE_PROCESS;
        qt.Type__c = 'Ordinario';
        qt.VoltageLevel__c = 'Monofase';
        qt.ThresholdAvailablePower__c = 2.0;
        qt.Operator__c = 'Maggiore di';
        qt.Power__c = 'SI';
        insert qt;
        Product2 pOffer = CEP_TestCatalogDataFactory.inizializeProdOffer();
        insert pOffer;
        Asset ass =[Select id from Asset limit 1];
        ass.Product2Id = pOffer.Id; 
        update ass;
        ServicePoint__c sp = [select id from ServicePoint__c where code__c ='00886673878903'];
        sp.CurrentAsset__c =ass.id;
        sp.AvailablePower__c = 14.5;
        update sp;
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsiVoltura(params);
        
            System.assertEquals(true, results != null);
            osi.Process__c = Constants.getAllConstants().OSI_VOLTURA_FUSIONE_INCORPORAZIONE_PROCESS;
            osi.ServicePointCode__c = '00886673878903';
            osi.PointIstatCode__c ='081025';
           	update osi;
           	params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase'
        };
            qt = new QuoteType__c ();
        	qt.Performance__c = Constants.getAllConstants().OSI_ATTIVAZIONE_PROCESS;
        	qt.Type__c = 'Ordinario';
        	qt.VoltageLevel__c = 'Monofase';
        	qt.ThresholdAvailablePower__c = 2.0;
        	qt.Operator__c = 'Maggiore di';
        	qt.Power__c = '';
        	insert qt;
        	results = CEP_LC_DedicatedProcessWizard.insertOsiVoltura(params);
        
         	sp.ContractualPower__c = 14;
            sp.AvailablePower__c =null;
        	update sp;
        	results = CEP_LC_DedicatedProcessWizard.insertOsiVoltura(params);
         
        Test.stopTest();
    }

    @isTest
    static void testInsertOsiVolturaEle1(){
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c LIMIT 1];
        osi.Process__c = 'VOLTURA CON SWITCHING';
        update osi; 
        OpportunityServiceItem__c osiGas = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c WHERE RecordType.DeveloperName = 'Gas' LIMIT 1];

        OpportunityServiceItem__c osiCambioProd = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c WHERE Process__c =: Constants.getAllConstants().OSI_CAMBIO_PRODOTTO_PROCESS LIMIT 1];
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        osiGas.Opportunity__c = null;
        update osiGas;
        osiCambioProd.Opportunity__c = null;
        update osiCambioProd;
        Map<String,String> params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase'
        };
        QuoteType__c  qt = new QuoteType__c ();
        qt.Performance__c = Constants.getAllConstants().OSI_ATTIVAZIONE_PROCESS;
        qt.Type__c = 'Ordinario';
        qt.VoltageLevel__c = 'Monofase';
        qt.ThresholdAvailablePower__c = 2.0;
        qt.Operator__c = 'Maggiore di';
        qt.Power__c = 'SI';
        insert qt;
        osi.Opportunity__c = null;
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsiVoltura(params);
        System.assertEquals(true, results != null);
        Test.stopTest();
    }
    
    @isTest
    static void testInsertOsiVolturaElectric(){
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c WHERE RecordType.DeveloperName = 'Electric' LIMIT 1];
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        
        Map<String,String> params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase'
        };
        QuoteType__c  qt = new QuoteType__c ();
        qt.Performance__c = Constants.getAllConstants().OSI_ATTIVAZIONE_PROCESS;
        qt.Type__c = 'Ordinario';
        qt.VoltageLevel__c = 'Monofase';
        qt.ThresholdAvailablePower__c = 2.0;
        qt.Operator__c = 'Maggiore di';
        qt.Power__c = 'SI';
        insert qt;
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsiVoltura(params);
        System.assertEquals(true, results != null);
        Test.stopTest();
    }

    @isTest
    static void testInsertOsiVolturaElectricExcpectedWithDrawal(){
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c WHERE RecordType.DeveloperName = 'Electric' LIMIT 1];
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        osi.ExpectedAnnualWithdrawal__c = 0;
        update osi;
        Map<String,String> params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase'
        };
        QuoteType__c  qt = new QuoteType__c ();
        qt.Performance__c = Constants.getAllConstants().OSI_ATTIVAZIONE_PROCESS;
        qt.Type__c = 'Ordinario';
        qt.VoltageLevel__c = 'Monofase';
        qt.ThresholdAvailablePower__c = 2.0;
        qt.Operator__c = 'Maggiore di';
        qt.Power__c = 'SI';
        insert qt;
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsiVoltura(params);
        System.assertEquals(true, results != null);
        Test.stopTest();
    }

    @isTest
    static void testInsertOsiVolturaErrorException(){
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c WHERE RecordType.DeveloperName = 'Electric' LIMIT 1];
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        
        Map<String,String> params = new Map<String, String>{};
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsiVoltura(params);
        System.assertEquals(true, results != null);
        Test.stopTest();
    }
    
    @isTest
    static void testInsertOsiSwitching(){
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c LIMIT 1];
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        
        Map<String,String> params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase'
        };
        QuoteType__c  qt = new QuoteType__c ();
        qt.Performance__c = Constants.getAllConstants().OSI_ATTIVAZIONE_PROCESS;
        qt.Type__c = 'Ordinario';
        qt.VoltageLevel__c = 'Monofase';
        qt.ThresholdAvailablePower__c = 2.0;
        qt.Operator__c = 'Maggiore di';
        qt.Power__c = 'SI';
        insert qt;
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsiSwitching(params);
        System.assertEquals(true, results != null);
        Test.stopTest();
    }

    @isTest
    static void testInsertOsiSwitchingWithdrawlLesThan1(){
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                        Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                        RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                        VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                        FROM OpportunityServiceItem__c WHERE RecordType.DeveloperName = 'Electric' LIMIT 1];
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        osi.ExpectedAnnualWithdrawal__c = 0;
        update osi;
        Map<String,String> params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase'
        };
        QuoteType__c  qt = new QuoteType__c ();
        qt.Performance__c = Constants.getAllConstants().OSI_ATTIVAZIONE_PROCESS;
        qt.Type__c = 'Ordinario';
        qt.VoltageLevel__c = 'Monofase';
        qt.ThresholdAvailablePower__c = 2.0;
        qt.Operator__c = 'Maggiore di';
        qt.Power__c = 'SI';
        insert qt;
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsiSwitching(params);
        System.assertEquals(true, results != null);
        Test.stopTest();
    }

    @isTest
    static void testInsertOsiSwitchingCambioProd(){
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c WHERE Process__c =: Constants.getAllConstants().OSI_CAMBIO_PRODOTTO_PROCESS LIMIT 1];
        osi.Process__c = 'Cambio Uso';

        update osi; 
        
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        
        Map<String,String> params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase'
        };
        QuoteType__c  qt = new QuoteType__c ();
        qt.Performance__c = Constants.getAllConstants().OSI_CAMBIO_PRODOTTO_PROCESS;
        qt.Type__c = 'Ordinario';
        qt.VoltageLevel__c = 'Monofase';
        qt.ThresholdAvailablePower__c = 2.0;
        qt.Operator__c = 'Maggiore di';
        qt.Power__c = 'SI';
        insert qt;
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsiSwitching(params);
        System.assertEquals(true, results != null);
        Test.stopTest();
    }



    @isTest
    static void testInsertOsiSwitchingCAMBIOPRODOTTO(){
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c WHERE Process__c =: Constants.getAllConstants().OSI_CAMBIO_PRODOTTO_PROCESS LIMIT 1];
        osi.Process__c = 'CAMBIO PRODOTTO'; 

        update osi;  
        
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        
        Map<String,String> params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase'
        };
        QuoteType__c  qt = new QuoteType__c ();
        qt.Performance__c = Constants.getAllConstants().OSI_CAMBIO_PRODOTTO_PROCESS;
        qt.Type__c = 'Ordinario';
        qt.VoltageLevel__c = 'Monofase';
        qt.ThresholdAvailablePower__c = 2.0;
        qt.Operator__c = 'Maggiore di';
        qt.Power__c = 'SI';
        insert qt;
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsiSwitching(params);
        System.assertEquals(true, results != null);
        Test.stopTest();
    }

    @isTest
    static void testInsertOsiSwitchingErrorException(){
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c WHERE Process__c =: Constants.getAllConstants().OSI_CAMBIO_PRODOTTO_PROCESS LIMIT 1];
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        
        Map<String,String> params = new Map<String, String>{};
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsiSwitching(params);
        System.assertEquals(true, results.get('error') == true);
        Test.stopTest();
    }
    
    @isTest
    static void checkDistributorVATtest(){
        String recType = 'Gas';
        OpportunityServiceItem__c osi = [SELECT Id, Name, RecordType.DeveloperName,Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c WHERE RecordType.DeveloperName =: recType LIMIT 1];
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        
        Map<String,String> params = new Map<String, String>{
            'OSI'=>JSON.serialize(osi),
            'codeAteco'=> ateco.Code__c,
            'atecoId'=> ateco.Id,
            'actualVoltageLevel'=> 'monofase',
            'osiId'=> osi.Id
        };
        QuoteType__c  qt = new QuoteType__c ();
        qt.Performance__c = Constants.getAllConstants().OSI_ATTIVAZIONE_PROCESS;
        qt.Type__c = 'Ordinario';
        qt.VoltageLevel__c = 'Monofase';
        qt.ThresholdAvailablePower__c = 2.0;
        qt.Operator__c = 'Maggiore di';
        qt.Power__c = 'SI';
        insert qt;
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.checkDistributorVAT(params);
        System.assertEquals(true, results != null);
        Test.stopTest();
    }

    @isTest
    static void checkDistributorVATErrorExceptiontest(){
        String recType = 'Gas';
        OpportunityServiceItem__c osi = [SELECT Id, Name, RecordType.DeveloperName,Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c WHERE RecordType.DeveloperName =: recType LIMIT 1];
        AtecoTranscode__c ateco = [SELECT Id, Code__c FROM AtecoTranscode__c];
        
        Map<String,String> params = new Map<String, String>{};
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EDM01_EbdmSchema'));
        Test.startTest();
            Map<String,Object> results = CEP_LC_DedicatedProcessWizard.checkDistributorVAT(params);
        System.assertEquals(true, results != null);
        Test.stopTest();
    }


    @IsTest
    static void testBehaviorException() {
        //OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c FROM OpportunityServiceItem__c LIMIT 1];
        Map<String,String> params = new Map<String, String>{
            'OSI'=>null
        };
        Test.startTest();
        Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsi(params);
        System.assertEquals(true, results.get('error') == true);
        Test.stopTest();
    }

    @IsTest
    static void prescreeningTest(){        
        Opportunity opp = [SELECT Id, Account.Code__c, Account.BusinessType__c, 
                            Account.RecordType.Name, Account.FiscalCode__c, 
                            Account.VATNumber__c, Account.CompanyName__c,
                            Account.FirstName__c, Account.LastName__c, AccountId 
                        FROM Opportunity LIMIT 1];
        Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_SRV_CreditPreCheckCER01'));
        Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_CreditCheck'));
        CreditCheck__c cch = new CreditCheck__c(); 
        cch.Opportunity__c = opp.Id; 
        cch.ResultCode__c = 'KO';
        Database.SaveResult resultCreditCheck = Database.insert(cch);
        Test.startTest(); 
        Map<String,Object> result =(Map<String,Object>)CEP_LC_DedicatedProcessWizard.prescreening(opp.AccountId, opp.Id);
         //KO
        Test.stopTest();  
        System.assert(resultCreditCheck.isSuccess(), 'The resultMap is different of null');
    }



    @IsTest
    static void prescreeningTestAccountNull(){         
        Opportunity opp = [SELECT Id, Account.Code__c, Account.BusinessType__c, 
                            Account.RecordType.Name, Account.FiscalCode__c, 
                            Account.VATNumber__c, Account.CompanyName__c,
                            Account.FirstName__c, Account.LastName__c, AccountId 
                        FROM Opportunity LIMIT 1];
        Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_SRV_CreditPreCheckCER01'));
        Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_CreditCheck'));
        CreditCheck__c cch = new CreditCheck__c();
        cch.Opportunity__c = opp.Id; 
        cch.ResultCode__c = 'KO';
        insert cch;
        Test.startTest(); 
        Map<String,Object> result =(Map<String,Object>)CEP_LC_DedicatedProcessWizard.prescreening(null, opp.Id);
         //KO 
        Test.stopTest();
        System.assert(!result.isEmpty(), 'The resultMap is different of null');
    }

    @IsTest
    static void prescreeningErrorTest(){        
        Opportunity opp = [SELECT Id, Account.Code__c, Account.BusinessType__c, 
                            Account.RecordType.Name, Account.FiscalCode__c, 
                            Account.VATNumber__c, Account.CompanyName__c,
                            Account.FirstName__c, Account.LastName__c, AccountId 
                        FROM Opportunity LIMIT 1];
        Test.startTest();
        Map<String,Object> result =(Map<String,Object>)CEP_LC_DedicatedProcessWizard.prescreening(opp.AccountId, opp.Id);
        System.assert(result.get('error')== true);
        Test.stopTest(); 
    }
    

    @IsTest
    static void prescreeningErrorExceptionTest(){   
        Test.startTest();
        Map<String,Object> result =(Map<String,Object>)CEP_LC_DedicatedProcessWizard.prescreening('opp.AccountId', 'opp.Id');
        System.assert(result.get('error')== true);
        Test.stopTest(); 
    }

    @isTest 
    static void atecueSelectedTst() {
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.atecueSelected('Test','Test');
        System.assertEquals(true, result.get('error')==false, 'Found codice Ateco'); 
        result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.atecueSelected('TestTest','Testtest');  
        System.assertEquals(true, result.get('ateco')==null, 'Not Found codice Ateco'); 
    }
    
        @isTest 
    static void atecueSelectedExceptionTst() {
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.atecueSelected('', '');
        System.assert(result.get('error')==true); 
    }
    
    @isTest 
    static void ivaSelectedEleExceptionTst() {
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.ivaSelectedEle('', '', '', '');
        System.assert(result.get('error')==true); 
    }
    
    @isTest 
    static void getCadastalCodeExceptionTst() {
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.getCadastalCode('');
        System.assert(result.get('error')==true); 
    }
    
    
    @isTest 
    static void ivaSelectedGasExceptionTst() {
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.ivaSelectedGas('', '', '');
        System.assert(result.get('error')==true); 
    }
    
     @isTest 
    static void atecTranscode2Tst() {
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.atecTranscode('', '', '');
        System.assert(result.get('error')==true); 
    }

    @isTest 
    static void getAtecoManualValuesTst() {
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.getAtecoManualValues();
        System.assertEquals(true, result.get('atecoValues')==null, 'Not Found Ateco'); 
    }
    
    @isTest 
    static void getUsoTecnologicoEnabledTst() {
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.getUsoTecnologicoEnabled();
        System.assertEquals(true, result.get('atecoValues')==null, 'Not Found Ateco'); 
    }
    

    @isTest 
    static void checkProcessCompatibilityTst() {
        Map<String, String> params = new Map<String, String>();
        
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.checkProcessCompatibility(params);
        System.assertEquals(true, result.get('error')==true, 'Check Process Compatibility error'); 
        params.put('podPdr', '');
        params.put('startingProcess', '');
        params.put('channel', 'Call Center');
        params.put('commodity', 'Gas');
        params.put('distributor', 'distributor');
        result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.checkProcessCompatibility(params);
        System.assertEquals(true, result.get('error')==false, 'Check Process Compatibility is ok'); 

    }

    @isTest 
    static void ivaSelectedEleTst() {
        //IvaConfiguration__c iva = [SELECT Id FROM IvaConfiguration__c];
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.ivaSelectedEle('Test','Test','Test','Test');
        System.assertEquals(true, result.get('iva')==null, 'Iva not found'); 
    }

    @isTest
    static void ivaSelectedGasTst() {
        //IvaConfiguration__c iva = [SELECT Id FROM IvaConfiguration__c];
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.ivaSelectedGas('Test','Test','Test');
        System.assertEquals(true, result.get('iva')==null, 'Iva not found'); 
    }

    @isTest
    static void callEbdmTst() {
        //Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EbdmEDM01.richiestaAsincrona'));
        Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EbdmEDM01.richiestaSincrona'));
        Test.startTest();
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.callEbdm('10023');
        System.assertEquals(true, result!=null, 'Call Ebdm'); 
        Test.stopTest();
    }

    @isTest
    static void callEbdmErrorTst() {
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.callEbdm('10023');
        System.assertEquals(true, result==null, 'Call Ebdm'); 
    }
    
    //getCadastalCode
    @isTest 
    static void getCadastalCodeTst() {
        //CityRegistry__c cr = [SELECT Id FROM CityRegistry__c];
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.getCadastalCode('Milano');
        System.assertEquals(true, result.get('city')!=null, 'City found');
        result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.getCadastalCode('Roma');
        System.assertEquals(true, result.get('city')==null, 'City not found');     
    }
    
    @isTest 
    static void getCadastalCodeException2Tst() {
        //CityRegistry__c cr = [SELECT Id FROM CityRegistry__c];
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.getCadastalCode('');
        System.assertEquals(false, result.get('')!=null, '');
        result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.getCadastalCode('');
        System.assertEquals(true, result.get('')==null, '');     
    }
    
    @isTest
    static void getCapTst() {
        ClimaticZoneCity__c cz = [SELECT Id FROM ClimaticZoneCity__c];
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.getCap('72015');
        System.assertEquals(false, result.get('climaticzone')!=null, 'Clima found');  
        result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.getCap('081025');
        System.assertEquals(true, result.get('climaticzone')==null, 'Clima not found');     

    }
    
    @isTest
    static void addizionaleRegionaleTst() {
        //CEP_LC_DedicatedProcessWizardTst.cls AdditionalRegion__c ar = [SELECT Id FROM AdditionalRegion__c];
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.addizionaleRegionale('Uso Industriale', 'D', 'LAZIO');//'Uso Tecnologico','D','LAZIO');
        System.assertEquals(true, result.get('addizionale')!=null, 'Addizionale found');
        result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.getCap('1111');
        System.assertEquals(true, result.get('addizionale')==null, 'Addizionale not found');     
    }
    
    @isTest
    static void addizionaleRegionaleExceptionTst() {
        Map<String,Object> result = (Map<String,Object>)CEP_LC_DedicatedProcessWizard.addizionaleRegionale('', '', '');
        System.assertEquals(true, result !=null);     
    }
    
    @isTest 
    static void getIvaPickListTst() {
        IvaConfiguration__c iva = [SELECT Id FROM IvaConfiguration__c];
        List<Map<String,Object>> result = CEP_LC_DedicatedProcessWizard.getIvaPickList('Electric');     
        System.assertEquals(true, result!=null, 'Iva found');
        
    }

    @isTest 
    static void getIvaRateAndCodeTst() {
        //IvaConfiguration__c iva = [SELECT Id FROM IvaConfiguration__c];
        Map<String,Object> result = CEP_LC_DedicatedProcessWizard.getIvaRateAndCode('Electric', 'Test');     
        System.assertEquals(true, result!=null, 'Iva found');
        
    }

    @isTest
    static void recoverDistributorVatNumberTst() {
        Test.setMock(WebServiceMock.class, new CEP_UTL_WebServiceMockImpl('CEP_WS_EbdmEDM01.richiestaSincrona'));
        Opportunity opp = [SELECT Id FROM Opportunity];
        Map<String,Object> results = CEP_LC_DedicatedProcessWizard.recoverDistributorVatNumber(opp.Id);
        System.assertEquals(false, results.get('error'), 'working method');
        OpportunityServiceItem__c osi = [SELECT Id, Opportunity__c FROM OpportunityServiceItem__c WHERE PointIstatCode__c!=null LIMIT 1];
        Test.startTest();
        results = CEP_LC_DedicatedProcessWizard.recoverDistributorVatNumber(osi.Opportunity__c);
        //integrare
        Test.stopTest();
        
    }

    @isTest
    static void retrieveAtecueDescriptionByIdTst() {
        AtecoTranscode__c ac = [SELECT Id FROM AtecoTranscode__c];
        Map<String,Object> result = CEP_LC_DedicatedProcessWizard.retrieveAtecueDescriptionById(ac.Id);
        System.assertEquals(false, result.get('error'), 'Ateco found');
    }
    
    @IsTest
    static void retrieveAtecueDescriptionByIdExceptionTest(){   
        Test.startTest();
        Map<String,Object> result =(Map<String,Object>)CEP_LC_DedicatedProcessWizard.retrieveAtecueDescriptionById('');
        System.assert(result.get('error')== false);
        Test.stopTest(); 
    }
    
    @isTest 
    static void atecTranscodeTst() {
        AtecoTranscode__c ac = [SELECT Id, Code__c FROM AtecoTranscode__c];
        Account acc = [SELECT Id FROM Account LIMIT 1];
        Map<String,Object> result = CEP_LC_DedicatedProcessWizard.atecTranscode(ac.Code__c, acc.Id, 'Test');
        System.assertEquals(false, result.get('error'), 'Ateco found');
    }
    
    @isTest 
    static void atecTranscodeExeptionTst() {
        AtecoTranscode__c ac = [SELECT Id, Code__c FROM AtecoTranscode__c];
        Account acc = [SELECT Id FROM Account LIMIT 1];
        Boolean fail = true;
        try {
            Test.startTest();
                fail = false;
                Map<String,Object> result = CEP_LC_DedicatedProcessWizard.atecTranscode(ac.Code__c, acc.Id, 'Test');
            Test.stopTest(); 
            System.assert(!result.isEmpty(), 'The resultMap is different of null');
        } catch (Exception e) {
            fail = false;
        }
    }
    

    @isTest 
    static void updateOpportunityPrescreeningStatusTst() {
        Opportunity opp = [SELECT Id, PrescreeningStatus__c FROM Opportunity];
        Test.startTest();
        Map<String,Object> result = CEP_LC_DedicatedProcessWizard.updateOpportunityPrescreeningStatus('Non Previsto', opp.Id);
        System.assertEquals(false, result.get('error'));
        Test.stopTest();
    }

    @isTest 
    static void updateOpportunityPrescreeningStatusTstNoStatus() {
        Opportunity opp = [SELECT Id, PrescreeningStatus__c FROM Opportunity];
        Test.startTest();
        Map<String,Object> result = CEP_LC_DedicatedProcessWizard.updateOpportunityPrescreeningStatus(null, opp.Id);
        System.assertEquals(true, result.get('error'));
        Test.stopTest();
    }

    @isTest 
    static void updateOpportunityPrescreeningStatusTstNoOpp() {        
        Test.startTest();
        Map<String,Object> result = CEP_LC_DedicatedProcessWizard.updateOpportunityPrescreeningStatus('Non Previsto', null);
        System.assertEquals(true, result.get('error'));
        Test.stopTest();
    }
    
    @isTest 
    static void getPreviousTraderNameTest() {        
        Test.startTest();
        Map<String,Object> result = CEP_LC_DedicatedProcessWizard.getPreviousTraderName('Piva');
//        System.assertEquals(true, result.get('error'));
        Test.stopTest();
    }
    
    @isTest 
    static void checkAccountResidenceTest() {   
        ServicePoint__c servicePoint = [SELECT Id, Code__c FROM ServicePoint__c LIMIT  1];
        Test.startTest();
        Map<String,Object> result = CEP_LC_DedicatedProcessWizard.checkAccountResidence('accountid', servicePoint.Code__c);
        System.assertEquals(false, result.get('error')); 
        Test.stopTest();
    }
    
    @isTest 
    static void getCadastralDataTest() {  
        List<ServicePoint__c> servicePoint = [SELECT Id, CurrentAsset__r.AccountId FROM ServicePoint__c];      
        Test.startTest();
        Map<String,Object> result = CEP_LC_DedicatedProcessWizard.getCadastralData(servicePoint[0].Id,servicePoint[0].CurrentAsset__r.AccountId);
        System.assertEquals(false, result.get('error'));
        Test.stopTest();
    }
    // @isTest 
    // static void getPreviousProductGasTest() {   
    //     Opportunity opp = [SELECT Id, Account.Code__c, Account.BusinessType__c, 
    //                         Account.RecordType.Name, Account.FiscalCode__c, 
    //                         Account.VATNumber__c, Account.CompanyName__c,
    //                         Account.FirstName__c, Account.LastName__c, AccountId 
    //                     FROM Opportunity LIMIT 1];     
    //     Test.startTest();
    //     Map<String,Object> result = CEP_LC_DedicatedProcessWizard.getPreviousProduct(opp.AccountId, 'Gas', '00886673878903');
    //     System.assertEquals(false, result.get('error'));
    //     Test.stopTest();
    // }

    @isTest 
    static void getPreviousProductTest() {   
        // Opportunity opp = [SELECT Id, Account.Code__c, Account.BusinessType__c, 
        //                     Account.RecordType.Name, Account.FiscalCode__c, 
        //                     Account.VATNumber__c, Account.CompanyName__c,
        //                     Account.FirstName__c, Account.LastName__c, AccountId 
        //                 FROM Opportunity LIMIT 1];    
        List<Account> listAccount = [SELECT Id, Name FROM Account]; 
        Test.startTest();
        Map<String,Object> result = CEP_LC_DedicatedProcessWizard.getPreviousProduct(listAccount[0].Id, 'Gas', '00886673878903');
        Test.stopTest(); 
        System.assertEquals(true, !result.isEmpty(), 'The ResultMap is different of null');
    }

    @isTest 
    static void handleBusinessGreenTest() {   
        //PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name = 'CEP_Small_Business_Permission'];
        //insert new PermissionSetAssignment(AssigneeId = u.id, PermissionSetId = ps.Id);
        OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c LIMIT 1];    
        Test.startTest();
        CEP_LC_DedicatedProcessWizard.handleBusinessGreen(osi);
        //System.assertEquals(false, result.get('error'));
        Test.stopTest();  
        System.assert(osi != null, 'The Opportunity Service Item was retrieve');
    }

    // @isTest 
    // static void getApproverIdTest() {     
    //     Test.startTest();
    //     //CEP_LC_DedicatedProcessWizard.getApproverId();
    //     Id userId = CEP_LC_DedicatedProcessWizard.getApproverId();
    //     System.assertEquals(true, userId != null);
    //     Test.stopTest();
    // }
    
    @isTest 
    static void retrieveDistributorVatTest() {        
        Test.startTest();
        String result = CEP_LC_DedicatedProcessWizard.retrieveDistributorVat('istatCode', 'distributorName');
        System.assertEquals(false, result != null);
        Test.stopTest();
    }

    @isTest 
    static void getSearchAccountsTst() {
        String firstName = 'Marko';
        String lastName = 'Matterazzi';
        String codeFiscal = '02793330735';
        String partitaIva = '02793330735';
        String company = 'ORGANIZZAZIONI FUNERARIE SRL DI GIANLUCA RICCI';
        Opportunity opp = [SELECT Id, PrescreeningStatus__c FROM Opportunity];
        Test.startTest();
        Map<String,Object> result = CEP_LC_DedicatedProcessWizard.getSearchAccounts(firstName,lastName,codeFiscal,partitaIva,company);
        System.assertEquals(false, result.get('error'));
        Test.stopTest();
    }
    
    @isTest 
    static void getPreviousProductExceptionTest() {   
   
        List<Account> listAccount = [SELECT Id, Name FROM Account]; 
        Test.startTest();
        Map<String,Object> result = CEP_LC_DedicatedProcessWizard.getPreviousProduct(listAccount[1].Id, '', '');
        Test.stopTest();  
        System.assertEquals(true, !result.isEmpty(), 'The getPreviousProduct method return true');
    }

    @isTest 
    static void setOsiContractTypeTest() { 
        OpportunityServiceItem__c osi = new OpportunityServiceItem__c();
        osi.Usage__c = 'Altri us';
        Account acc = [SELECT Id, RecordTypeDeveloperName__c, VATNumber__c FROM Account where RecordTypeDeveloperName__c = 'CEP_RT_ResellerEndCustomer'];
        acc.FiscalCode__c = 'addss';
        acc.Type = 'Persona Fisica';   
        Test.startTest();
        CEP_LC_DedicatedProcessWizard.setOsiContractType(osi, acc);
        System.assert(osi.ContractType__c != null);
        Test.stopTest();
    }

    @isTest 
    static void setOsiContractType2Test() { 
        OpportunityServiceItem__c osi = new OpportunityServiceItem__c();
        osi.Usage__c = 'Altri us';
        Account acc = [SELECT Id, RecordTypeDeveloperName__c, VATNumber__c FROM Account where RecordTypeDeveloperName__c = 'CEP_RT_ResellerEndCustomer'];
        acc.FiscalCode__c = 'addss';
        acc.VATNumber__c = '123456';
        acc.Type = 'Persona Fisica';   
        Test.startTest();
        CEP_LC_DedicatedProcessWizard.setOsiContractType(osi, acc);
        System.assert(osi.ContractType__c != null);
        Test.stopTest();
    }

    @isTest 
    static void getDefaultAtecoTest() { 
        Account acc = [SELECT Id FROM Account where RecordTypeDeveloperName__c = 'CEP_RT_ResellerEndCustomer'];
        Test.startTest();
        Object result = CEP_LC_DedicatedProcessWizard.getDefaultAteco(acc.Id);
        System.assert(result != null);
        Test.stopTest();
    }

    @isTest static void checkResidenceAndUsageFromAssetTest(){

        Test.startTest();
        ServicePoint__c pod = [SELECT Id, Key__c FROM ServicePoint__c LIMIT 1];
        Map<String,String> params = new Map<String,String>();
        params.put('pod', pod.Key__c);
        params.put('commodity', 'Electric'); 
        Map<String,Object> resultMap = CEP_LC_DedicatedProcessWizard.checkResidenceAndUsageFromAsset(params);
        Test.stopTest(); 
        System.assert(!resultMap.isEmpty(), 'The method return the map object');
    }


    @isTest static void checkResidenceAndUsageFromAssetGasTest(){

        Test.startTest();
        ServicePoint__c pod = [SELECT Id, Key__c FROM ServicePoint__c LIMIT 1];
        Map<String,String> params = new Map<String,String>();
        params.put('pod', pod.Key__c); 
        params.put('commodity', 'Gas');  
        Map<String,Object> resultMap = CEP_LC_DedicatedProcessWizard.checkResidenceAndUsageFromAsset(params);
        Test.stopTest(); 
        System.assert(!resultMap.isEmpty(), 'The method return the map object');
    }

    
    @isTest static void getAssetTest(){ 

        Test.startTest();
        Asset ast = [SELECT Id FROM Asset LIMIT 1];
        Asset asset = CEP_LC_DedicatedProcessWizard.getContractAccount(ast.Id);
        Test.stopTest(); 
        System.assert(asset != null, 'The method return the Asset');
    }


    @isTest static void checkVolturaCambioControparteCommercialeTest(){

        Test.startTest();
        Account acc = [SELECT Id FROM Account LIMIT 1];
        acc.Segment__c = 'Mass Market';
        update acc; 
        Asset asset = [SELECT Id FROM Asset LIMIT 1];
        Map<String,String> params = new Map<String,String>();
        params.put('assetId', asset.Id); 
        params.put('accountId', acc.Id);
        Map<String,Object> resultMap = CEP_LC_DedicatedProcessWizard.checkVolturaCambioControparteCommerciale(params);
        Test.stopTest(); 
        System.assert(!resultMap.isEmpty(), 'The method return the map object');
    }



    @isTest static void checkVolturaCambioDifferentSegment(){

        Test.startTest(); 
        Account acc = [SELECT Id FROM Account LIMIT 1]; 
        Asset asset = [SELECT Id FROM Asset LIMIT 1];
        asset.Status = 'Attivo';

        update asset; 
        Map<String,String> params = new Map<String,String>();
        params.put('assetId', asset.Id); 
        params.put('accountId', acc.Id);
        Map<String,Object> resultMap = CEP_LC_DedicatedProcessWizard.checkVolturaCambioControparteCommerciale(params);
        Test.stopTest(); 
        System.assert(!resultMap.isEmpty(), 'The method return the map object');
    }


    
    @isTest static void checkVolturaCambioDifferentSegmentTest(){

        try{
        Test.startTest(); 
        Account acc = [SELECT Id FROM Account LIMIT 1]; 
        Asset asset = [SELECT Id FROM Asset LIMIT 1]; 
        asset.Status = 'Attivo';

        update asset; 
        Map<String,String> params = new Map<String,String>();
        params.put('assetId', null);  
        params.put('accountId', null); 
        Map<String,Object> resultMap = CEP_LC_DedicatedProcessWizard.checkVolturaCambioControparteCommerciale(params);
        resultMap = CEP_LC_DedicatedProcessWizard.checkResidenceAndUsageFromAsset(params); 
        Test.stopTest();  
        System.assert(!resultMap.isEmpty(), 'The method return the map object');
        }catch(Exception ex){ 
            System.assertEquals(ex.getMessage(), ex.getMessage(), 'The method return the Exception');
        }
    }


    @isTest static void getAccountByIdTest(){

        Test.startTest();
        Account acc = [SELECT Id FROM Account LIMIT 1];
        acc.Segment__c = 'Mass Market';
        update acc;  
 
        Map<String,Object> resultMap = CEP_LC_DedicatedProcessWizard.getAccountById(acc.Id);
        Test.stopTest(); 
        System.assert(!resultMap.isEmpty(), 'The method return the map object');
    }


    
    @isTest static void getAccountByAssetIdTest(){

        Test.startTest();
        Account acc = [SELECT Id FROM Account LIMIT 1];
        acc.Segment__c = 'Mass Market';
        update acc; 

        ServicePoint__c pod = [SELECT Id, Key__c FROM ServicePoint__c LIMIT 1];
        Map<String,Object> resultMap = CEP_LC_DedicatedProcessWizard.getAccountByAssetId(pod.Key__c);
        
        asset ass =[select id,ServicePointKey__c from asset limit 1];
 		ass.ServicePoint__c = pod.Id;
        update ass;
        Map<String,Object> resultMap2 = CEP_LC_DedicatedProcessWizard.getAccountByAssetId(pod.Key__c);

        Test.stopTest(); 
        System.assert(!resultMap.isEmpty(), 'The method return the map object');
    }

    @isTest static void getAccountBeneficiarioByAssetPodTest(){

        Test.startTest();
        ServicePoint__c pod = [SELECT Id, Key__c FROM ServicePoint__c LIMIT 1];
        Map<String,Object> resultMap = CEP_LC_DedicatedProcessWizard.getAccountBeneficiarioByAssetPod(pod.Key__c);
        System.assert(!resultMap.isEmpty(), 'The resultMap is different of null');

        asset ass =[select id,ServicePoint__c from asset limit 1];
		ass.ServicePoint__c =pod.Id;
        update ass;
        resultMap = CEP_LC_DedicatedProcessWizard.getAccountBeneficiarioByAssetPod(pod.Key__c);
        Test.stopTest();  
    }

    @isTest static void getApproverIdTest(){

        try{
        Test.startTest();    
        Id idResult = CEP_LC_DedicatedProcessWizard.getApproverId();
        Test.stopTest(); 
        System.assert(String.isNotBlank(idResult), 'The method return the ApprovalId');
        }catch(Exception ex){
            System.assertEquals(ex.getMessage(), ex.getMessage(), 'The method return the Exception Error'); 
        }
    }

    @isTest static void retrieveAtecueDescriptionByIdNull(){

        Test.startTest();
        Map<String, Object> resultMap = CEP_LC_DedicatedProcessWizard.retrieveAtecueDescriptionById('');
        Test.stopTest(); 
        System.assert(!resultMap.isEmpty(), 'The method return the Exception'); 
    }

    @isTest static void attecoOppIdTest(){

        String testChannel = 'my channel';
        CEP_CervedCacheConfiguration__mdt cevredConfig = new CEP_CervedCacheConfiguration__mdt();
        cevredConfig.VerificationType__c = 'Prescreening';
        cevredConfig.Channel__c = testChannel;
        cevredConfig.CacheDurationDays__c = 10.0;

        Map<String,Object> testChannelMap = new Map<String,Object>();
        testChannelMap.put('channel', testChannel);
        CEP_UTL_MatrixChannelManagement.channelMap = testChannelMap;

        Opportunity opp = [SELECT Id FROM Opportunity LIMIT 1];
        opp.PrescreeningDate__c = Date.today();   
        opp.PrescreeningStatus__c = 'OK';
        update opp;
        
  
        Opportunity opportunity = TestDataCustomer.opportunity().createOpportunity().build();
		opportunity.RecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CEP_RT_Business').getRecordTypeId();
        opportunity.RequestType__c = 'Offerta B2B'; 
        insert opportunity;  

        CreditCheck__c cch = new CreditCheck__c();
        //cch.Name = 'CrCheck-0000000883'; 
        cch.Opportunity__c = opp.Id;  
        cch.ResultCode__c = 'KO';
        insert cch;
         
        Account acc = [SELECT Id FROM Account LIMIT 1];
        Test.startTest();  
            Object objectResult = CEP_LC_DedicatedProcessWizard.prescreening(acc.Id, opportunity.Id);
        Test.stopTest();    
        System.assertEquals(true, objectResult != null, 'The ResultMap is different of null');
    }
    
        @IsTest
    	static void checkPdrAttivazioneRemiDiretteTest() {
          
        Map<String,String> params = new Map<String, String>{
            'RemiDiretteORinnovo'=>null,
            'accountId'=>[SELECT Id FROM Account LIMIT 1].Id,
            'pod'=>'nullmopu',
            'RemiDiretteORinnovo'=>'RemiDirette'    
        };
        Test.startTest();
        Map<String,Object> results = CEP_LC_DedicatedProcessWizard.checkPdrAttivazioneRemiDirette(params);
        //System.assertEquals(true, results.get('error') == true);
        params = new Map<String, String>{
            'RemiDiretteORinnovo'=>null,
            'accountId'=>[SELECT Id FROM Account LIMIT 1].Id,
            'pod'=>'00886673878903',
            'RemiDiretteORinnovo'=>'RemiDirette'    
        };
            OpportunityServiceItem__c opi =[select id,Opportunity__c from OpportunityServiceItem__c limit 1];
            opi.ServicePointCode__c='00886673878903';
            opi.Process__c ='Attivazione Tecnica';
            update opi;

            Opportunity opp =[select id,RequestType__c from Opportunity where id =: opi.Opportunity__c];
            opp.RequestType__c ='Offerta B2B Remi Diretta';
            update opp;
            
        	results = CEP_LC_DedicatedProcessWizard.checkPdrAttivazioneRemiDirette(params);
            
        Test.stopTest();
    }
    
         @IsTest
    	static void checkPdrAttivazioneRemiDiretteExceptTest() {
          
        Map<String,String> params = new Map<String, String>{
            'RemiDiretteORinnovo'=>null,
            
            'pod'=>null,
            'RemiDiretteORinnovo'=>'RemiDirette'    
        };
        Test.startTest();
        Map<String,Object> results = CEP_LC_DedicatedProcessWizard.checkPdrAttivazioneRemiDirette(params);
        //System.assertEquals(true, results.get('error') == true);
        Test.stopTest();
    }
    
       @IsTest
    	static void ConfrontoProdottiTest() {
            Asset asset = [SELECT Id FROM Asset LIMIT 1]; 
        Opportunity opp = [SELECT Id, Account.Code__c, Account.BusinessType__c, 
                             Account.RecordType.Name, Account.FiscalCode__c, 
                             Account.VATNumber__c, Account.CompanyName__c,
                             Account.FirstName__c, Account.LastName__c, AccountId 
                         FROM Opportunity LIMIT 1];
            quote quo = new quote();
        quo.OpportunityId = opp.Id;
        quo.Name = 'Namename';    
        insert quo;
        Test.startTest();
        Map<String,Object> results = CEP_LC_DedicatedProcessWizard.ConfrontoProdotti(asset.Id,opp.Id);
        System.assertEquals(true, results.get('error') == true);
        Test.stopTest();
    }
    
        @IsTest
    	static void insertOsiAttivazioneTecnicaRemiDiretteTest() {
                    OpportunityServiceItem__c osi = [SELECT Id, Name, Opportunity__c, Process__c, RequestedContractualPowerBeyond__c,
                                                Excise__c, RevenueAgencyRegisteredDate__c, ActDate__c, ExpectedAnnualWithdrawal__c,
                                                RequestedAvailablePower__c, AvailablePower__c, IsPowerBeyond__c,
                                                VoltageLevel__c, ServicePointCode__c, Account__c, ContractType__c
                                            FROM OpportunityServiceItem__c WHERE Process__c =: Constants.getAllConstants().OSI_CAMBIO_PRODOTTO_PROCESS LIMIT 1];
        osi.Process__c = 'CAMBIO PRODOTTO'; 

        update osi;
        Map<String,String> params = new Map<String, String>{
            'RemiDiretteORinnovo'=>null,
            'isCommercialCounterPart'=>'si',
            'pod'=>null,
            'RemiDiretteORinnovo'=>'RemiDirette',
             'OSI'=>JSON.serialize(osi)   
        };
        Test.startTest();
        Map<String,Object> results = CEP_LC_DedicatedProcessWizard.insertOsiAttivazioneTecnicaRemiDirette(params);
        //System.assertEquals(true, results.get('error') == true);
        Test.stopTest();
    }
    
}