• Raj Chongder
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies

Aura.cmp:::

<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" >
    <aura:attribute name="PicklistField" type="object"/>
   
    <!--force:recordData to update picklist value-->
    <force:recordData aura:id="record"
                      layoutType="FULL"
                      recordId="{!v.recordId}"
                      targetFields="{!v.PicklistField}"
                      mode="EDIT"/>
   
    <lightning:picklistPath aura:id="picklistPath" recordId="{!v.recordId}"
        variant="linear"
        picklistFieldApiName="twod_bm__Inventory_Stage__c">
    </lightning:picklistPath>
</aura:component>

 

Aura.js:

({
    handleSelect : function (component, event, helper) {
        var stepName = event.getParam("detail").value;
        component.set("v.PicklistField.twod_bm__Inventory_Stage__c", stepName);
       
        component.find("record").saveRecord($A.getCallback(function(response) {
            if (response.state === "SUCCESS") {
                $A.get('e.force:refreshView').fire();
            }
        }));
    }
   
})

Apex class:

public with sharing class wod_UploadDocumentController {

 @AuraEnabled//(cacheable=true)
    public static List<string> getDoctype(Id recID){
        List<string> stroptions=new List<string>();
        for( string var : wod_UploadDocumentControllerDataSrvice.getDoctype( recID)){
            stroptions.add(var); 
        }    
       // stroptions.add('Roof Plan'); 
       system.debug(stroptions);

@AuraEnabled//(cacheable=true)
public static List<string> getDoctypePicklist(){
    List<string> stroptions = new List<string>();
    for( string var : wod_UploadDocumentControllerDataSrvice.getDoctypePicklist( )){
        stroptions.add(var); 
    }
   // stroptions.add('Roof Plan'); 
    return stroptions;
}

@AuraEnabled//(cacheable=true)
public static List<string> getExistingDocTypes(Id recID){
    Set<string> stroptions=new Set<string>();
    for( twod_bm__Document__c var : [select Id, twod_bm__Document_Type__c, Name from twod_bm__Document__c where
    twod_bm__Building__r.Id = :recId and twod_bm__Validated__c= true]){
        System.debug(var);
        stroptions.add(var.twod_bm__Document_Type__c); 
    }    
   // stroptions.add('Roof Plan'); 
    return new List<String>(stroptions);
}
            System.debug('lstDoc > '+ lstDoc);
            for(twod_bm__Document__c var: wod_UploadDocumentControllerDataSrvice.FetchGRSDocumentRecord(recID)){
                if(var.twod_bm__Validated__c == false || var.twod_bm__Document_Type__c == null){
                objwP=NEW DataWrapper();
                objwP.strDocId=var.Id;
                objWp.FileURL=var.twod_bm__Document_URL__c;
                objwP.strfileName=var.Name;
                 objwP.selectedType=var.twod_bm__Document_Type__c;
                objwP.IsValidated=var.twod_bm__Validated__c;
                objwP.strUserName=var.CreatedBy.Name;
                datetime dt=var.CreatedDate;
                objwP.strDateTime=''+dt.format('MM/dd/yyyy HH:mm:ss'); 
                
                lstDoc.add(objwP); 
               }
            } 
        }

Those lines in apex class its not covered^

Test class:

@istest
public class wod_UploadDocumentControllerTest {
    static testMethod void fetchassembly() {
        Test.startTest();
        Project__c objProject=WOD_DataFactoryTest.createProject();
        WOD_2__Inventory__c objInvn= WOD_DataFactoryTest.createInventory(objProject.id);
        Assembly_Template__c objTemp= WOD_DataFactoryTest.createAssemblytemp(objInvn.id);
        WOD_2__Warranty_Registration__c objwarranty= WOD_DataFactoryTest.createWarrantyRegistration(objInvn.id);
        Assembly__c objAsem=WOD_DataFactoryTest.createAssembly(objInvn.id);
        twod_bm__Assembly_Detail__c objassdet= WOD_DataFactoryTest.createAssemblydetail(objAsem.id);       
        
        ContentDocumentLink objdoclink= WOD_DataFactoryTest.createContentVersion(objInvn.id);
        // Insert objdoclink;
        Id DocRuleRecordTypeId = Schema.SObjectType.twod_bm__Business_Rule__c.getRecordTypeInfosByDeveloperName().get('Documents_Rules').getRecordTypeId();
        
        twod_bm__Business_Rule__c objBR= WOD_DataFactoryTest.createBusinessRule(objInvn.id,DocRuleRecordTypeId);
        twod_bm__Document__c objdoc= WOD_DataFactoryTest.createdocument(objInvn.id,objProject.id,objdoclink.contentdocumentid ,'SampleTitle');
        insert objdoc;
        Insert objBR;
        list<twod_bm__Document__c> lst=new list<twod_bm__Document__c>();
        twod_bm__Document__c obj=new twod_bm__Document__c();
        obj.name='test';
        lst.add(obj);
        // twod_bm__Assembly_Detail_Template__c objtempdata=WOD_DataFactoryTest.createAssemblydetailtemp(objassdet.id);
        wod_UploadDocumentController.getDoctype(objInvn.id);
        string strid=''+   wod_UploadDocumentController.FetchDocument(objInvn.id);
        wod_UploadDocumentController.saveDocument(lst);
        objdoc.twod_bm__Validated__c=true;
        update objdoc; 
        
        wod_UploadDocumentControllerDataSrvice.foxproDocChecklistFromReOpen = false;
        objInvn.twod_bm__Foxpro_Pull_Test__c = true;
        update objInvn;
        
        objInvn.twod_bm__Override_Doc_Type__c = 'Test, Test';
        update objInvn;
        //System.assertEquals(90, obj.Price__c);
        Test.stopTest();
    }
}

Test class:

/*
 * @description - This class is the test class for WOD_ProjectTriggerHandler,WOD_BusinessRules_ACK_DOC_Helper and WOD_ProjectDataService
 */
@isTest
public with sharing class WOD_ProjectTriggerHandlerTest {
    public WOD_ProjectTriggerHandlerTest() {
    }
    @testSetup
    public static void runTestSetup(){
        Test.startTest();
        WOD_DataFactoryTest.createAckBusinessRule();
        WOD_DataFactoryTest.createDocumentBusinessRule();
        twod_bm__Project__c project =  WOD_DataFactoryTest.createProject();
        project.twod_bm__Project_Status__c = 'Submitted';
        project.twod_bm__Is_Migrated_Data__c = true;
       // update project;
        
        // Adding Strategic Account also
        Account acc = WOD_DataFactoryTest.createAccount();
        acc.twod_bm__Strategic_Account__c = true;
        update acc;
        
        WOD_2__Inventory__c inventory =  WOD_DataFactoryTest.createInventory(project.Id);
        inventory.twod_bm__Inventory_Status__c = 'Pending Review';
        inventory.twod_bm__Guarantee_Issued__c = false;
        inventory.twod_bm__Strategic_Building__c = true;
        inventory.twod_bm__Strategic_AccountName__c = acc.id;
        inventory.twod_bm__Strategic_Price_Available__c = true;
        update inventory;
        
        WOD_2__Inventory__c inv = WOD_DataFactoryTest.createInventory(project.Id);
        inv.twod_bm__Guarantee_Issued__c = true;
        inv.twod_bm__Admin_Review__c = true;
        inv.twod_bm__Specification_Check__c = true;
        inv.twod_bm__Is_Building_Approved__c = true;
        
        update inv;
        
        twod_bm__Inspection__c ins = WOD_DataFactoryTest.createInspection(inv.id);
        ins.twod_bm__Type__c = 'Final Inspection';
        ins.twod_bm__Status__c = 'Pending Inspection';
        ins.twod_bm__Inspection_Rating__c = 'Conditionally accepted with Punchlist';
        update ins;
        
        twod_bm__Customer_Communication__c custComm = new twod_bm__Customer_Communication__c();
        custComm.twod_bm__Building__c = inventory.id;
        custComm.twod_bm__Status__c = 'Awaiting Response';
        //insert custComm;
        
        WOD_2__Warranty_Registration__c objwarranty= WOD_DataFactoryTest.createWarrantyRegistration(inventory.id);
        
        Test.stopTest();
    }
    @IsTest
    static void handlerMethods(){
        test.startTest();
        Account acc = new Account();
        acc.Name = 'Test Property Owner';
       // insert acc;

        twod_bm__Project__c proj = WOD_DataFactoryTest.createProject();
        WOD_2__Inventory__c inv = WOD_DataFactoryTest.createInventory(proj.Id);
        
        WOD_2__Warranty_Registration__c objwarranty= WOD_DataFactoryTest.createWarrantyRegistration(inv.id);
        Assembly__c ass = WOD_DataFactoryTest.createAssembly(inv.Id);
        WOD_DataFactoryTest.createAssemblydetail(ass.Id);

        proj.twod_bm__Property_Owner__c = acc.Id;
        proj.twod_bm__Submitted_Internally__c = true;
        proj.twod_bm__Project_Status__c = 'Submitted';
       // update proj;
        
        proj.twod_bm__General_Contractor__c = acc.Id;
       // update proj;
        WOD_ProjectTriggerHandler.createOpenItems(new List<twod_bm__Project__c>{proj});
        test.stopTest();
    }
    
    @IsTest
    static void handlerMethodsForDelete(){
        test.startTest();
        Account acc = new Account();
        acc.Name = 'Test Property Owner';
        //insert acc;

        twod_bm__Project__c proj = WOD_DataFactoryTest.createProject();
        WOD_2__Inventory__c inv = WOD_DataFactoryTest.createInventory(proj.Id);
        
        WOD_2__Warranty_Registration__c objwarranty= WOD_DataFactoryTest.createWarrantyRegistration(inv.id);
        Assembly__c ass = WOD_DataFactoryTest.createAssembly(inv.Id);
        WOD_DataFactoryTest.createAssemblydetail(ass.Id);
        proj.twod_bm__Property_Owner__c = acc.Id;
        proj.twod_bm__Submitted_Internally__c = true;
        proj.twod_bm__Project_Status__c = 'Submitted';
        //update proj;
        
        proj.twod_bm__General_Contractor__c = acc.Id;
       // update proj;
        delete proj;
        test.stopTest();
    }
}

Test class:

/*
 * @description - This class is the test class for WOD_ProjectTriggerHandler,WOD_BusinessRules_ACK_DOC_Helper and WOD_ProjectDataService
 */
@isTest
public with sharing class WOD_ProjectTriggerHandlerTest {
    public WOD_ProjectTriggerHandlerTest() {
    }
    @testSetup
    public static void runTestSetup(){
        Test.startTest();
        WOD_DataFactoryTest.createAckBusinessRule();
        WOD_DataFactoryTest.createDocumentBusinessRule();
        twod_bm__Project__c project =  WOD_DataFactoryTest.createProject();
        project.twod_bm__Project_Status__c = 'Submitted';
        project.twod_bm__Is_Migrated_Data__c = true;
       // update project;
        
        // Adding Strategic Account also
        Account acc = WOD_DataFactoryTest.createAccount();
        acc.twod_bm__Strategic_Account__c = true;
        update acc;
        
        WOD_2__Inventory__c inventory =  WOD_DataFactoryTest.createInventory(project.Id);
        inventory.twod_bm__Inventory_Status__c = 'Pending Review';
        inventory.twod_bm__Guarantee_Issued__c = false;
        inventory.twod_bm__Strategic_Building__c = true;
        inventory.twod_bm__Strategic_AccountName__c = acc.id;
        inventory.twod_bm__Strategic_Price_Available__c = true;
        update inventory;
        
        WOD_2__Inventory__c inv = WOD_DataFactoryTest.createInventory(project.Id);
        inv.twod_bm__Guarantee_Issued__c = true;
        inv.twod_bm__Admin_Review__c = true;
        inv.twod_bm__Specification_Check__c = true;
        inv.twod_bm__Is_Building_Approved__c = true;
        
        update inv;
        
        twod_bm__Inspection__c ins = WOD_DataFactoryTest.createInspection(inv.id);
        ins.twod_bm__Type__c = 'Final Inspection';
        ins.twod_bm__Status__c = 'Pending Inspection';
        ins.twod_bm__Inspection_Rating__c = 'Conditionally accepted with Punchlist';
        update ins;
        
        twod_bm__Customer_Communication__c custComm = new twod_bm__Customer_Communication__c();
        custComm.twod_bm__Building__c = inventory.id;
        custComm.twod_bm__Status__c = 'Awaiting Response';
        //insert custComm;
        
        WOD_2__Warranty_Registration__c objwarranty= WOD_DataFactoryTest.createWarrantyRegistration(inventory.id);
        
        Test.stopTest();
    }
    @IsTest
    static void handlerMethods(){
        test.startTest();
        Account acc = new Account();
        acc.Name = 'Test Property Owner';
       // insert acc;

        twod_bm__Project__c proj = WOD_DataFactoryTest.createProject();
        WOD_2__Inventory__c inv = WOD_DataFactoryTest.createInventory(proj.Id);
        
        WOD_2__Warranty_Registration__c objwarranty= WOD_DataFactoryTest.createWarrantyRegistration(inv.id);
        Assembly__c ass = WOD_DataFactoryTest.createAssembly(inv.Id);
        WOD_DataFactoryTest.createAssemblydetail(ass.Id);

        proj.twod_bm__Property_Owner__c = acc.Id;
        proj.twod_bm__Submitted_Internally__c = true;
        proj.twod_bm__Project_Status__c = 'Submitted';
       // update proj;
        
        proj.twod_bm__General_Contractor__c = acc.Id;
       // update proj;
        WOD_ProjectTriggerHandler.createOpenItems(new List<twod_bm__Project__c>{proj});
        test.stopTest();
    }
    
    @IsTest
    static void handlerMethodsForDelete(){
        test.startTest();
        Account acc = new Account();
        acc.Name = 'Test Property Owner';
        //insert acc;

        twod_bm__Project__c proj = WOD_DataFactoryTest.createProject();
        WOD_2__Inventory__c inv = WOD_DataFactoryTest.createInventory(proj.Id);
        
        WOD_2__Warranty_Registration__c objwarranty= WOD_DataFactoryTest.createWarrantyRegistration(inv.id);
        Assembly__c ass = WOD_DataFactoryTest.createAssembly(inv.Id);
        WOD_DataFactoryTest.createAssemblydetail(ass.Id);
        proj.twod_bm__Property_Owner__c = acc.Id;
        proj.twod_bm__Submitted_Internally__c = true;
        proj.twod_bm__Project_Status__c = 'Submitted';
        //update proj;
        
        proj.twod_bm__General_Contractor__c = acc.Id;
       // update proj;
        delete proj;
        test.stopTest();
    }
}