Untitled
unknown
plain_text
3 years ago
82 kB
4
Indexable
/** * @description : * @author : ChangeMeIn@UserSettingsUnder.SFDoc * @group : * @last modified on : 12-01-2021 * @last modified by : ChangeMeIn@UserSettingsUnder.SFDoc **/ @isTest public class CEP_UTL_StatePerformanceCheckTst { @isTest public static void getIstance(){ CEP_UTL_StatePerformanceCheck test = CEP_UTL_StatePerformanceCheck.getInstance(); System.assert(test!=null); } @TestSetup static void setup() { wrts_prcgvr.InstallIntegration.install(); insert TestDataCustomer.createPhaseManagerSettingFileMetadata(); insert TestDataCustomer.createPhase('Creato'); insert TestDataCustomer.createPhase('In Archiviazione'); insert TestDataCustomer.createPhaseManagerSettingOpportunity(); List<Account> listAccount = new list<Account>(); CompanyDivision__c companyDivisionOne = TestDataFactory.CompanyDivision().createBulkCompanyDivision(1).build(); companyDivisionOne.Name = 'ACEA ENERGIA'; companyDivisionOne.JointVentureCode__c = 'IT02'; insert companyDivisionOne; Account personAccount = TestDataCustomer.account().physicalPersonAccount().build(); Object phase = TestDataCustomer.createPhaseManagerSettingIntegration(); personAccount.Name = 'BusinessAccount1'; personAccount.VATNumber__c= '1343324'; personAccount.Key__c = 'supply'; personAccount.JointVenture__c = companyDivisionOne.Id; listAccount.add(personAccount); Account businessAccount = TestDataCustomer.Account().businessAccount().build(); businessAccount.FiscalCode__c = 'BNCPLA80A01F205C'; businessAccount.Name = 'BusinessAccount1'; businessAccount.VATNumber__c= '1343324'; businessAccount.Key__c = '1324433'; businessAccount.JointVenture__c = companyDivisionOne.Id; listAccount.add(businessAccount); insert listAccount; CompanyDivision__c companyDivision = TestDataFactory.CompanyDivision().createBulkCompanyDivision(1).build(); companyDivision.JointVentureCode__c = '13434EA'; insert companyDivision; User user = new User(); user.Id = UserInfo.getUserId(); user.CompanyDivisionId__c = companyDivision.Id; user.CompanyDivisionEnforced__c = true; update user; User u = TestDataCustomer.user().admindUser().build(); Supply__c supply = TestDataFactory.supply().createSupplyBuilder().setCompany(companyDivision.Id).build(); supply.Status__c = 'Active'; supply.Key__c = 'supply'; supply.Account__c = listAccount[0].Id; supply.CompanyDivision__c = companyDivision.Id; insert supply; ContractAccount__c contractAccount = TestDataFactory.contractAccount().createContractAccount().setAccount(listAccount[1].Id).build(); insert contractAccount; Contact contact = TestDataFactory.contact().createContact().setAccount(listAccount[1].Id).build(); insert contact; ServiceSite__c serviceSite = TestDataFactory.serviceSite().createServiceSite().build(); insert serviceSite; Asset asset = new Asset(); asset.Name ='test'; asset.Status = 'Allacciato'; asset.AccountId = personAccount.Id; asset.ContactId = contact.Id; insert asset; ServicePoint__c servicePoint = TestDataFactory.servicePoint().createServicePoint().build(); servicePoint.CurrentSupply__c = supply.Id; servicePoint.CurrentAsset__c = asset.Id; servicePoint.Key__c = 'service'; insert servicePoint; BillingProfile__c billingProfile = TestDataFactory.BillingProfileBuilder().createBillingProfile().build(); billingProfile.Account__c=listAccount[0].Id; insert billingProfile; Opportunity oppTest = TestDataCustomer.opportunity().createOpportunity().build(); oppTest.AccountId = listAccount[1].Id; oppTest.Phase__c = 'Confermata'; oppTest.RequestType__c = 'Offerta B2B'; oppTest.RecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CEP_RT_Business').getRecordTypeId(); insert oppTest; Contract contract = TestDataCustomer.Contract().createContract().setCompany(companyDivision.Id).build(); contract.AccountId = listAccount[1].Id; contract.Opportunity__c = oppTest.Id; insert contract; ContestablePod__c contestablePod = new ContestablePod__c(); contestablePod.PodCode__c = 'test'; contestablePod.AvailablePower__c = 2; contestablePod.CounterStatus__c = 'Montato'; insert contestablePod; ContestablePod__c cp = new ContestablePod__c(); cp.PodCode__c = 'test1'; cp.AvailablePower__c = 2; cp.CounterStatus__c = 'Sospeso'; insert cp; } @IsTest public static void statoPrestazionePreValorizzazioneTst(){ CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Account account = [SELECT Id FROM Account LIMIT 1]; account.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_Reseller').getRecordTypeId(); update account; Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; ast.Status = 'Rimosso'; Opportunity opp = [SELECT Id, Account.Name, Account.Segment__c,Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; update ast; List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.SupplyEnergyService__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; ServicePoint__c servicePoint = [SELECT Id, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Name, CurrentAsset__r.SupplyEnergyService__c,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; servicePoint.CurrentAsset__c = ast.Id; update servicePoint; Test.startTest(); try { statePerformance.statoPrestazionePreValorizzazione(servicePoint.CurrentAsset__r.Account.FiscalCode__c, 'Electric', account.Id, opp.Id); } catch (Exception e) { System.assert(true, e.getMessage()); } Test.stopTest(); } @IsTest public static void statoPrestazionePreValorizzazioneEleTst(){ CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Account account = [SELECT Id FROM Account LIMIT 1]; account.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_PhysicalPerson').getRecordTypeId(); update account; Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; ast.Status = 'Rimosso'; Opportunity opp = [SELECT Id, Account.Name, Account.Segment__c,Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; update ast; List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.SupplyEnergyService__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; ServicePoint__c servicePoint = [SELECT Id, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Name, CurrentAsset__r.SupplyEnergyService__c,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; servicePoint.CurrentAsset__c = ast.Id; update servicePoint; Test.startTest(); try { statePerformance.statoPrestazionePreValorizzazione(servicePoint.CurrentAsset__r.Account.FiscalCode__c, 'Electric', account.Id, opp.Id); } catch (Exception e){ System.assert(false, e.getMessage()); } Test.stopTest(); } @IsTest public static void statoPrestazionePreValorizzazioneGasTst(){ CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Account account = [SELECT Id FROM Account LIMIT 1]; account.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_PhysicalPerson').getRecordTypeId(); update account; Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; ast.Status = 'Rimosso'; Opportunity opp = [SELECT Id, Account.Name, Account.Segment__c,Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; update ast; List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.SupplyEnergyService__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; ServicePoint__c servicePoint = [SELECT Id, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Name, CurrentAsset__r.SupplyEnergyService__c,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; servicePoint.CurrentAsset__c = ast.Id; update servicePoint; Test.startTest(); try { statePerformance.statoPrestazionePreValorizzazione(servicePoint.CurrentAsset__r.Account.FiscalCode__c, 'Electric', account.Id, opp.Id); } catch (Exception e){ System.assert(false, e.getMessage()); } Test.stopTest(); } @IsTest public static void statoPrestazionePreValorizzazioneElseTst(){ CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Account account = [SELECT Id FROM Account LIMIT 1]; account.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_PhysicalPerson').getRecordTypeId(); update account; Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; ast.Status = 'Rimosso'; Opportunity opp = [SELECT Id, Account.Name, Account.Segment__c,Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; update ast; List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.SupplyEnergyService__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; ServicePoint__c servicePoint = [SELECT Id, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Name, CurrentAsset__r.SupplyEnergyService__c,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; servicePoint.CurrentAsset__c = ast.Id; update servicePoint; Test.startTest(); try { statePerformance.statoPrestazionePreValorizzazione(servicePoint.CurrentAsset__r.Account.FiscalCode__c, 'Electric', account.Id, opp.Id); } catch (Exception e){ System.assert(false, e.getMessage()); } Test.stopTest(); } @IsTest public static void statoPrestazionePreValorizzazioneExceptionTst(){ CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Test.startTest(); try { statePerformance.statoPrestazionePreValorizzazione('', 'commodity', 'accountId', 'opportunityId'); } catch (Exception e) { System.assert(true, e.getMessage()); } Test.stopTest(); } @IsTest public static void manageGasCommodityRimossoTst(){ Test.startTest(); Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; ast.Status = 'Rimosso'; Opportunity opp = [SELECT Id, Account.Name, Account.Segment__c,Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c, Account.CompanyChannel__c FROM Opportunity LIMIT 1]; update ast; List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.SupplyEnergyService__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Name, CurrentAsset__r.SupplyEnergyService__c,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; servicePoint.CurrentAsset__c = ast.Id; Database.SaveResult result = Database.update(servicePoint); statePerformance.manageGasCommodity(new List<ServicePoint__c>{servicePoint}, 'accountId', servicePoint.CurrentAsset__r.Account.FiscalCode__c, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); //manageGasCommodity(servicePoints,'accountId', , accountVatNumber); Test.stopTest(); System.assertEquals(true, result.isSuccess(), 'The update of the Service Point was realized with success'); } @IsTest public static void manageGasCommodityTst(){ Test.startTest(); Account acc = [SELECT Id FROM Account LIMIT 1]; acc.Name = 'Test Account Name'; acc.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_Reseller').getRecordTypeId(); update acc; Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; ast.Status = 'Attivo'; ast.AccountId = acc.Id; Opportunity opp = [SELECT Id, Account.Name, Account.Segment__c,Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c,Account.CompanyChannel__c FROM Opportunity LIMIT 1]; update ast; List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.SupplyEnergyService__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Name, CurrentAsset__r.SupplyEnergyService__c,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; servicePoint.CurrentAsset__c = ast.Id; Database.SaveResult result = Database.update(servicePoint); statePerformance.manageGasCommodity(new List<ServicePoint__c>{servicePoint}, 'accountId', servicePoint.CurrentAsset__r.Account.FiscalCode__c, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); //manageGasCommodity(servicePoints,'accountId', , accountVatNumber); Test.stopTest(); System.assertEquals(true, result.isSuccess(), 'The update of ServicePoint was realized with success'); } @IsTest public static void manageGasCommodityTst6(){ Test.startTest(); Account acc = [SELECT Id FROM Account LIMIT 1]; acc.Name = 'Test Account Name'; acc.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_Reseller').getRecordTypeId(); update acc; Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; ast.Status = 'Attivo'; ast.AccountId = acc.Id; Opportunity opp = [SELECT Id, Account.Name, Account.Segment__c,Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c, Account.CompanyChannel__c FROM Opportunity LIMIT 1]; update ast; List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.SupplyEnergyService__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Name, CurrentAsset__r.SupplyEnergyService__c,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; servicePoint.CurrentAsset__c = ast.Id; Database.SaveResult result = Database.update(servicePoint); statePerformance.manageGasCommodity(new List<ServicePoint__c>{servicePoint}, 'accountId', servicePoint.CurrentAsset__r.Account.FiscalCode__c, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); //manageGasCommodity(servicePoints,'accountId', , accountVatNumber); Test.stopTest(); System.assertEquals(true, result.isSuccess(), 'The update of servicePoint was realized with success'); } @IsTest public static void manageGasCommodityTstMassMarket(){ Test.startTest(); Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; ast.Status = 'Attivo'; List<Account> listAccount = new List<Account>(); Opportunity opp = [SELECT Id, Account.Name, Account.Segment__c,Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c, Account.CompanyChannel__c FROM Opportunity LIMIT 1]; Account businessAccount = TestDataCustomer.Account().physicalPersonAccount().build(); businessAccount.Segment__c = 'Mass Market'; businessAccount.VATNumber__c= '1343324'; businessAccount.Key__c = '1324433'; listAccount.add(businessAccount); insert listAccount; ast.AccountId = listAccount[0].Id; update ast; List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.SupplyEnergyService__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Name, CurrentAsset__r.SupplyEnergyService__c,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; servicePoint.CurrentAsset__c = ast.Id; update servicePoint; statePerformance.manageGasCommodity(new List<ServicePoint__c>{servicePoint}, 'accountId', servicePoint.CurrentAsset__r.Account.FiscalCode__c, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); //manageGasCommodity(servicePoints,'accountId', , accountVatNumber); Test.stopTest(); System.assert(servicePoint != null, 'The update of servicePoint was realized with success'); } @IsTest public static void manageGasCommodityTst3(){ Test.startTest(); Account acc = [SELECT Id FROM Account LIMIT 1]; acc.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_Reseller').getRecordTypeId(); update acc; Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; ast.Status = 'Attivo'; ast.AccountId = acc.Id; List<Account> listAccount = new List<Account>(); Opportunity opp = [SELECT Id, Account.Name, Account.Segment__c,Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c, Account.CompanyChannel__c FROM Opportunity LIMIT 1]; opp.AccountId = acc.Id; update opp; Account businessAccount = TestDataCustomer.Account().physicalPersonAccount().build(); businessAccount.Segment__c = 'Mass Market'; businessAccount.Name = 'Test Business name'; businessAccount.VATNumber__c= '1343324'; businessAccount.Key__c = '1324433'; listAccount.add(businessAccount); insert listAccount; ast.AccountId = listAccount[0].Id; update ast; List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.SupplyEnergyService__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Name, CurrentAsset__r.SupplyEnergyService__c,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; servicePoint.CurrentAsset__c = ast.Id; update servicePoint; statePerformance.manageGasCommodity(new List<ServicePoint__c>{servicePoint}, 'accountId', servicePoint.CurrentAsset__r.Account.FiscalCode__c, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); //manageGasCommodity(servicePoints,'accountId', , accountVatNumber); Test.stopTest(); System.assert(servicePoint != null, 'The currentAsset is updated'); } @IsTest public static void manageGasCommodityTst5(){ Test.startTest(); Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; ast.Status = 'Attivo'; List<Account> listAccount = new List<Account>(); Opportunity opp = [SELECT Id, Account.Name, Account.Segment__c,Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c, Account.CompanyChannel__c FROM Opportunity LIMIT 1]; Account businessAccount = TestDataCustomer.Account().physicalPersonAccount().build(); businessAccount.Segment__c = 'Mass Market'; businessAccount.VATNumber__c= '1343324'; businessAccount.Key__c = '1324433'; listAccount.add(businessAccount); insert listAccount; ast.AccountId = listAccount[0].Id; update ast; List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.SupplyEnergyService__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Name, CurrentAsset__r.SupplyEnergyService__c,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; servicePoint.CurrentAsset__c = ast.Id; update servicePoint; statePerformance.manageGasCommodity(new List<ServicePoint__c>{servicePoint}, 'accountId', servicePoint.CurrentAsset__r.Account.FiscalCode__c, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); //manageGasCommodity(servicePoints,'accountId', , accountVatNumber); Test.stopTest(); System.assertEquals('Mass Market', businessAccount.Segment__c, 'The Segment is equals Mass Market'); } @IsTest public static void manageGasCommodityTstSPSize(){ Test.startTest(); List<ServicePoint__c> sp =[SELECT Id,CurrentAsset__r.Account.JointVenture__r.Name,CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Name, CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.SupplyEnergyService__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c,CurrentAsset__r.Account.CompanyChannel__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Opportunity opp = [SELECT Id, Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c,Account.CompanyChannel__c, CompanyDivision__r.Name FROM Opportunity LIMIT 1]; ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.SupplyEnergyService__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c,CurrentAsset__r.Account.CompanyChannel__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageGasCommodity(sp, 'accountId', servicePoint.CurrentAsset__r.Account.FiscalCode__c, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); //manageGasCommodity(servicePoints,'accountId', , accountVatNumber); Test.stopTest(); System.assert(servicePoint != null, 'The ServicePoint is different of null'); } @IsTest public static void manageGasCommodityKoServicePoitTst(){ Test.startTest(); List<ServicePoint__c> sp = new List<ServicePoint__c>(); CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Opportunity opp = [SELECT Id, Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageGasCommodity(sp, 'accountId', servicePoint.CurrentAsset__r.Account.FiscalCode__c, servicePoint.CurrentAsset__r.Account.VATNumber__c,opp.Id); Test.stopTest(); System.assertEquals(true, servicePoint != null, 'The servicePoint is different of null'); } @IsTest public static void manageEleCommodity(){ Test.startTest(); Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; ast.Status = 'Attivo'; update ast; List<ServicePoint__c> sp =[SELECT Id,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Id, CurrentAsset__r.Account.FiscalCode__c,CurrentAsset__r.Account.CompanyChannel__c, CurrentAsset__r.Status FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Opportunity opp = [SELECT Id, Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.Name, CurrentAsset__r.Account.JointVenture__c, CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c,CurrentAsset__r.Account.CompanyChannel__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; try { statePerformance.manageEleCommodity(sp,'service',servicePoint.CurrentAsset__r.Account.FiscalCode__c,servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); } catch(DmlException e) { System.debug('Aldo: ' + e.getMessage()); } Test.stopTest(); System.assertEquals(true, servicePoint != null, 'The service point is different of null'); } @IsTest public static void manageEleCommodity2(){ Test.startTest(); Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; List<Account> listAccount = new List<Account>(); Account businessAccount = TestDataCustomer.Account().physicalPersonAccount().build(); businessAccount.Segment__c = 'Mass Market'; businessAccount.VATNumber__c= '1343324'; businessAccount.Key__c = '1324433'; businessAccount.Type = 'Organizzazione'; listAccount.add(businessAccount); insert listAccount; ast.AccountId = listAccount[0].Id; ast.Status = 'Attivo'; update ast; List<ServicePoint__c> sp =[SELECT Id,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Id, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Status, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Opportunity opp = [SELECT Id, Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c, Account.CompanyChannel__c FROM Opportunity LIMIT 1]; ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.Name, CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; try { statePerformance.manageEleCommodity(sp,'service',servicePoint.CurrentAsset__r.Account.FiscalCode__c,servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); } catch(DmlException e) { System.debug('Aldo: ' + e.getMessage()); } Test.stopTest(); System.assertEquals(true, servicePoint != null, 'The Service Point is different of null'); } @IsTest public static void manageEleCommodity7(){ Test.startTest(); Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; List<Account> listAccount = new List<Account>(); Account businessAccount = TestDataCustomer.Account().physicalPersonAccount().build(); businessAccount.Segment__c = 'Mass Market'; businessAccount.VATNumber__c= '1343324'; businessAccount.Key__c = '1324433'; businessAccount.Type = 'Organizzazione'; CompanyDivision__c compDiv = TestDataCustomer.CompanyDivision().createCompanyDivision().build(); compDiv.JointVentureCode__c = 'IT0U654'; insert compDiv; businessAccount.JointVenture__c = compDiv.Id; listAccount.add(businessAccount); insert listAccount; ast.AccountId = listAccount[0].Id; ast.Status = 'Sospeso'; update ast; List<ServicePoint__c> sp =[SELECT Id,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Id, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Status, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Opportunity opp = [SELECT Id, Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c, Account.CompanyChannel__c FROM Opportunity LIMIT 1]; ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.Name, CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId,CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; try { statePerformance.manageEleCommodity(sp,'service',servicePoint.CurrentAsset__r.Account.FiscalCode__c,servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); } catch(DmlException e) { System.debug('Aldo: ' + e.getMessage()); } Test.stopTest(); System.assertEquals(true, servicePoint != null, 'The Service Point is different of null'); } @IsTest public static void manageEleCommodity8(){ Test.startTest(); Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; ast.Status = 'Attivo'; update ast; List<Account> listAccount = new List<Account>(); Account businessAccount = TestDataCustomer.Account().physicalPersonAccount().build(); businessAccount.Segment__c = 'Mass Market'; businessAccount.VATNumber__c= '1343324'; businessAccount.Key__c = '1324433'; businessAccount.Type = 'Organizzazione'; CompanyDivision__c compDiv = TestDataCustomer.CompanyDivision().createCompanyDivision().build(); compDiv.JointVentureCode__c = 'IT0U654'; insert compDiv; businessAccount.JointVenture__c = compDiv.Id; listAccount.add(businessAccount); insert listAccount; ast.AccountId = listAccount[0].Id; ast.Status = 'Sospeso'; update ast; List<ServicePoint__c> sp =[SELECT Id,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Id, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Status, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Opportunity opp = [SELECT Id, Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c, Account.CompanyChannel__c FROM Opportunity LIMIT 1]; ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.Name, CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; try { statePerformance.manageEleCommodity(sp,'service',servicePoint.CurrentAsset__r.Account.FiscalCode__c,servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); } catch(DmlException e) { System.debug('Aldo: ' + e.getMessage()); } Test.stopTest(); System.assertEquals(true, servicePoint != null, 'The Service Point is different of null'); } @IsTest public static void manageEleCommodity3(){ Test.startTest(); Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; List<Account> listAccount = new List<Account>(); Account businessAccount = TestDataCustomer.Account().physicalPersonAccount().build(); businessAccount.Segment__c = 'Reseller'; businessAccount.VATNumber__c= '1343324'; businessAccount.Key__c = '1324433'; businessAccount.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_Reseller').getRecordTypeId(); businessAccount.Type = 'Organizzazione'; CompanyDivision__c compDiv = TestDataCustomer.CompanyDivision().createCompanyDivision().build(); compDiv.JointVentureCode__c = 'IT0U654'; insert compDiv; businessAccount.JointVenture__c = compDiv.Id; listAccount.add(businessAccount); insert listAccount; ast.AccountId = listAccount[0].Id; ast.Status = 'Sospeso'; update ast; List<ServicePoint__c> sp =[SELECT Id,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Id, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Status, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Opportunity opp = [SELECT Id, Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c, Account.CompanyChannel__c FROM Opportunity LIMIT 1]; ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.Name, CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId, CurrentAsset__r.Account.CompanyChannel__c FROM ServicePoint__c LIMIT 1]; try { statePerformance.manageEleCommodity(sp,'service',servicePoint.CurrentAsset__r.Account.FiscalCode__c,servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); } catch(DmlException e) { System.debug('Aldo: ' + e.getMessage()); } Test.stopTest(); System.assertEquals(true, servicePoint != null, 'The Service Point is different of null'); } @IsTest public static void manageGasCommodityNewTst4(){ Test.startTest(); Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; List<Account> listAccount = new List<Account>(); Account businessAccount = TestDataCustomer.Account().physicalPersonAccount().build(); businessAccount.Segment__c = 'Mass Market'; businessAccount.VATNumber__c= '134332499'; businessAccount.Key__c = '132443399'; businessAccount.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_PhysicalPerson').getRecordTypeId(); businessAccount.Type = 'Organizzazione'; CompanyDivision__c compDiv = TestDataCustomer.CompanyDivision().createCompanyDivision().build(); compDiv.JointVentureCode__c = 'IT0U654'; insert compDiv; businessAccount.JointVenture__c = compDiv.Id; listAccount.add(businessAccount); Account businessAccount2 = new Account(); businessAccount2.Name = 'Paola'; businessAccount2.FirstName__c = 'Paola'; businessAccount2.LastName__c = 'Bianchi'; businessAccount2.Active__c ='N'; businessAccount2.CompanyName__c = 'compSrls'; businessAccount2.FiscalCode__c ='BNCPLA80A01F205K'; businessAccount2.ResidentialCity__c = 'Milano'; businessAccount2.ResidentialIstatCode__c = '09555'; businessAccount2.ResidentialProvince__c = 'Milano'; businessAccount2.ResidentialStreetNumber__c = '10'; businessAccount2.ResidentialStreetType__c = 'Via'; businessAccount2.Segment__c = 'Mass Market'; businessAccount2.VATNumber__c ='0318343058'; businessAccount2.Phone = '+333154665328'; businessAccount2.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_PhysicalPerson').getRecordTypeId(); CompanyDivision__c compDiv2 = TestDataCustomer.CompanyDivision().createCompanyDivision().build(); compDiv2.JointVentureCode__c = 'IS0U659'; insert compDiv2; businessAccount2.JointVenture__c = compDiv2.Id; listAccount.add(businessAccount2); insert listAccount; ast.AccountId = listAccount[1].Id; ast.Status = 'Sospeso'; update ast; Opportunity opp = [SELECT Id, Account.Name, Account.Segment__c,Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; opp.RecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CEP_RT_MassMarket').getRecordTypeId(); opp.AccountId = listAccount[0].Id; update opp; List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.SupplyEnergyService__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Name, CurrentAsset__r.SupplyEnergyService__c,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; servicePoint.CurrentAsset__c = ast.Id; update servicePoint; Opportunity opp2 = [SELECT Id, Account.Name, Account.Segment__c,Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; // statePerformance.manageGasCommodity(new List<ServicePoint__c>{servicePoint}, 'service', 'Organizzazione', servicePoint.CurrentAsset__r.Account.VATNumber__c, opp2.Id); statePerformance.statoPrestazionePreValorizzazione(servicePoint.CurrentAsset__r.Account.FiscalCode__c, 'Gas', listAccount[0].Id, opp.Id); Test.stopTest(); System.assertEquals(true, servicePoint != null, 'The service point is different of null'); } @IsTest public static void manageGasCommodityTst4(){ Test.startTest(); Asset ast = [SELECT Id, Status FROM Asset LIMIT 1]; List<Account> listAccount = new List<Account>(); Account businessAccount = TestDataCustomer.Account().physicalPersonAccount().build(); businessAccount.Segment__c = 'Mass Market'; businessAccount.VATNumber__c= '134332499'; businessAccount.Key__c = '132443399'; businessAccount.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_PhysicalPerson').getRecordTypeId(); businessAccount.Type = 'Organizzazione'; CompanyDivision__c compDiv = TestDataCustomer.CompanyDivision().createCompanyDivision().build(); compDiv.JointVentureCode__c = 'IT0U654'; insert compDiv; businessAccount.JointVenture__c = compDiv.Id; listAccount.add(businessAccount); Account businessAccount2 = new Account(); businessAccount2.Name = 'Paola'; businessAccount2.FirstName__c = 'Paola'; businessAccount2.LastName__c = 'Bianchi'; businessAccount2.Active__c ='N'; businessAccount2.CompanyName__c = 'compSrls'; businessAccount2.FiscalCode__c ='BNCPLA80A01F205K'; businessAccount2.ResidentialCity__c = 'Milano'; businessAccount2.ResidentialIstatCode__c = '09555'; businessAccount2.ResidentialProvince__c = 'Milano'; businessAccount2.ResidentialStreetNumber__c = '10'; businessAccount2.ResidentialStreetType__c = 'Via'; businessAccount2.Segment__c = 'Mass Market'; businessAccount2.VATNumber__c ='0318343058'; businessAccount2.Phone = '+333154665328'; businessAccount2.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_PhysicalPerson').getRecordTypeId(); CompanyDivision__c compDiv2 = TestDataCustomer.CompanyDivision().createCompanyDivision().build(); compDiv2.JointVentureCode__c = 'IS0U659'; insert compDiv2; businessAccount2.JointVenture__c = compDiv2.Id; listAccount.add(businessAccount2); insert listAccount; ast.AccountId = listAccount[1].Id; ast.Status = 'Sospeso'; update ast; Opportunity opp = [SELECT Id, Account.Name, Account.Segment__c,Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; opp.RecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CEP_RT_MassMarket').getRecordTypeId(); opp.AccountId = listAccount[0].Id; update opp; List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.SupplyEnergyService__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Segment__c,CurrentAsset__r.Account.Name, CurrentAsset__r.SupplyEnergyService__c,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; servicePoint.CurrentAsset__c = ast.Id; update servicePoint; Opportunity opp2 = [SELECT Id, Account.Name, Account.Segment__c,Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; // statePerformance.manageGasCommodity(new List<ServicePoint__c>{servicePoint}, 'service', 'Organizzazione', servicePoint.CurrentAsset__r.Account.VATNumber__c, opp2.Id); statePerformance.statoPrestazionePreValorizzazione(servicePoint.CurrentAsset__r.Account.FiscalCode__c, 'Gas', listAccount[0].Id, opp.Id); Test.stopTest(); System.assertEquals(true, opp2 != null, 'The Opportunity is different of null'); } @IsTest public static void manageEleCommodityAttivoTest(){ Test.startTest(); List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.CompanyChannel__c, CurrentAsset__r.Account.JointVenture__c ,CurrentAsset__r.Account.Name, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Status, CurrentAsset__r.Account.Id, CurrentAsset__r.Account.FiscalCode__c FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Opportunity opp = [SELECT Id, Account.CompanyChannel__c,Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; ServicePoint__c servicePoint = [SELECT Id, CurrentAsset__r.Account.CompanyChannel__c, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageEleCommodity(sp,'service',servicePoint.CurrentAsset__r.Account.FiscalCode__c,servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c,opp.Id); Test.stopTest(); System.assertEquals(true, opp != null, 'The Opportunity is retrieved'); } @IsTest public static void manageEleCommodityAttivoNullTest(){ Test.startTest(); Account acc = [SELECT Id,FiscalCode__c FROM Account LIMIT 1]; Asset ast = [SELECT Id FROM Asset LIMIT 1]; ast.AccountId = acc.Id; ast.Status = 'Rimosso'; update ast; List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.CompanyChannel__c, CurrentAsset__r.Account.Name, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Status, CurrentAsset__r.Account.Id, CurrentAsset__r.Account.FiscalCode__c FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Opportunity opp = [SELECT Id, Account.CompanyChannel__c,Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageEleCommodity(sp,'service',acc.FiscalCode__c,null, null,opp.Id); Test.stopTest(); System.assertEquals(true, ast != null, 'The Asset is updated with success'); } @IsTest public static void manageEleCommodityAttivoResellerTest(){ Test.startTest(); Account acc = [SELECT Id FROM Account LIMIT 1]; acc.Name = 'Test name'; acc.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_Reseller').getRecordTypeId(); update acc; Asset ast = [SELECT Id FROM Asset LIMIT 1]; ast.AccountId = acc.Id; ast.Status = 'Attivo'; update ast; List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Status, CurrentAsset__r.Account.Id, CurrentAsset__r.Account.FiscalCode__c FROM ServicePoint__c LIMIT 1]; sp.get(0).Account__c = acc.Id; sp.get(0).CurrentAsset__c = ast.Id; update sp; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Opportunity opp = [SELECT Id, Account.CompanyChannel__c, Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; opp.AccountId = acc.Id; Database.SaveResult result = Database.update(opp); ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageEleCommodity(sp,'service',servicePoint.CurrentAsset__r.Account.FiscalCode__c,servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c,opp.Id); Test.stopTest(); System.assertEquals(true, result.isSuccess(), 'The opportunity is updated with success'); } @IsTest public static void manageEleCommodityAttivoReseller2Test(){ Test.startTest(); Account acc = [SELECT Id FROM Account LIMIT 1]; acc.Name = 'Test name 2'; acc.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_Reseller').getRecordTypeId(); update acc; Asset ast = [SELECT Id FROM Asset LIMIT 1]; ast.AccountId = acc.Id; ast.Status = 'Attivo'; update ast; Account businessAccount = TestDataCustomer.Account().physicalPersonAccount().build(); businessAccount.Segment__c = 'Reseller'; businessAccount.VATNumber__c= '1343324'; businessAccount.Key__c = '1324433'; businessAccount.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('CEP_RT_Reseller').getRecordTypeId(); businessAccount.Type = 'Organizzazione'; insert businessAccount; List<ServicePoint__c> sp =[SELECT Id, CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Status, CurrentAsset__r.Account.Id, CurrentAsset__r.Account.FiscalCode__c FROM ServicePoint__c LIMIT 1]; sp.get(0).Account__c = acc.Id; sp.get(0).CurrentAsset__c = ast.Id; update sp; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Opportunity opp = [SELECT Id, Account.CompanyChannel__c,Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; opp.AccountId = businessAccount.Id; update opp; ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageEleCommodity(sp,'service',servicePoint.CurrentAsset__r.Account.FiscalCode__c,servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c,opp.Id); Test.stopTest(); System.assertEquals(true, servicePoint != null, 'The Service Point is different of null'); } @IsTest public static void manageEleCommodityContestablePodTest(){ Test.startTest(); Account acc = [SELECT id, Name, FiscalCode__c FROM Account LIMIT 1]; List<ServicePoint__c> sp =[SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Status, CurrentAsset__r.Account.Id, CurrentAsset__r.Account.FiscalCode__c FROM ServicePoint__c LIMIT 1]; ContestablePod__c cp = [SELECT Id,CounterStatus__c, PodCode__c FROM ContestablePod__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Opportunity opp = [SELECT Id, Account.Name,Account.CompanyChannel__c, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageEleCommodity(sp, cp.PodCode__c, acc.FiscalCode__c, servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); Test.stopTest(); System.assertEquals(true, servicePoint != null, 'The ServicePoint is different of null'); } @IsTest public static void manageEleCommodityContestablePodNullTest(){ Test.startTest(); Account acc = [SELECT id, Name, FiscalCode__c FROM Account LIMIT 1]; List<ServicePoint__c> sp =[SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Status, CurrentAsset__r.Account.Id, CurrentAsset__r.Account.FiscalCode__c FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Opportunity opp = [SELECT Id, Account.CompanyChannel__c,Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageEleCommodity(sp, null, acc.FiscalCode__c, servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); Test.stopTest(); System.assertEquals(true, acc != null, 'The Account is retrieved'); } @IsTest public static void manageEleCommodityKoStatePerfomanceTest(){ Test.startTest(); Account acc = [SELECT id, FiscalCode__c FROM Account LIMIT 1]; Opportunity opp = [SELECT Id, Account.CompanyChannel__c,Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; List<ServicePoint__c> sp =[SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.Account.JointVenture__r.Name,CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Status, CurrentAsset__r.Account.Id, CurrentAsset__r.Account.FiscalCode__c FROM ServicePoint__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageEleCommodity(sp, 'NO', acc.FiscalCode__c, servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); Test.stopTest(); System.assertEquals(true, !sp.isEmpty(), 'The Service Point is different of null'); } @IsTest public static void manageEleComodityContestablePodOKTest(){ Test.startTest(); Account acc = [SELECT id, Name, FiscalCode__c FROM Account LIMIT 1]; Opportunity opp = [SELECT Id, Account.CompanyChannel__c,Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; List<ServicePoint__c> sp = new List<ServicePoint__c>(); ContestablePod__c cp = [SELECT Id,CounterStatus__c, PodCode__c FROM ContestablePod__c LIMIT 1]; cp.PodCode__c = 'asjnasjcan'; cp.CounterStatus__c= 'asjfnaj'; update cp; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageEleCommodity(sp, 'test', 'accountId', servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); Test.stopTest(); System.assertEquals(true, servicePoint != null, 'The ServicePoint is updated'); } @IsTest public static void manageEleCommodityStatePoerformanceKOInContestablePodTest(){ Test.startTest(); Opportunity opp = [SELECT Id, Account.CompanyChannel__c,Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; Account acc = [SELECT Id FROM Account LIMIT 1]; List<ServicePoint__c> sp = new List<ServicePoint__c>(); ContestablePod__c cp = [SELECT Id,CounterStatus__c FROM ContestablePod__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageEleCommodity(sp, 'test1', 'accountId', servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); Test.stopTest(); System.assertEquals(true, sp.isEmpty(), 'The ServicePoint is different of null'); } @IsTest public static void manageEleCommodityStatePoerformanceKOInAccountId(){ Test.startTest(); Opportunity opp = [SELECT Id, Account.CompanyChannel__c, Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; Account acc = [SELECT Id,FiscalCode__c FROM Account LIMIT 1]; acc.Type = 'Organizzazione'; Asset ast = [SELECT Id FROM Asset LIMIT 1]; ast.Status = 'Cessato'; ast.AccountId = acc.Id; update ast; String query = 'SELECT CurrentAsset__r.Account.CompanyChannel__c, CurrentAsset__r.Account.Name, CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Status, CurrentAsset__r.AccountId, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, '+CEP_UTL_SObject.getAllFieldsForObject('ServicePoint__c')+' '; query+= 'FROM ServicePoint__c LIMIT 1'; ServicePoint__c servicePoint2 = Database.query(query); servicePoint2.CurrentAsset__c = ast.Id; update servicePoint2; List<ServicePoint__c> sp = new List<ServicePoint__c>{servicePoint2}; ContestablePod__c contestablePod = new ContestablePod__c(); contestablePod.PodCode__c = 'IT002E2115551A'; contestablePod.AvailablePower__c = 2; contestablePod.CounterStatus__c = 'Montato'; contestablePod.Usage__c = 'Altri usi'; insert contestablePod; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageEleCommodity(sp, contestablePod.PodCode__c, acc.FiscalCode__c, 'N/A', servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); Test.stopTest(); System.assertEquals(true, servicePoint != null, 'The ServicePoint is different of null'); } @IsTest public static void manageEleCommodityStatePoerformanceKOIn(){ Test.startTest(); Opportunity opp = [SELECT Id, Account.CompanyChannel__c,Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; Account acc = [SELECT Id,FiscalCode__c FROM Account LIMIT 1]; acc.Type = 'Organizzazione'; Asset ast = [SELECT Id FROM Asset LIMIT 1]; ast.Status = 'Attivo'; ast.AccountId = acc.Id; update ast; String query = 'SELECT CurrentAsset__r.Account.CompanyChannel__c, CurrentAsset__r.Account.Name, CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Status, CurrentAsset__r.AccountId, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, '+CEP_UTL_SObject.getAllFieldsForObject('ServicePoint__c')+' '; query+= 'FROM ServicePoint__c LIMIT 1'; ServicePoint__c servicePoint2 = Database.query(query); servicePoint2.CurrentAsset__c = ast.Id; update servicePoint2; List<ServicePoint__c> sp = new List<ServicePoint__c>{servicePoint2}; ContestablePod__c contestablePod = [SELECT Id, PodCode__c FROM ContestablePod__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageEleCommodity(sp, contestablePod.PodCode__c, acc.FiscalCode__c, servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); Test.stopTest(); System.assertEquals(true, contestablePod != null, 'the ContestablePod__c is different of null'); } @IsTest public static void manageEleCommodityStatePoerformanceKOInNull(){ Test.startTest(); Account acc = [SELECT Id, FiscalCode__c FROM Account LIMIT 1]; acc.Segment__c = 'Mass Market'; acc.Type = 'Organizzazione'; update acc; Opportunity opp = [SELECT Id, Account.CompanyChannel__c,Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; Asset ast = [SELECT Id FROM Asset LIMIT 1]; String query = 'SELECT CurrentAsset__r.Account.CompanyChannel__c, CurrentAsset__r.Account.Name, CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Status, CurrentAsset__r.AccountId, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, '+CEP_UTL_SObject.getAllFieldsForObject('ServicePoint__c')+' '; query+= 'FROM ServicePoint__c LIMIT 1'; ServicePoint__c servicePoint2 = Database.query(query); servicePoint2.CurrentAsset__c = ast.Id; update servicePoint2; List<ServicePoint__c> sp = new List<ServicePoint__c>{servicePoint2}; ContestablePod__c contestablePod = [SELECT Id, PodCode__c FROM ContestablePod__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageEleCommodity(sp, 'test1', acc.FiscalCode__c, servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); Test.stopTest(); System.assertEquals(true, servicePoint != null, 'The Service Point is different of null'); } @IsTest public static void manageEleCommodityStatePoerformanceKOInNullAccountId(){ Test.startTest(); Account acc = [SELECT id, FiscalCode__c FROM Account LIMIT 1]; Opportunity opp = [SELECT Id, Account.CompanyChannel__c,Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; Asset ast = [SELECT Id FROM Asset LIMIT 1]; String query = 'SELECT CurrentAsset__r.Account.CompanyChannel__c, CurrentAsset__r.Account.Name, CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Status, CurrentAsset__r.AccountId, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Account.RecordType.Name, '+CEP_UTL_SObject.getAllFieldsForObject('ServicePoint__c')+' '; query+= 'FROM ServicePoint__c LIMIT 1'; ServicePoint__c servicePoint2 = Database.query(query); servicePoint2.CurrentAsset__c = ast.Id; update servicePoint2; List<ServicePoint__c> sp = new List<ServicePoint__c>{servicePoint2}; ContestablePod__c contestablePod = [SELECT Id, PodCode__c FROM ContestablePod__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageEleCommodity(sp, 'test1', acc.FiscalCode__c, servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); Test.stopTest(); System.assertEquals(true, servicePoint != null, 'The Service Point is updated with success'); } @IsTest public static void manageEleCommoditypodContendibiliTest(){ Test.startTest(); Opportunity opp = [SELECT Id, Account.CompanyChannel__c,Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; List<ServicePoint__c> sp = new List<ServicePoint__c>(); ContestablePod__c cp = [SELECT Id,CounterStatus__c FROM ContestablePod__c LIMIT 1]; CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c ,CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageEleCommodity(sp, null, 'accountId', servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); Test.stopTest(); System.assertEquals(true, servicePoint != null, 'The Service Point is different of null'); } @IsTest public static void manageEleCommodityNoPointOnContestablePodTest(){ Test.startTest(); Opportunity opp = [SELECT Id, Account.CompanyChannel__c,Account.Name, Account.JointVenture__r.Name, Account.RecordTypeDeveloperName__c FROM Opportunity LIMIT 1]; List<ServicePoint__c> sp = new List<ServicePoint__c>(); ContestablePod__c cp = new ContestablePod__c(); CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); ServicePoint__c servicePoint = [SELECT Id,CurrentAsset__r.Account.CompanyChannel__c,CurrentAsset__r.Account.Name,CurrentAsset__r.Account.JointVenture__r.JointVentureCode__c , CurrentAsset__r.Account.JointVenture__r.Name, CurrentAsset__r.Account.Segment__c, CurrentAsset__r.Account.Type, CurrentAsset__r.Status, CurrentAsset__r.Account.FiscalCode__c, CurrentAsset__r.Account.VATNumber__c, CurrentAsset__r.AccountId FROM ServicePoint__c LIMIT 1]; statePerformance.manageEleCommodity(sp, 'test9', 'accountId', servicePoint.CurrentAsset__r.Account.Type, servicePoint.CurrentAsset__r.Account.VATNumber__c, opp.Id); Test.stopTest(); System.assertEquals(true, servicePoint != null, 'The Service point is different of null'); } @IsTest public static void filterPerformanceValuesForWave1EleTest(){ List<String> prestazioni = new List<String>(); prestazioni.add('Attivazione'); CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Test.startTest(); statePerformance.filterPerformanceValuesForWave1(prestazioni, 'Electric'); Test.stopTest(); System.assertEquals(true, !prestazioni.isEmpty(), 'The prestazioni is equals Attivazione'); } @IsTest public static void filterPerformanceValuesForWave1GasTest(){ List<String> prestazioni = new List<String>(); prestazioni.add('A01 - ATTIVAZIONE NON SOGGETTA ALLA DELIBERA 40/14,A40'); CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Test.startTest(); statePerformance.filterPerformanceValuesForWave1(prestazioni, 'Gas'); Test.stopTest(); System.assertEquals(true, !prestazioni.isEmpty(), 'A01 - ATTIVAZIONE NON SOGGETTA ALLA DELIBERA 40/14,A40'); } /*@IsTest public static void addPrestazioniPermissionSetTest(){ List<String> prestazioni = new List<String>(); Profile profile = [SELECT Id FROM Profile WHERE Name = 'System Administrator' WITH SECURITY_ENFORCED]; User u = [SELECT Id FROM User WHERE ProfileId = :profile.Id WITH SECURITY_ENFORCED].get(0); CEP_UTL_StatePerformanceCheck statePerformance = new CEP_UTL_StatePerformanceCheck(); Test.startTest(); statePerformance.addPrestazioniPermissionSet(prestazioni); Test.stopTest(); } */ }
Editor is loading...