+ Start a Discussion
Melanie VOYMANTMelanie VOYMANT 

code coverage 52%

Hi guys :) 

I need your help please :( 

I have a code coverage at 52 % but i don't see how to have more than 75%... Could you help me please ? Thank you !

My apex class : 

public with sharing class VFC01_Etiquette_Amiante {
        public BSDA__c process;
    public Integer addition;
    public VFC01_Etiquette_Amiante() {
        setPdfContent(ApexPages.currentPage().getParameters().get('id').escapeHtml4());
    }
    public VFC01_Etiquette_Amiante(ApexPages.StandardController controller) {
        setPdfContent(controller.getRecord().id);
    }
    public String getCity() {
        String address = process.Chantier__r.Adresse__c;
        String[] splittedAddress = address.split(',');
        if (splittedAddress.size() > 2) {
        return splittedAddress.get(1);}
    return '';
    }
    public void setPdfContent(String id) {
        List<BSDA__c> processes = [
            SELECT Id, Name, Chantier__r.Adresse__c
            FROM BSDA__c
            WHERE Id = :id
        ];
        if (!processes.isEmpty()) {
            process = processes.get(0);
            addition = 3;
        }
        Apexpages.currentPage().getHeaders().put( 'content-disposition', 'Attachment; filename=PT_' + process.Name + '.pdf');
    }
}

My Test class : 

@isTest
private class VFC01_Etiquette_AmianteTest {
    @TestSetup
    static void makeData() {
        FactureTestUtils.makeData();
    }
    @isTest
    private static void testVF01PageisOk() {
        PAD.ApexForcedBypass.add('AP001');
        chantier__c chantier = [SELECT Id, Name, Agence_codee__c, Adresse__c FROM chantier__c LIMIT 1];
        BSDA__c bsda = new BSDA__c();
        bsda.Chantier__c = chantier.Id;
        bsda.Agence__c = chantier.Agence_codee__c;
        bsda.Retour_client__c = Datetime.now().date();
        insert bsda;

        Test.startTest();
        ApexPages.StandardController sc = new ApexPages.StandardController(bsda);
        VFC01_Etiquette_Amiante vfpvCtrl = new VFC01_Etiquette_Amiante(sc);
        
        PageReference pageRef = Page.VF01_Etiquette_Amiante;
        pageRef.getParameters().put('id', String.valueOf(bsda.Id));
        pageRef.getParameters().put('isFinal', 'true');
        Test.setCurrentPage(pageRef);
        Test.stopTest();
    }
}