Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
6.6 kB
1
Indexable
Never
@isTest
public class NTT_PerfezionamentoCommAndVasCntTst {
    /*@isTest public static void perfezionamentoCommAndVasCntTest(){

        
        PageReference pageRef = Page.NTT_Wind3Touchpoint;
        Test.setCurrentPage(pageRef);
        ApexPages.currentPage().getParameters().put('tp', 'yyyy');
        thecontroller controller = new thecontroller();
        NTT_PerfezionamentoCommAndVasCnt pcavc = new NTT_PerfezionamentoCommAndVasCnt();   
        pcavc.showPopup();
        pcavc.closePopup();
        pcavc.step2();
        pcavc.step3();
        pcavc.step4();
        pcavc.confirmDownloadCommodity();
        pcavc.confirmDownloadVas();
        
    }*/

    @TestSetup
    static void testSetup(){

        //Setup Phase Manager
        wrts_prcgvr.InstallIntegration.install();
        insert TestDataCustomer.createPhaseManagerSettingCase();
		insert TestDataCustomer.createPhaseManagerSettingFileMetadata();
        insert TestDataCustomer.createPhaseManagerSettingIntegrationCase();
        insert TestDataCustomer.createPhaseManagerSettingOpportunity();



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

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

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


        Opportunity opportunity = TestDataCustomer.opportunity().build();
        opportunity.Name ='test';
        opportunity.CloseDate = System.today();
        opportunity.AccountId = acc.Id;
        opportunity.Contact__c = contact.Id;
        opportunity.Phase__c = 'DETAILS';
        opportunity.StageName = 'Attesa Ripensamento';
        opportunity.RecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CEP_RT_PDC').getRecordTypeId();
        insert opportunity;


        String process = 'Attivazione Wind3';
		String type = 'Perfezionamento Digitale';
        Map<String,List<String>> inputParams = new Map<String,List<String>>();
        List<String> l = new List<String>();
        l.add(type);
        inputParams.put(opportunity.Id, l);
        CEP_SRV_TouchPoint touchPointSrv = CEP_SRV_TouchPoint.getInstance();
        Map<String, List<String>> ret = touchPointSrv.startTouchPoint(process, inputParams);
    }

    @isTest 
    public static void testStep1() {
        PageReference myVfPage = Page.NTT_Wind3Touchpoint;
        Test.setCurrentPage(myVfPage);

        Opportunity opp = [SELECT Id FROM Opportunity limit 1];
        OpportunityServiceItem__c osi = TestDataCustomer.opportunityServiceItem().createOpportunityServiceItem().setOpportunity(opp.Id).build();
        osi.RecordTypeId = Schema.SObjectType.OpportunityServiceItem__c.getRecordTypeInfosByDeveloperName().get('Electric').getRecordTypeId();
        insert osi;

        FileMetadata__c fm = [select id,Link__c,Opportunity__c from FileMetadata__c limit 1];
        System.debug('FileMetadata :'+json.serialize(fm));
        fm.Opportunity__c = opp.Id;
        update fm; 
        Test.startTest();
        ApexPages.currentPage().getParameters().put('tp',fm.link__c.split('tp=')[1]);
        NTT_PerfezionamentoCommAndVasCnt controller = new NTT_PerfezionamentoCommAndVasCnt();
        Test.stopTest();
    }

    @isTest 
    public static void step2 (){
        PageReference myVfPage = Page.NTT_Wind3Touchpoint;
        Test.setCurrentPage(myVfPage);
        FileMetadata__c fm = [select id,Link__c from FileMetadata__c limit 1];
        Test.startTest();
        ApexPages.currentPage().getParameters().put('tp',fm.link__c.split('tp=')[1]);

        NTT_PerfezionamentoCommAndVasCnt controller = new NTT_PerfezionamentoCommAndVasCnt();
        controller.step2();
        Test.stopTest();
        System.assertEquals(2, controller.step);
        
    }

    @isTest 
    public static void step3 (){
        PageReference myVfPage = Page.NTT_Wind3Touchpoint;
        Test.setCurrentPage(myVfPage);
        FileMetadata__c fm = [select id,Link__c from FileMetadata__c limit 1];
        Test.startTest();
        ApexPages.currentPage().getParameters().put('tp',fm.link__c.split('tp=')[1]);

        NTT_PerfezionamentoCommAndVasCnt controller = new NTT_PerfezionamentoCommAndVasCnt();
        controller.step3();
        controller.SolicitationConsent = null;
        controller.ThirdPartySolicitationConsent = null;
        controller.LoyaltyConsent = null;
        controller.ProfilingConsent = null;
        Test.stopTest();
        
    }

    @isTest 
    public static void step4 (){
        PageReference myVfPage = Page.NTT_Wind3Touchpoint;
        Test.setCurrentPage(myVfPage);
        FileMetadata__c fm = [select id,Link__c from FileMetadata__c limit 1];
        Test.startTest();
        ApexPages.currentPage().getParameters().put('tp',fm.link__c.split('tp=')[1]);

        NTT_PerfezionamentoCommAndVasCnt controller = new NTT_PerfezionamentoCommAndVasCnt();
        controller.VASConsentAssurance = 'Si';
        controller.VASConsentFranchigia = 'Si';
        controller.step4();
        Test.stopTest();        
    }

    @isTest 
    public static void catchaFailed(){
        PageReference myVfPage = Page.NTT_Wind3Touchpoint;
        Test.setCurrentPage(myVfPage);
        Test.startTest();
        ApexPages.currentPage().getParameters().put('tp','');
        ApexPages.currentPage().getParameters().put('g-recaptcha-response','');
        Test.setMock(HttpCalloutMock.class, new CEP_UTL_HttpCalloutMockImpl('CEP_VFP_PerfezionamentoReCAPTCHAResponse'));
        NTT_PerfezionamentoCommAndVasCnt controller = new NTT_PerfezionamentoCommAndVasCnt();
        PageReference p = controller.submit();
        Test.stopTest();
        
    }

    @isTest 
    public static void confirmDownloadCommodity(){
        PageReference myVfPage = Page.NTT_Wind3Touchpoint;
        Test.setCurrentPage(myVfPage);
        Test.startTest();
        ApexPages.currentPage().getParameters().put('tp','');
        ApexPages.currentPage().getParameters().put('g-recaptcha-response','');
        NTT_PerfezionamentoCommAndVasCnt controller = new NTT_PerfezionamentoCommAndVasCnt();
        controller.confirmDownloadCommodity();
        Test.stopTest();
        
    }


}