• santhiya durai
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 8
    Replies
I have created a Quick Action button on Itemsetup Object and calling a Lightning component when clickon Button.

When Click on Action button , Popup is showing when I logged in as System Admin. But when I logged in as other user I can't see popup. I have not specfied any permission to visbility of lightning popup. But it is not showing, Why? 

Can anyone help me on this?

Thanks in Advance !
Hi ,
I have created a Lightning component and I am calling that from Quick action.
I have a validation rule that will throw an error and restrict a user to make changes on a record when Record_Locked field is true. But When validation rule is Active, Success part is not working instead else part is working. If I deactivated a validation rule then IF part is working fine.
Can anyone help me on this if I missed anything?

Class: 

public class ArchiveRecord {

    @AuraEnabled
    public static void getItemSetupForm(Id itemsetupId){
        Item_Setup__c itemsetup= [Select Id, Name,Processed__c,Item_Setup_Form_Status__c from Item_Setup__c where Id=:itemsetupId and Item_Setup_Form_Status__c!='Archived'];
        itemsetup.Item_Setup_Form_Status__c='Archived';
        update itemsetup;
        
        if(itemsetup.Item_Setup_Form_Status__c=='Archived'){
          itemsetup.Name=itemsetup.Name +'_Archived';
        }
        upsert itemsetup;
}

}

Component:
<aura:component controller="ArchiveRecord" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickActionWithoutHeader" access="global">
   <aura:html tag="style">
        .cuf-content {
        padding: 0 0rem !important;
        }
        .slds-p-around--medium {
        padding: 0rem !important;
        }       
        .slds-modal__content{
        overflow-y:hidden !important;
        height:unset !important;
        max-height:unset !important;
        }
    </aura:html>
    
    <aura:attribute name="showSpinner" type="boolean" />
    <aura:attribute name="accessFlag" type="boolean"/>
    <aura:attribute name="noAccessFlag" type="boolean"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:if isTrue="{!v.accessFlag}">
     <div class="modal-header slds-modal__header slds-size_1-of-1">
        <h4 class="title slds-text-heading--medium">Archive</h4>
    </div>
    <!--End Modal Header--> 
     
    <!--Modal Body-->  
    <div class="slds-modal__content slds-p-around--x-large slds-align_absolute-center slds-size_1-of-1 slds-is-relative">
        <form class="slds-form--stacked">
           
                <div class="slds-align_absolute-center">
                    <b>Do you want to Archive this record?</b>
                </div>            
            
        </form> 
    </div>
    <!--End of Modal Body-->
     
    <!--Modal Footer-->
    <div class="modal-footer slds-modal__footer slds-size_1-of-1">
        <lightning:button variant="Neutral" class="slds-button" label="Cancel" onclick="{!c.cancelBtn}"/>
        <lightning:button variant="Brand" class="slds-button" label="Continue" onclick="{!c.updateStatus}"/>
        
    </div>
        
    </aura:if>
    
     <aura:if isTrue="{!v.noAccessFlag}">
         
     <div class="modal-header slds-modal__header slds-size_1-of-1">
        <h4 class="title slds-text-heading--medium">Archive</h4>
    </div>
    <!--End Modal Header--> 
     
    <!--Modal Body-->  
    <div class="slds-modal__content slds-p-around--x-large slds-align_absolute-center slds-size_1-of-1 slds-is-relative">
        <form class="slds-form--stacked">
           
                <div class="slds-align_absolute-center slds-text-color_error">
                    <b>You Don't Have Permission to Archive this Record</b>
                </div>            
            
        </form> 
    </div>
    <!--End of Modal Body-->
     
    <!--Modal Footer-->
    <div class="modal-footer slds-modal__footer slds-size_1-of-1">
        <lightning:button variant="Neutral" class="slds-button" label="Cancel" onclick="{!c.cancelBtn}"/>
        
    </div>
    </aura:if>
    
    <aura:if isTrue="{!v.showSpinner}">
        <lightning:spinner variant="brand" alternativeText="Loading" />
    </aura:if>
</aura:component>

Controller:


({
    updateStatus : function(component, event, helper) {
    var itemsetupId=component.get("v.recordId");
        var action=component.get("c.getItemSetupForm");
        action.setParams({"itemsetupId":itemsetupId
            
        });
        action.setCallback(this,function(response){
            
            var state=response.getState();
            if(state==="SUCCESS"){
               let toastEvent = $A.get("e.force:showToast");
                toastEvent.setParams({
                    "title": "Success!",
                    "message": "The record Archived Successfully",
                    "type": "success"   
                });
                toastEvent.fire();
            }
             else if (state === "ERROR")
        {
            alert("You can't make any changes on Archived Record");
        }
              var dismissActionPanel = $A.get("e.force:closeQuickAction");
                dismissActionPanel.fire();  
              $A.get('e.force:refreshView').fire();
             component.set("v.showSpinner",false);
        });
        $A.enqueueAction(action);
    },

    cancelBtn : function(component, event, helper) {
        // Close the action panel
        var dismissActionPanel = $A.get("e.force:closeQuickAction");
        dismissActionPanel.fire();
    },
     // Checking user access for creating new version record
    doInit: function(component, event, helper){ 
         component.set("v.showSpinner",true);
        var action = component.get("c.checkUserValidity");
        action.setCallback(this, function(response){
           var state = response.getState();
            if(state === "SUCCESS"){
                if(response.getReturnValue()){
                   component.set("v.accessFlag", true); 
                }
                else{
                  component.set("v.noAccessFlag", true);  
                    
                }
                component.set("v.showSpinner",false); 
            }
            
        });
       
        $A.enqueueAction(action);
        
    }
    
})


Validation rule:
condition:  Record_Locked__c =true
error message : The Record Archived, You can't make any changes.
Hi,

Here is a User case.
As a Contract Manager, User should Archive a record instead of Delete on Item Setup record.
Once a record is Archived, Status field should get updated as Archived and Quick Action should get disabled or user can't Archive a record again. 
I have created a Quick Action and Lightning Component. I am calling Lightning Component on click of Action. Status is updating as expected . But I am not sure about disbale a Quick Action when status is Archived. Can anyone help me on this?

Class:
public class ArchiveRecord {

    @AuraEnabled
    public static void getItemSetupForm(Id itemsetupId){
        Item_Setup__c itemsetup= [Select Id, Name,Processed__c,Item_Setup_Form_Status__c from Item_Setup__c where Id=:itemsetupId];
        itemsetup.Item_Setup_Form_Status__c='Archived';
        update itemsetup;
        
        if(itemsetup.Item_Setup_Form_Status__c=='Archived'){
          itemsetup.Name=itemsetup.Name +'_Archived';
        }
        upsert itemsetup;
}
  }

Component:
<aura:component controller="ArchiveRecord" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickActionWithoutHeader" access="global">
   <aura:html tag="style">
        .cuf-content {
        padding: 0 0rem !important;
        }
        .slds-p-around--medium {
        padding: 0rem !important;
        }       
        .slds-modal__content{
        overflow-y:hidden !important;
        height:unset !important;
        max-height:unset !important;
        }
    </aura:html>
    
    <aura:attribute name="showSpinner" type="boolean" />
    <aura:attribute name="accessFlag" type="boolean"/>
    <aura:attribute name="noAccessFlag" type="boolean"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:if isTrue="{!v.accessFlag}">
     <div class="modal-header slds-modal__header slds-size_1-of-1">
        <h4 class="title slds-text-heading--medium">Archive Item Setup Form</h4>
    </div>
    <!--End Modal Header--> 
     
    <!--Modal Body-->  
    <div class="slds-modal__content slds-p-around--x-large slds-align_absolute-center slds-size_1-of-1 slds-is-relative">
        <form class="slds-form--stacked">
           
                <div class="slds-align_absolute-center">
                    <b>Do you want to Archive this record?</b>
                </div>            
            
        </form> 
    </div>
    <!--End of Modal Body-->
     
    <!--Modal Footer-->
    <div class="modal-footer slds-modal__footer slds-size_1-of-1">
        <lightning:button variant="Neutral" class="slds-button" label="Cancel" onclick="{!c.cancelBtn}"/>
        <lightning:button variant="Brand" class="slds-button" label="Continue" onclick="{!c.updateStatus}"/>
        
    </div>
        
    </aura:if>
    
</aura:component>

Controller:
({
    updateStatus : function(component, event, helper) {
    var itemsetupId=component.get("v.recordId");
        var action=component.get("c.getItemSetupForm");
        action.setParams({"itemsetupId":itemsetupId
            
        });
        action.setCallback(this,function(response){
            
            var state=response.getState();
            if(state==="SUCCESS"){
               let toastEvent = $A.get("e.force:showToast");
                toastEvent.setParams({
                    "title": "Success!",
                    "message": "The record Archived Successfully",
                    "type": "success"   
                });
                toastEvent.fire();
            }
             else if (state === "ERROR")
        {
            alert("Failed");
        }
              var dismissActionPanel = $A.get("e.force:closeQuickAction");
                dismissActionPanel.fire();  
              $A.get('e.force:refreshView').fire();
             component.set("v.showSpinner",false);
        });
        $A.enqueueAction(action);
    },

    cancelBtn : function(component, event, helper) {
        // Close the action panel
        var dismissActionPanel = $A.get("e.force:closeQuickAction");
        dismissActionPanel.fire();
    }
    
})


Thanks in advance!
Hi,
Here is the usecase.
On Opportunity record, I want to show a Archive button. Onclick of the Archive button a prompt must display “Do you want to Archive the record?” , Cancel and Continue button must be displayed. Onclick of Cancel button the prompt must be closed.
Onclick of the Continue button the status of the record must be updated as ‘Archived’ and the Name of the record must be appended with ‘_Archived’. How can achieve this use case?
I have tried to create a flow and called from Quick action, but in flow i am not able to update a Status field? Does Lightning component required to achieve this case?
Hi,
I have tried to cover the below Apex class but unable to cover.

Apex class:
public class ItemSetupNewVersionController {
    
    /*Description: 
     * This method is used for cloning item setup record from parent record
     * Creating new case record for new Item setup
     * Creating new itemCaseRelation for new case record
     * Creating new Case Product RelationShips for new case record
     */ 
    
    @AuraEnabled
    public static void itemSetupClone(String recordId){ 
        Boolean isItprocessed = false;  
        Map<String, Integer> parentItemSetupMap = new Map<String, Integer>();         
        Case__c newCase = new Case__c();
        List<CaseICIXProductRelationship__c> newCaseProductList = new List<CaseICIXProductRelationship__c>();   
        List<String> fieldAPINames = new List<String>(Schema.SObjectType.Item_Setup__c.fields.getMap().keySet());
        String query = 'SELECT Case__r.Name, Case__r.Case_Description__c, Case__r.Pre_Listing_Case_Number__c, Case__r.Case_Content__c, Case__r.ELWIS_Case_Number__c, Case__r.EKS_Case_Number__c, Case__r.Category_Group_Item_Family__c, Case__r.Temporary_Unique_Key__c, Case__r.Case_version__c, (SELECT Id, ParentId__c FROM Item_setup__r),'+String.join(fieldAPINames,',')+ ' FROM Item_Setup__c WHERE Id=:recordId';  
        Item_Setup__c parentItemSetup = Database.query(query);
        parentItemSetupMap.put(parentItemSetup.ParentId__c == null?recordId:parentItemSetup.ParentId__c, parentItemSetup.ParentId__c == null?parentItemSetup.Item_setup__r.size():[SELECT (SELECT Id,ParentId__c from Item_setup__r) FROM Item_Setup__c WHERE Id =: parentItemSetup.ParentId__c].Item_setup__r.size());        
        // New Case record insertion
        if(parentItemSetup.Case__c != null){
           newCase = new Case__c(Name = parentItemSetup.ParentId__c == null?parentItemSetup.Case__r.Name+'_v'+(parentItemSetupMap.get(recordId)+1):parentItemSetup.Case__r.Name.split('_v')[0]+'_v'+(parentItemSetupMap.get(parentItemSetup.ParentId__c)+1), Case_Description__c = parentItemSetup.Case__r.Case_Description__c, Pre_Listing_Case_Number__c = parentItemSetup.Case__r.Pre_Listing_Case_Number__c, Case_Content__c = parentItemSetup.Case__r.Case_Content__c, ELWIS_Case_Number__c = parentItemSetup.Case__r.ELWIS_Case_Number__c, EKS_Case_Number__c = parentItemSetup.Case__r.EKS_Case_Number__c, Category_Group_Item_Family__c = parentItemSetup.Case__r.Category_Group_Item_Family__c, Temporary_Unique_Key__c = parentItemSetup.Case__r.Temporary_Unique_Key__c, Case_version__c = parentItemSetup.Case__r.Case_version__c);  
            try{
                insert newCase;
            }catch(exception ex){
                System.debug('ItemSetupNewVersionController:itemSetupClone:case Error: '+ex.getMessage());
                throw new AuraHandledException('There is an Exception while inserting case records: '+ex.getMessage());
            }            
    
        }
  
        // Item Setup clone
        Item_Setup__c newItemSetup = parentItemSetup.clone();
        newItemSetup.Name = parentItemSetup.ParentId__c == null?parentItemSetup.Name+'_v'+(parentItemSetupMap.get(recordId)+1):parentItemSetup.Name.split('_v')[0]+'_v'+(parentItemSetupMap.get(parentItemSetup.ParentId__c)+1);       
        newItemSetup.Id = null;
        newItemSetup.Contract_Log_Created__c = false;
        newItemSetup.Valid_From_Verified__c = false;
        newItemSetup.Approved_by_Buyer__c = false;
        newItemSetup.Approved_by_MD__c = false;
        newItemSetup.Item__c = parentItemSetup.Item__c;
        newItemSetup.Case__c = newCase.Id;  
        if(parentItemSetup.ParentId__c == null){
           newItemSetup.ParentId__c = recordId;  
        }
        if(parentItemSetup.Processed__c){
            //Updating the Pricing Information on ItemSetup Record from SQL Server inorder to Populate the same on to the FORM
            List<SQLServerConnector.updateFieldsWrapperClass> pricingInfo = SQLServerConnector.getPricingInfo(recordId);
                                
            for(SQLServerConnector.updateFieldsWrapperClass wrap: pricingInfo){
                newItemSetup.put(wrap.fieldAPI,wrap.fieldValue);
            } 
            
        }              
            try{
                insert newItemSetup;
            }
            catch(exception ex){
                System.debug('ItemSetupNewVersionController:itemSetupClone:case Error: '+ex.getMessage());
                throw new AuraHandledException('There is an Exception while inserting Item Setup records: '+ex.getMessage());
            }
      
          // New itemCaseRelation insertion  
          ItemCaseRelationship__c itemCaseRelation = new ItemCaseRelationship__c ( Case__c = newCase.Id, Item__c = parentItemSetup.Item__c);
              
            try{
                insert itemCaseRelation; 
            }
            catch(exception ex){
                System.debug('ItemSetupNewVersionController:itemSetupClone:Item Case Relationship Error: '+ex.getMessage());
                throw new AuraHandledException('There is an Exception while inserting Item Case Relationship records: '+ex.getMessage());
                
            }
            
    
        //Insertion of new Case Product RelationShips
     
            CaseICIXProductRelationship__c newCaseProduct;
            for(CaseICIXProductRelationship__c caseProduct: [SELECT Id,case__c,ICIX_Product__c,Units_Per_Case__c,Product_UPC__c,Brand_Name__c,Number_of_Units_in_a_Pack__c,Pack_Size_a__c,Unit_of_Measure_a__c,Package_Type_a__c,Product_Long_Description__c FROM CaseICIXProductRelationship__c WHERE Case__c  =:parentItemSetup.Case__c]){
                newCaseProduct = caseProduct.clone();
                newCaseProduct.case__c = newCase.Id;
                newCaseProduct.Id = null;
                newCaseProductList.add(newCaseProduct);
            } 
            
            if(newCaseProductList.size()>0 && !newCaseProductList.isEmpty()){
                try{
                    insert newCaseProductList; 
                    
                }
                catch(exception ex){
                    System.debug('ItemSetupNewVersionController:itemSetupClone:Case ICIXProduct Relationship Error'+ex.getMessage());
                    throw new AuraHandledException('There is an Exception while inserting Case ICIXProduct Relationship records: '+ex.getMessage());
                }
                
            }  
}}

Need help on:

Can someone help me to cover the below lines
 String query = 'SELECT Case__r.Name, Case__r.Case_Description__c, Case__r.Pre_Listing_Case_Number__c, Case__r.Case_Content__c, Case__r.ELWIS_Case_Number__c, Case__r.EKS_Case_Number__c, Case__r.Category_Group_Item_Family__c, Case__r.Temporary_Unique_Key__c, Case__r.Case_version__c, (SELECT Id, ParentId__c FROM Item_setup__r),'+String.join(fieldAPINames,',')+ ' FROM Item_Setup__c WHERE Id=:recordId';  
        Item_Setup__c parentItemSetup = Database.query(query);
        parentItemSetupMap.put(parentItemSetup.ParentId__c == null?recordId:parentItemSetup.ParentId__c, parentItemSetup.ParentId__c == null?parentItemSetup.Item_setup__r.size():[SELECT (SELECT Id,ParentId__c from Item_setup__r) FROM Item_Setup__c WHERE Id =: parentItemSetup.ParentId__c].Item_setup__r.size());        
        // New Case record insertion
        if(parentItemSetup.Case__c != null){
           newCase = new Case__c(Name = parentItemSetup.ParentId__c == null?parentItemSetup.Case__r.Name+'_v'+(parentItemSetupMap.get(recordId)+1):parentItemSetup.Case__r.Name.split('_v')[0]+'_v'+(parentItemSetupMap.get(parentItemSetup.ParentId__c)+1), Case_Description__c = parentItemSetup.Case__r.Case_Description__c, Pre_Listing_Case_Number__c = parentItemSetup.Case__r.Pre_Listing_Case_Number__c, Case_Content__c = parentItemSetup.Case__r.Case_Content__c, ELWIS_Case_Number__c = parentItemSetup.Case__r.ELWIS_Case_Number__c, EKS_Case_Number__c = parentItemSetup.Case__r.EKS_Case_Number__c, Category_Group_Item_Family__c = parentItemSetup.Case__r.Category_Group_Item_Family__c, Temporary_Unique_Key__c = parentItemSetup.Case__r.Temporary_Unique_Key__c, Case_version__c = parentItemSetup.Case__r.Case_version__c);  
            try{
                insert newCase;
            }catch(exception ex){
                System.debug('ItemSetupNewVersionController:itemSetupClone:case Error: '+ex.getMessage());
                throw new AuraHandledException('There is an Exception while inserting case records: '+ex.getMessage());
            }  

Thanks in Advance.

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, UPCustomTrigger: execution of AfterInsert
caused by: System.QueryException: List has no rows for assignment to SObject
Class.UPCustomtriggerHandler.AfterInsert: line 202, column 1 Trigger.UPCustomTrigger: line 9, column 1: []
I am getting this error but not able to figure it out. Due to this am not able to cover 5 test classes. Could anyone please clear me why am getting this error.
The issue am facing is I am not able to insert/update ICIX_V1__UP_Relationship__c records.
Trigger:
trigger UPCustomTrigger on ICIX_V1__UP_Relationship__c (After Insert,Before Update,Before Insert) {
    if(Triggercontrol.check('ICIX_V1__UP_Relationship__c1')){
        if(RecursivePreventer.recursiveFlag){
            if( Trigger.IsBefore &&  Trigger.isupdate){
                UPCustomtriggerHandler.updateUprName(trigger.new);
                UPCustomtriggerHandler.BeforeUpdate(trigger.new,trigger.oldmap);
            }
            if( Trigger.Isafter && Trigger.isInsert ){
              UPCustomtriggerHandler.AfterInsert(trigger.new);
                UPCustomtriggerHandler.afterUprInsert(trigger.new);
               
            }
            if( Trigger.IsBefore && Trigger.isInsert ){
               UPCustomtriggerHandler.updateUprName(trigger.new);
            }
        }
    }
}

controller:
public class UPCustomtriggerHandler{ Public static void BeforeUpdate(list< ICIX_V1__UP_Relationship__c> newRecords, Map<ID, ICIX_V1__UP_Relationship__c> oldRecordMap){ RecursivePreventer.recursiveFlag=false; set<ICIX_V1__UP_Relationship__c> uprInsert=new set<ICIX_V1__UP_Relationship__c>(); set<Id> Aid=new Set<Id>(); set<String> AlreadyExts=new set<String>(); map<Id,Id> uprAccmp=new map<Id,Id>(); Id InternalAccId=[select Id from Account where ICIX_V1__Internal__c=true].Id; system.debug('Trigger.new map'+JSON.serialize(newRecords)); system.debug('Trigger.Old map'+JSON.serialize(oldRecordMap)); for(ICIX_V1__UP_Relationship__c upc : newRecords){ system.debug('New Related Account==>'+ upc.ICIX_V1__Related_Account__c); system.debug('Old Related Account==>'+ oldRecordMap.get(upc.Id).ICIX_V1__Related_Account__c); if(upc.ICIX_V1__Related_Account__c!=null && oldRecordMap.get(upc.Id).ICIX_V1__Related_Account__c==null){ Aid.add(upc.ICIX_V1__Product__c); uprAccmp.put(upc.ICIX_V1__Product__c,upc.ICIX_V1__Related_Account__c); } if(upc.ICIX_V1__Related_Account__c!=null && oldRecordMap.get(upc.Id).ICIX_V1__Related_Account__c!=null && upc.ICIX_V1__Related_Account__c==oldRecordMap.get(upc.Id).ICIX_V1__Related_Account__c){ AlreadyExts.add(upc.ICIX_V1__Product__c+'-'+upc.ICIX_V1__Related_Account__c); } if(upc.ICIX_V1__Related_Account__c!=null && oldRecordMap.get(upc.Id).ICIX_V1__Related_Account__c!=upc.ICIX_V1__Related_Account__c && oldRecordMap.get(upc.Id).ICIX_V1__Related_Account__c!=null){ system.debug('New Related Account==>'+ upc.ICIX_V1__Related_Account__c); system.debug('Old Related Account==>'+ oldRecordMap.get(upc.Id).ICIX_V1__Related_Account__c); ICIX_V1__UP_Relationship__c secondUpRec=new ICIX_V1__UP_Relationship__c(); secondUpRec.Name=upc.Name; secondUpRec.ICIX_V1__Related_Account__c=upc.ICIX_V1__Related_Account__c; secondUpRec.ICIX_V1__Product__c=upc.ICIX_V1__Product__c; secondUpRec.ICIX_V1__Status__c='Active'; secondUpRec.ICIX_V1__Type__c='Buy'; secondUpRec.ICIX_V1__UBE__c=InternalAccId; uprInsert.add(secondUpRec); Aid.add(upc.ICIX_V1__Product__c); uprAccmp.put(upc.ICIX_V1__Product__c,upc.ICIX_V1__Related_Account__c); upc.ICIX_V1__Related_Account__c=oldRecordMap.get(upc.Id).ICIX_V1__Related_Account__c; } } if(!Aid.isempty()){ system.debug('Assortment Ids==>'+uprInsert); set<Id> AllIds=new set<Id>(); List<ICIX_V1__PP_Relationship__c> pplst=[select id,ICIX_V1__Product1__c,ICIX_V1__Product2__c,ICIX_V1__Product2__r.Name,ICIX_V1__Product1__r.Name from ICIX_V1__PP_Relationship__c where ICIX_V1__Product1__c in :Aid and ICIX_V1__Status__c='active' and ICIX_V1__Product2__c!=null]; for(ICIX_V1__PP_Relationship__c pp: pplst ){ AllIds.add(pp.ICIX_V1__Product2__c); } system.debug('Retail Item Ids==>'+AllIds); //Upr Records map<Id,Id> mpUpr=new map<Id,Id>(); List<ICIX_V1__UP_Relationship__c> uprlstRe=[select id,ICIX_V1__Product__c,ICIX_V1__Related_Account__c from ICIX_V1__UP_Relationship__c where ICIX_V1__Product__c in : AllIds and ICIX_V1__Related_Account__c=null]; for(ICIX_V1__UP_Relationship__c upr:uprlstRe ){ mpUpr.put(upr.ICIX_V1__Product__c,upr.Id); } system.debug('Retail Item Ids Blank UPR==>'+JSON.serialize(mpUpr)); map<Id,Set<Id>> ExistingUPRs=new map<Id,Set<Id>>(); List<ICIX_V1__UP_Relationship__c> AlAssgned=[select id,ICIX_V1__Product__c,ICIX_V1__Related_Account__c from ICIX_V1__UP_Relationship__c where ICIX_V1__Product__c in : AllIds and ICIX_V1__Related_Account__c!=null]; for(ICIX_V1__UP_Relationship__c upt : AlAssgned ){ if(ExistingUPRs.containskey(upt.ICIX_V1__Product__c)){ Set<Id> TpID=ExistingUPRs.get(upt.ICIX_V1__Product__c); TpID.add(upt.ICIX_V1__Related_Account__c); ExistingUPRs.put(upt.ICIX_V1__Product__c,TpID); }else{ Set<Id> TpID=New set<Id>(); TpID.add(upt.ICIX_V1__Related_Account__c); ExistingUPRs.put(upt.ICIX_V1__Product__c,TpID); } } system.debug('Retail Item Ids Populated UPR==>'+JSON.serialize(ExistingUPRs)); system.debug('Retail Item Ids Populated UPR==>'+JSON.serialize(uprAccmp)); //Attributes List<ICIX_V1__UP_Relationship__c> uprUpdateset=new List<ICIX_V1__UP_Relationship__c>(); List<ICIX_V1__UP_Relationship__c> uprUpdatelst=new List<ICIX_V1__UP_Relationship__c>(); //For Retail Items for(ICIX_V1__PP_Relationship__c ppt: pplst ){ If(mpUpr.containskey(ppt.ICIX_V1__Product2__c)){ system.debug('Inside Blank'); ICIX_V1__UP_Relationship__c uprUp=new ICIX_V1__UP_Relationship__c(); uprUp.Id=mpUpr.get(ppt.ICIX_V1__Product2__c); uprUp.ICIX_V1__Related_Account__c=uprAccmp.get(ppt.ICIX_V1__Product1__c); uprUpdateset.add(uprUp); mpUpr.remove(ppt.ICIX_V1__Product2__c); }else{ system.debug('No Blank Upr'); Set<Id> Asid=ExistingUPRs.get(ppt.ICIX_V1__Product2__c); system.debug('No Blank Upr Asid='+Asid); system.debug('No Blank Upr uprAccmp.get(ppt.ICIX_V1__Product1__c)='+uprAccmp.get(ppt.ICIX_V1__Product1__c)); if(Asid != null && uprAccmp != null && uprAccmp.get(ppt.ICIX_V1__Product1__c) != null && !Asid.contains(uprAccmp.get(ppt.ICIX_V1__Product1__c))){ system.debug('Inside Not Present'); ICIX_V1__UP_Relationship__c uprIn=new ICIX_V1__UP_Relationship__c(); uprIn.Name=ppt.ICIX_V1__Product2__r.Name; uprIn.ICIX_V1__Related_Account__c=uprAccmp.get(ppt.ICIX_V1__Product1__c); uprIn.ICIX_V1__Product__c=ppt.ICIX_V1__Product2__c; uprIn.ICIX_V1__Status__c='Active'; uprIn.ICIX_V1__Type__c='Buy'; uprIn.ICIX_V1__UBE__c=InternalAccId; uprInsert.add(uprIn); } else{ ICIX_V1__UP_Relationship__c uprIn=new ICIX_V1__UP_Relationship__c(); uprIn.Name=ppt.ICIX_V1__Product2__r.Name; uprIn.ICIX_V1__Related_Account__c=uprAccmp.get(ppt.ICIX_V1__Product1__c); uprIn.ICIX_V1__Product__c=ppt.ICIX_V1__Product2__c; uprIn.ICIX_V1__Status__c='Active'; uprIn.ICIX_V1__Type__c='Buy'; uprIn.ICIX_V1__UBE__c=InternalAccId; uprInsert.add(uprIn); } } } if(!uprUpdateset.IsEmpty()){ system.debug('Updated Records==>'+uprUpdateset); for(ICIX_V1__UP_Relationship__c uprts : uprUpdateset){ if(uprts.ICIX_V1__Related_Account__c!=null){ uprUpdatelst.add(uprts); } } //Update uprUpdatelst;//Assigning to Existing TPR's Database.Update(uprUpdatelst, false); } if(!uprInsert.IsEmpty()){ RecursivePreventer.recursiveFlag=true; List<ICIX_V1__UP_Relationship__c> uprInsertLst=new List<ICIX_V1__UP_Relationship__c>(); for(ICIX_V1__UP_Relationship__c uprt : uprInsert){ if(uprt.ICIX_V1__Related_Account__c!=null){ if(!AlreadyExts.contains(uprt.ICIX_V1__Product__c+'-'+uprt.ICIX_V1__Related_Account__c)){ uprInsertLst.add(uprt); } } } system.debug('Inserted Records==>'+uprInsertLst); //Insert uprInsertLst;//Inserting New TPR's database.Insert(uprInsertLst,false); } } } Public static void AfterInsert(list<ICIX_V1__UP_Relationship__c> newUpr){ RecursivePreventer.recursiveFlag=false; set<Id> AllIds=new set<Id>(); map<Id,List<Id>> MpInsert=new map<Id,List<Id>>(); Map<Id, Id> uprIdVsProductIdMap = new Map<Id, Id>(); List<Id> uprIdList = new List<Id>(); for(ICIX_V1__UP_Relationship__c upc : newUpr){ if(!MpInsert.containsKey(upc.ICIX_V1__Product__c)){ MpInsert.put(upc.ICIX_V1__Product__c,new List<Id>()); MpInsert.get(upc.ICIX_V1__Product__c).add(upc.Id); } else{ MpInsert.get(upc.ICIX_V1__Product__c).add(upc.Id); } //MpInsert.put(upc.ICIX_V1__Product__c,upc.Id); AllIds.add(upc.ICIX_V1__Product__c); uprIdVsProductIdMap.put(upc.Id, upc.ICIX_V1__Product__c); uprIdList.add(upc.Id); } List<ICIX_V1__ICIX_Product__c> productsList = [SELECT Id, ICIX_V1__External_Id__c FROM ICIX_V1__ICIX_Product__c WHERE Id IN: AllIds AND ICIX_V1__External_Id__c != null]; Map<String, String> productIdVsExternalIdMap = new Map<String, String>(); if(productsList.size()>0){ for(ICIX_V1__ICIX_Product__c pro: productsList){ productIdVsExternalIdMap.put(pro.Id, pro.ICIX_V1__External_Id__c); } } map<Id,Id> mpUprF=new map<Id,Id>(); for(ICIX_V1__UP_Relationship__c upr :[select id,ICIX_V1__Product__c,ICIX_V1__Related_Account__c from ICIX_V1__UP_Relationship__c where ICIX_V1__Product__c in : AllIds and ICIX_V1__Related_Account__c!=null and Id not in : newUpr] ){ mpUprF.put(upr.ICIX_V1__Product__c,upr.Id); } List<ICIX_V1__UP_Relationship_Attribute__c> uprlsts=new list<ICIX_V1__UP_Relationship_Attribute__c>(); list<ICIX_V1__Product_Non_Universal_Id__c> ProdNonId=new List<ICIX_V1__Product_Non_Universal_Id__c>(); map<string,ICIX_V1__UP_Relationship_Attribute__c> MpAttr=new map<string,ICIX_V1__UP_Relationship_Attribute__c>(); map<string,ICIX_V1__Product_Non_Universal_Id__c> MpNon=new map<string,ICIX_V1__Product_Non_Universal_Id__c>(); List<ICIX_V1__UP_Relationship_Attribute__c> UprAlst=[select id,ICIX_V1__Attribute__c,ICIX_V1__Attribute_Value__c,ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c,ICIX_V1__UP_Relationship__c from ICIX_V1__UP_Relationship_Attribute__c where ICIX_V1__UP_Relationship__c in : mpUprF.values() and ICIX_V1__Attribute__r.ICIX_V1__Type__c='Attribute']; for(ICIX_V1__UP_Relationship_Attribute__c upra: UprAlst){ MpAttr.put(upra.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c+'-'+upra.ICIX_V1__Attribute__c,upra); } List<ICIX_V1__Product_Non_Universal_Id__c> ProdNonLst=[select id,ICIX_V1__Id_Type__c,ICIX_V1__Id_Value__c,ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c from ICIX_V1__Product_Non_Universal_Id__c where ICIX_V1__UP_Relationship__c in : mpUprF.values()]; for(ICIX_V1__Product_Non_Universal_Id__c upra: ProdNonLst){ MpNon.put(upra.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c+'-'+upra.ICIX_V1__Id_Type__c,upra); } Hasbro_UpRelationshipTriggerHelper.FirstRun=false; for(ICIX_V1__UP_Relationship_Attribute__c uprt: MpAttr.values()){ if(MpInsert.containskey(uprt.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c)){ for(Id uprId: MpInsert.get(uprt.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c)){ ICIX_V1__UP_Relationship_Attribute__c Upra=new ICIX_V1__UP_Relationship_Attribute__c(); Upra.ICIX_V1__Attribute_Value__c=uprt.ICIX_V1__Attribute_Value__c; Upra.ICIX_V1__Attribute__c=uprt.ICIX_V1__Attribute__c; Upra.ICIX_V1__UP_Relationship__c = uprId; uprlsts.add(Upra); } } } Insert uprlsts;//Inserting Product Attributes List<Id> prodNonUniIdUprIdList = new List<Id>(); for(ICIX_V1__Product_Non_Universal_Id__c PnID : MpNon.values() ){ if(MpInsert.containskey(PnID.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c)){ for(Id uprId: MpInsert.get(PnID.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c)){ ICIX_V1__Product_Non_Universal_Id__c Pid=new ICIX_V1__Product_Non_Universal_Id__c(); Pid.ICIX_V1__Id_Type__c=PnID.ICIX_V1__Id_Type__c; pid.ICIX_V1__Id_Value__c=PnId.ICIX_V1__Id_Value__c; pid.ICIX_V1__UP_Relationship__c= uprId; prodNonUniIdUprIdList.add(uprId); ProdNonId.add(Pid); } } } System.debug('=====ProdNonId===='+ProdNonId+'======='+ProdNonId.size()); ICIX_V1__Id_Type__c idType = [SELECT Id, Name, ICIX_V1__Type__c, ICIX_V1__Unique_Id__c FROM ICIX_V1__Id_Type__c WHERE ICIX_V1__Unique_Id__c = 'ITEM_N' AND ICIX_V1__Type__c = 'NonUniversal' LIMIT 1]; System.debug('=========idType========'+idType); if(idType != null){ for(Id uprId: uprIdList){ if(uprId != null && !prodNonUniIdUprIdList.contains(uprId)){ ICIX_V1__Product_Non_Universal_Id__c PnuId = new ICIX_V1__Product_Non_Universal_Id__c(); PnuId.ICIX_V1__Id_Type__c = idType.Id; PnuId.ICIX_V1__Id_Value__c = productIdVsExternalIdMap.get(uprIdVsProductIdMap.get(uprId)); PnuId.ICIX_V1__UP_Relationship__c = uprId; ProdNonId.add(PnuId); } } } System.debug('========ProdNonId======'+ProdNonId+'========'+ProdNonId.size()); if(ProdNonId.size()>0){ insert ProdNonId;//Inserting Product Non Universal Ids } } public static void updateUprName(List<ICIX_V1__UP_Relationship__c> Newrecordlist){ set<Id> Pid=new set<Id>(); for(ICIX_V1__UP_Relationship__c Upr :Newrecordlist){ If(Upr.Name.contains('_*')){ Pid.add(Upr.ICIX_V1__Product__c); } } Pid.remove(null); if(!Pid.Isempty()){ map<Id,ICIX_V1__ICIX_Product__c> Mproduct=new map<Id,ICIX_V1__ICIX_Product__c>([Select id,ICIX_V1__Description__c,Product_Number__c from ICIX_V1__ICIX_Product__c where id in :Pid ]); List<ICIX_V1__UP_Relationship_Attribute__c> UpAttlst=[Select Id,ICIX_V1__Attribute_Value__c,ICIX_V1__UP_Relationship__c from ICIX_V1__UP_Relationship_Attribute__c where ICIX_V1__Attribute__r.Name='Product Number' and ICIX_V1__UP_Relationship__r.ICIX_V1__product__c in:pid]; map<Id,String> MpAttr=new map<Id,String>(); for(ICIX_V1__UP_Relationship_Attribute__c upr : UpAttlst){ MpAttr.put(upr.ICIX_V1__UP_Relationship__c,upr.ICIX_V1__Attribute_Value__c); } List<ICIX_V1__ICIX_Product_Attribute__c> productAttributeList = [SELECT Id,Name, ICIX_V1__ICIX_Product__c, ICIX_V1__Attribute__c, ICIX_V1__Attribute__r.Name, ICIX_V1__Attribute_Value__c FROM ICIX_V1__ICIX_Product_Attribute__c WHERE ICIX_V1__Attribute__r.Name = 'Product Number' AND ICIX_V1__Attribute_Value__c != null AND ICIX_V1__ICIX_Product__c IN: pid]; Map<Id, String> productIdVsAttributeValueMap = new Map<Id, String>(); if(productAttributeList.size()>0 && !productAttributeList.isEmpty()){ for(ICIX_V1__ICIX_Product_Attribute__c pa: productAttributeList){ productIdVsAttributeValueMap.put(pa.ICIX_V1__ICIX_Product__c, pa.ICIX_V1__Attribute_Value__c); } } for(ICIX_V1__UP_Relationship__c Upr : Newrecordlist){ if(Mproduct.containskey(Upr.ICIX_V1__Product__c)){ system.debug('Available Attributes'); if(MpAttr.containskey(Upr.Id)){ Upr.Name=MpAttr.get(Upr.Id)+'_'+Mproduct.get(Upr.ICIX_V1__Product__c).ICIX_V1__Description__c; } else if(productIdVsAttributeValueMap.containsKey(Upr.ICIX_V1__Product__c)){ Upr.Name = productIdVsAttributeValueMap.get(Upr.ICIX_V1__Product__c)+'_'+Mproduct.get(Upr.ICIX_V1__Product__c).ICIX_V1__Description__c; } else { if(Mproduct.get(Upr.ICIX_V1__Product__c).Product_Number__c!=null){ Upr.Name=Mproduct.get(Upr.ICIX_V1__Product__c).Product_Number__c+'_'+Mproduct.get(Upr.ICIX_V1__Product__c).ICIX_V1__Description__c; } } } } } } }
I have created a test class. Related list part is not covering.

On product object UP Relationship is a related list.
I have craeted a product and created UP Relationship nd inserted. how to cover if product.up relationship size>0?

batch class:

global void execute(Database.BatchableContext bc, List<Equivalent_Version__c> evList){
        Equivalent_Version__c ev = evList[0];
        List<String> mappingColorwayList = new List<String>();
        mappingColorwayList.add(ev.DOM_COLORWAY__c);
        mappingColorwayList.addAll(ev.LC_COLORWAY__c.split(','));
        // Colorway matched products.
        List<ICIX_V1__ICIX_Product__c> colorwayMatchedProductsList = new List<ICIX_V1__ICIX_Product__c>();
        Map<String, Map<String, List<String>>> equivalentUniqueVsProductVsUprMap = new Map<String, Map<String, List<String>>>();
        Map<String, ContentVersion> uniqueCvMap = new Map<String, ContentVersion>();
        Map<String, String> cpcCeritificateUniqueUprMap = new Map<String, String>();
        if(mappingColorwayList.size()>0 && !mappingColorwayList.isEmpty()){
            // Collecting all the Assortment/Solid products based on colorway code
            colorwayMatchedProductsList = [SELECT Id, ICIX_V1__Finished_Product__c, Parent_Number__c, Product_Number__c, ColorwayF__c,EquivalentUnique__c,ProductType__c,
                                           (SELECT Id,ICIX_V1__Related_Account__c FROM ICIX_V1__UP_Relationship__r WHERE ICIX_V1__Status__c = 'Active' )
                                           FROM ICIX_V1__ICIX_Product__c
                                           
                                           WHERE ColorwayF__c IN: mappingColorwayList
                                           AND EquivalentUnique__c != null
                                           AND ProductType__c IN ('ASSORTMENT','SOLID')];
            
            System.debug('======colorwayMatchedProductsList======='+colorwayMatchedProductsList);
            
            if(colorwayMatchedProductsList.size()>0 && !colorwayMatchedProductsList.isEmpty()){
                //Separating products based on parent number
                for(ICIX_V1__ICIX_Product__c product: colorwayMatchedProductsList){
                    if(product.ICIX_V1__UP_Relationship__r.size()>0){
                        for(ICIX_V1__UP_Relationship__c upr: product.ICIX_V1__UP_Relationship__r){
                            if(upr.ICIX_V1__Related_Account__c != null){
                                if(!equivalentUniqueVsProductVsUprMap.containsKey(product.EquivalentUnique__c)){
                                    equivalentUniqueVsProductVsUprMap.put(product.EquivalentUnique__c, new Map<String, List<String>>());
                                    equivalentUniqueVsProductVsUprMap.get(product.EquivalentUnique__c).put(product.Id, new List<String>());
                                    equivalentUniqueVsProductVsUprMap.get(product.EquivalentUnique__c).get(product.Id).add(upr.ICIX_V1__Related_Account__c);
                                    
                                }  
                                else{
                                    if(equivalentUniqueVsProductVsUprMap.get(product.EquivalentUnique__c).keySet().contains(product.Id)){
                                        equivalentUniqueVsProductVsUprMap.get(product.EquivalentUnique__c).get(product.Id).add(upr.ICIX_V1__Related_Account__c);
                                        
                                    }
                                    else{
                                        equivalentUniqueVsProductVsUprMap.get(product.EquivalentUnique__c).put(product.Id, new List<String>());
                                        equivalentUniqueVsProductVsUprMap.get(product.EquivalentUnique__c).get(product.Id).add(upr.ICIX_V1__Related_Account__c);
                                        
                                    }
                                    
                                }
                            }
                            
                        }
                        
                    }
                    
                    
                }
                
            }
            
            System.debug('======equivalentUniqueVsProductVsUprMap======='+equivalentUniqueVsProductVsUprMap);
            
Test class:
@isTest
public class ColorwayCertificateGenerationBatch_Test {
    
    @isTest Static void test1(){
     

             
        ColorwayCertificateGenerationBatch cc=new ColorwayCertificateGenerationBatch();

        Equivalent_Version__c ev=new Equivalent_Version__c(Name='99',DOM_COLORWAY__c='229',LC_COLORWAY__c='230');
        insert ev;
        List<Equivalent_Version__c> evList=[SELECT Id, Name, DOM_COLORWAY__c, LC_COLORWAY__c FROM Equivalent_Version__c WHERE DOM_COLORWAY__c != null AND LC_COLORWAY__c != null];
    system.assertEquals(true, evList.size()>0);
        // Database.getQueryLocator(evList);
      
                List<String> mappingColorwayList = new List<String>();
                 mappingColorwayList.add(ev.DOM_COLORWAY__c);
        mappingColorwayList.addAll(ev.LC_COLORWAY__c.split(','));
        
      
        
            List<ICIX_V1__ICIX_Product__c> colorwayMatchedProductsList = new List<ICIX_V1__ICIX_Product__c>();
        Map<String, Map<String, List<String>>> equivalentUniqueVsProductVsUprMap = new Map<String, Map<String, List<String>>>();
        Map<String, ContentVersion> uniqueCvMap = new Map<String, ContentVersion>();
        Map<String, String> cpcCeritificateUniqueUprMap = new Map<String, String>();
        System.assertEquals(true, mappingColorwayList.size()>0);
        System.assertEquals(true, !mappingColorwayList.isEmpty());
        
        //creating account
    Account acc = new Account(Name = 'Name783', Type = 'Prospect', Facility_Name__c = 'Facil788', ICIX_V1__Status__c = 'Active', ICIX_V1__ICIX_ID__c = 'ICIX_480');
    Insert acc;
        List<ICIX_V1__ICIX_Product__c> productlst=new List<ICIX_V1__ICIX_Product__c>();
         ICIX_V1__ICIX_Product__c product=new ICIX_V1__ICIX_Product__c(Name='product1',ICIX_V1__Finished_Product__c=false,Parent_Number__c='C3994',Product_Number__c='C3994AS01',
         
                                                                       ProductType__c='ASSORTMENT;SOLID' ); 
       //product.EquivalentUnique__c!=null;
      
                 ICIX_V1__ICIX_Product__c product1=new ICIX_V1__ICIX_Product__c(Name='product2',ICIX_V1__Finished_Product__c=false,Parent_Number__c='C3995',Product_Number__c='C3995AS02',
         
                                                                       ProductType__c='ASSORTMENT;SOLID' ); 
       //product.EquivalentUnique__c!=null;
        productlst.add(product);
        productlst.add(product1);
        insert productlst;

        mappingColorwayList.add(product.ColorwayF__c);
       
        try{
            List<ICIX_V1__UP_Relationship__c> uplist=new List<ICIX_V1__UP_Relationship__c>();
        ICIX_V1__UP_Relationship__c up=new ICIX_V1__UP_Relationship__c(Name='C3994AS01_MVL',ICIX_V1__Related_Account__c=acc.id,ICIX_V1__Status__c='Active',
                                                                       ICIX_V1__Product__c=product.id,ICIX_V1__Type__c='Tag');
      
         ICIX_V1__UP_Relationship__c up1=new ICIX_V1__UP_Relationship__c(Name='C3994AS01',ICIX_V1__Related_Account__c=acc.id,ICIX_V1__Status__c='Active',
                                                                       ICIX_V1__Product__c=product.id,ICIX_V1__Type__c='Tag');
       
            uplist.add(up);
            uplist.add(up1);
            insert uplist;
        }
        catch(Exception e) {
            Boolean isException;
            if(e.getMessage().contains('Exception thrown for test class'))
            isException = true;
            system.assertEquals(isException, null);
        }
         colorwayMatchedProductsList = [SELECT Id, ICIX_V1__Finished_Product__c, Parent_Number__c, Product_Number__c, ColorwayF__c,EquivalentUnique__c,ProductType__c,
                                           (SELECT Id,ICIX_V1__Related_Account__c FROM ICIX_V1__UP_Relationship__r WHERE ICIX_V1__Status__c = 'Active' )
                                           FROM ICIX_V1__ICIX_Product__c
                                           
                                           WHERE ColorwayF__c IN: mappingColorwayList
                                           AND EquivalentUnique__c != null
                                           AND ProductType__c IN ('ASSORTMENT','SOLID')];
        system.assertEquals(true, productlst.size()>0);
        system.assertEquals(true, product.ICIX_V1__UP_Relationship__r.size()>0);
        
     Database.BatchableContext bc;
    cc.start(bc);
        Database.executebatch(new ColorwayCertificateGenerationBatch(),1);
        
    }

   
}
I have created a test class for batch class. But Execute method is not covering even single line. Could anypne help me on this?

Class:
public class UPRSync implements Database.Batchable<sObject>,Database.stateful{
    public string AssortmentId;
    public String InputQuery;
    public UPRSync(String Query1){
        AssortmentId='NA';
        InputQuery=Query1;
    }
    public UPRSync(Id AssortId){
        AssortmentId='NAS';
        AssortmentId=AssortId;
    }
    public Database.QueryLocator start(Database.BatchableContext BC){
        Datetime hourBack = Datetime.now().addMinutes(-60);
        String Query;
        system.debug(AssortmentId);
        if(AssortmentId=='NA'){
            Query=InputQuery;
        }else{
            system.debug('AssortmentId==>'+AssortmentId);
            Query='select ICIX_V1__Product1__c,ICIX_V1__Product2__c from ICIX_V1__PP_Relationship__c where ICIX_V1__Product2__c !=null and  ICIX_V1__Type__c=\'component\' and ICIX_V1__Product1__c=:AssortmentId';
        }
        return Database.getQueryLocator(Query);
    }
    public void execute(Database.BatchableContext BC, List<ICIX_V1__PP_Relationship__c> scope){
        //Assortment or Solid Ids
        Set<Id> AsstId=new set<Id>();
        for(ICIX_V1__PP_Relationship__c pp : Scope){
            AsstId.add(pp.ICIX_V1__Product1__c);
        }
        AsstId.remove(null);
        List<ICIX_V1__ICIX_Product__c> Scope1=[Select Id,Name from ICIX_V1__ICIX_Product__c where Id in : AsstId];
        set<Id> AllIds=new set<Id>();
        map<Id,List<Id>> MpPP=new map<Id,List<Id>>();
        for(ICIX_V1__PP_Relationship__c pp : [select ICIX_V1__Product1__c,ICIX_V1__Product2__c from ICIX_V1__PP_Relationship__c where ICIX_V1__Product2__c !=null and ICIX_V1__Product1__c in: AsstId and ICIX_V1__Type__c='component'] ){
            AllIds.add(pp.ICIX_V1__Product1__c);
            AllIds.add(pp.ICIX_V1__Product2__c);
            //Creating a map of Assortment/Solid and its Retail items
            if(MpPP.containskey(pp.ICIX_V1__Product1__c)){
                MpPP.get(pp.ICIX_V1__Product1__c).add(pp.ICIX_V1__Product2__c);
            }else{
                MpPP.put(pp.ICIX_V1__Product1__c, new list<Id> { pp.ICIX_V1__Product2__c });
            }
        }
        map<Id,ICIX_V1__ICIX_Product__c> Mpprod=new map<Id,ICIX_V1__ICIX_Product__c>([Select id,name from ICIX_V1__ICIX_Product__c where Id in : AllIds]);
        Id InternalAccId=[select Id from Account where ICIX_V1__Internal__c=true].Id;
        AllIds.remove(null);
        //Map of Product and 
        map<Id,List<ICIX_V1__UP_Relationship__c>> MpUprs=new map<Id,List<ICIX_V1__UP_Relationship__c>>();
        List<ICIX_V1__UP_Relationship__c> Uprlst=[select Id,ICIX_V1__Related_Account__c,ICIX_V1__Product__c from ICIX_V1__UP_Relationship__c where ICIX_V1__Product__c in : AllIds ];
        //Capturing the Product and its upr in a map..
        for(ICIX_V1__UP_Relationship__c upr : Uprlst){
            if(MpUprs.containskey(upr.ICIX_V1__Product__c)){
                MpUprs.get(upr.ICIX_V1__Product__c).add(upr);
            }else{
                MpUprs.put(upr.ICIX_V1__Product__c, new list<ICIX_V1__UP_Relationship__c> { upr });
            }
        }
        //List to Insert..
        List<ICIX_V1__UP_Relationship__c> UprlsttoUpdate=new List<ICIX_V1__UP_Relationship__c>();
        List<ICIX_V1__UP_Relationship__c> UprlsttoUpdateset=new List<ICIX_V1__UP_Relationship__c>();
        List<ICIX_V1__UP_Relationship__c> UprlsttoInsertset=new List<ICIX_V1__UP_Relationship__c>();
        for(ICIX_V1__ICIX_Product__c Prd : scope1){
            if(MpPP.containskey(Prd.Id)){
                List<Id> RetailIds=MpPP.get(Prd.Id);
                for(Id Rid: RetailIds){
                    list<ICIX_V1__UP_Relationship__c> UpAsst=MpUprs.get(Prd.Id);
                    list<ICIX_V1__UP_Relationship__c> REuprs=MpUprs.get(Rid);
                    system.debug('Retail Item Ids==>'+Rid);
                    system.debug('Upr Ids==>'+UpAsst.Size());
                    system.debug('Retail Upr Ids==>'+REuprs.size());
                    set<Id> TradingPartners=new set<Id>();
                    Id BlankUpr; 
                    Boolean populateUpr=false;
                    for(ICIX_V1__UP_Relationship__c upr : REuprs){
                        if(upr.ICIX_V1__Related_Account__c==null){
                            BlankUpr=upr.Id;
                            populateUpr=true;
                        }else{
                            TradingPartners.add(upr.ICIX_V1__Related_Account__c);  
                        }
                    }
                    system.debug('Trading Partners size==>'+TradingPartners.size());
                    for(ICIX_V1__UP_Relationship__c uprAt : UpAsst){
                        if(populateUpr){
                            ICIX_V1__UP_Relationship__c upt=new ICIX_V1__UP_Relationship__c();
                            upt.Id=BlankUpr;
                            upt.ICIX_V1__Related_Account__c=uprAt.ICIX_V1__Related_Account__c;
                            UprlsttoUpdateset.add(upt);
                            populateUpr=false;
                        }
                        if(!populateUpr){
                            if(!TradingPartners.contains(uprAt.ICIX_V1__Related_Account__c)){
                                system.debug('Inside');
                                ICIX_V1__UP_Relationship__c uprIn=new ICIX_V1__UP_Relationship__c();
                                uprIn.Name=Mpprod.get(Rid).Name;
                                uprIn.ICIX_V1__Related_Account__c=uprAt.ICIX_V1__Related_Account__c;
                                uprIn.ICIX_V1__Product__c=Rid;
                                uprIn.ICIX_V1__Status__c='Active';
                                uprIn.ICIX_V1__Type__c='Buy';
                                uprIn.ICIX_V1__UBE__c=InternalAccId;
                                
                                UprlsttoInsertset.add(uprIn); 
                                
                            } 
                        }
                    }
                }
            }
        }
        if(!UprlsttoUpdateset.Isempty()){
            RecursivePreventer.recursiveFlag=false;
            for(ICIX_V1__UP_Relationship__c uprt : UprlsttoUpdateset){
                if(uprt.ICIX_V1__Related_Account__c!=null){
                    UprlsttoUpdate.add(uprt);
                }
            }
            database.update(UprlsttoUpdate,false);
        }
        if(!UprlsttoInsertset.Isempty()){
            
            RecursivePreventer.recursiveFlag=false;
            List<ICIX_V1__UP_Relationship__c> UprlsttoInsert=new List<ICIX_V1__UP_Relationship__c>();
            for(ICIX_V1__UP_Relationship__c uprt : UprlsttoInsertset){
                if(uprt.ICIX_V1__Related_Account__c!=null){
                    UprlsttoInsert.add(uprt);
                }
            }
            
            database.insert(UprlsttoInsert,false);
            //Logic for Querying the Attributes and Non Universal Id..
            map<Id,List<Id>> MpInsert=new map<Id,List<Id>>();
            set<Id> NewUprIds=new set<Id>();
            Map<Id, Id> uprIdVsProductIdMap = new Map<Id, Id>();
            for(ICIX_V1__UP_Relationship__c upc : UprlsttoInsert){
                NewUprIds.add(upc.Id);
                uprIdVsProductIdMap.put(upc.Id, upc.ICIX_V1__Product__c);
                if(MpInsert.containskey(upc.ICIX_V1__Product__c)){
                    MpInsert.get(upc.ICIX_V1__Product__c).add(upc.Id);
                }else{
                    MpInsert.put(upc.ICIX_V1__Product__c, new list<Id> { upc.Id });
                }
            }
            NewUprIds.remove(null);
            map<Id,Id> mpUprF=new map<Id,Id>();
            for(ICIX_V1__UP_Relationship__c upr :[select id,ICIX_V1__Product__c,ICIX_V1__Related_Account__c from ICIX_V1__UP_Relationship__c where ICIX_V1__Product__c in : AllIds and ICIX_V1__Related_Account__c!=null and  Id not in : NewUprIds] ){
                mpUprF.put(upr.ICIX_V1__Product__c,upr.Id);
            }
            List<ICIX_V1__UP_Relationship_Attribute__c> uprlsts=new list<ICIX_V1__UP_Relationship_Attribute__c>();
            list<ICIX_V1__Product_Non_Universal_Id__c> ProdNonId=new List<ICIX_V1__Product_Non_Universal_Id__c>();
            map<string,ICIX_V1__UP_Relationship_Attribute__c> MpAttr=new map<string,ICIX_V1__UP_Relationship_Attribute__c>();
            map<string,ICIX_V1__Product_Non_Universal_Id__c> MpNon=new map<string,ICIX_V1__Product_Non_Universal_Id__c>();
            List<ICIX_V1__UP_Relationship_Attribute__c> UprAlst=[select id,ICIX_V1__Attribute__c,ICIX_V1__Attribute_Value__c,ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c,ICIX_V1__UP_Relationship__c from ICIX_V1__UP_Relationship_Attribute__c where ICIX_V1__UP_Relationship__c in : mpUprF.values() and ICIX_V1__Attribute__r.ICIX_V1__Type__c='Attribute'];
            for(ICIX_V1__UP_Relationship_Attribute__c upra: UprAlst){
                MpAttr.put(upra.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c+'-'+upra.ICIX_V1__Attribute__c,upra);
            }
            List<ICIX_V1__Product_Non_Universal_Id__c> ProdNonLst=[select id,ICIX_V1__Id_Type__c,ICIX_V1__Id_Value__c,ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c from ICIX_V1__Product_Non_Universal_Id__c where ICIX_V1__UP_Relationship__c in : mpUprF.values()];
            for(ICIX_V1__Product_Non_Universal_Id__c upra: ProdNonLst){
                MpNon.put(upra.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c+'-'+upra.ICIX_V1__Id_Type__c,upra);
            }
            Hasbro_UpRelationshipTriggerHelper.FirstRun=false;
            for(ICIX_V1__UP_Relationship_Attribute__c uprt: MpAttr.values()){
                if(MpInsert.containskey(uprt.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c)){
                    List<Id> Uprids=MpInsert.get(uprt.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c);
                    for(Id Ids : Uprids){
                        if(Ids!=null){
                            system.debug('====Upr ids=='+ids);
                            ICIX_V1__UP_Relationship_Attribute__c Upra=new ICIX_V1__UP_Relationship_Attribute__c();
                            //Upra.name=ids;
                            Upra.ICIX_V1__Attribute_Value__c=uprt.ICIX_V1__Attribute_Value__c;
                            Upra.ICIX_V1__Attribute__c=uprt.ICIX_V1__Attribute__c;
                            Upra.ICIX_V1__UP_Relationship__c=ids;
                            uprlsts.add(Upra);
                        }
                    }
                }
            }
            Insert uprlsts;//Inserting Product Attributes
            List<Id> prodNonUniIdUprIdList = new List<Id>();
            for(ICIX_V1__Product_Non_Universal_Id__c PnID : MpNon.values() ){
                if(MpInsert.containskey(PnID.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c)){
                    List<Id> Uprids=MpInsert.get(PnID.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c);
                    for(Id Ids : Uprids){
                        if(ids!=null){
                            system.debug('=======>ppnon uid'+ids);
                            ICIX_V1__Product_Non_Universal_Id__c Pid=new ICIX_V1__Product_Non_Universal_Id__c();
                            Pid.ICIX_V1__Id_Type__c=PnID.ICIX_V1__Id_Type__c;
                            pid.ICIX_V1__Id_Value__c=PnID.ICIX_V1__Id_Value__c;
                            pid.ICIX_V1__UP_Relationship__c=Ids;
                            prodNonUniIdUprIdList.add(Ids);
                            ProdNonId.add(Pid);
                        }
                    }
                }
            }
            
            
            List<ICIX_V1__ICIX_Product__c> productsList = [SELECT Id, ICIX_V1__External_Id__c FROM ICIX_V1__ICIX_Product__c WHERE Id IN: MpInsert.keySet() AND ICIX_V1__External_Id__c != null];
            Map<String, String> productIdVsExternalIdMap = new Map<String, String>();
            
            if(productsList.size()>0){
                for(ICIX_V1__ICIX_Product__c pro: productsList){
                    productIdVsExternalIdMap.put(pro.Id, pro.ICIX_V1__External_Id__c);
                    
                }
                
            }
            
            ICIX_V1__Id_Type__c idType = [SELECT Id, Name, ICIX_V1__Type__c, ICIX_V1__Unique_Id__c
                                          FROM ICIX_V1__Id_Type__c
                                          WHERE ICIX_V1__Unique_Id__c = 'ITEM_N'
                                          AND ICIX_V1__Type__c = 'NonUniversal' LIMIT 1];
            System.debug('=========idType========'+idType);
            
            if(idType != null){
                
                for(ICIX_V1__UP_Relationship__c uprId: UprlsttoInsert){
                    if(uprId.Id != null){
                    if(!prodNonUniIdUprIdList.contains(uprId.Id)){
                        if(uprIdVsProductIdMap.containsKey(uprId.Id) && productIdVsExternalIdMap.containsKey(uprIdVsProductIdMap.get(uprId.Id))){
                        
                        ICIX_V1__Product_Non_Universal_Id__c PnuId = new ICIX_V1__Product_Non_Universal_Id__c();
                        PnuId.ICIX_V1__Id_Type__c = idType.Id;
                        PnuId.ICIX_V1__Id_Value__c = productIdVsExternalIdMap.get(uprIdVsProductIdMap.get(uprId.Id));
                        PnuId.ICIX_V1__UP_Relationship__c = uprId.Id;
                        
                        ProdNonId.add(PnuId);
                        
                        
                    }
                    
                    }
                    } 
                }
                
                
                
                
            }
            
            
            if(ProdNonId.size()>0){
                
                insert ProdNonId;//Inserting Product Non Universal Ids
            }
        }
    }
    public void finish(Database.BatchableContext BC){
    }
}

Test class:
@isTest
Public class UPRSync_Test{
    @isTest Static void testUPRSync(){
        try{
        //Create TheCustom settings
        PP_Deletion_Batch__c pp_del=new PP_Deletion_Batch__c();
        pp_del.name='PPDeletionBatch';
        pp_del.Is_Processed__c=true;
        insert pp_del;
        //create Account
        list<Account> accs=Hasbro_TestDataFactory.createAccount();
        accs[0].facility_name__c=accs[0].name;
        Update accs;
        //Create Responder Account
        Account acc=new Account();
        acc.name='Hasbro Dev Stg Req';
        acc.ICIX_V1__Status__c='Active';
        acc.ICIX_V1__ICIX_ID__c='304789';
        acc.ICIX_V1__Internal__c=true;
        acc.facility_name__c='Hasbro Dev Stg Req';
        insert acc;
        //create the product
        list<ICIX_V1__ICIX_Product__c> AssortProd=Hasbro_TestDataFactory.createProduct();
        //Create RetailItem Product
        list<ICIX_V1__ICIX_Product__c> RetailProd=Hasbro_TestDataFactory.createReatilItem();
        //create the PP Relation 
        list<ICIX_V1__PP_Relationship__c> PPr =Hasbro_TestDataFactory.createPP_relationship();
        ppr[0].ICIX_V1__Product1__c=AssortProd[0].id;
        ppr[0].ICIX_V1__Product2__c=RetailProd[0].id;
        ppr[0].ICIX_V1__Type__c='component';
        Update ppr;
        //create Up Relation record
        list< ICIX_V1__UP_Relationship__c> Upr_rel=new list<ICIX_V1__UP_Relationship__c>();
        ICIX_V1__UP_Relationship__c up_realationShip=new ICIX_V1__UP_Relationship__c();
        up_realationShip.name='BLP BLACK PANTHER MOVIE';
        up_realationShip.ICIX_V1__Status__c='Active';
        up_realationShip.ICIX_V1__Type__c='Buy';
        up_realationShip.ICIX_V1__Product__c=AssortProd[0].Id;
        up_realationShip.ICIX_V1__Related_Account__c=acc.Id;
        //up_realationShip.ICIX_V1__UBE__c=acc.id;
        Upr_rel.add(up_realationShip);
        ICIX_V1__UP_Relationship__c up_realationShip1=new ICIX_V1__UP_Relationship__c();
        up_realationShip1.name='BLP BLACK PANTHER MOVIE';
        up_realationShip1.ICIX_V1__Status__c='Active';
        up_realationShip1.ICIX_V1__Type__c='Buy';
        up_realationShip1.ICIX_V1__Product__c=RetailProd[0].Id;
        up_realationShip1.ICIX_V1__Related_Account__c=acc.Id;
       Upr_rel.add(up_realationShip1);
        insert Upr_rel;
        //create Up Relationship attribute
        list<ICIX_V1__UP_Relationship_Attribute__c> attri=Hasbro_TestDataFactory.createUpRealtionShipAttribute();
        attri[0].ICIX_V1__UP_Relationship__c=Upr_rel[1].id;
        insert attri;
        System.Test.Starttest();
        UPRSync sh1 = new UPRSync (AssortProd[0].Id);
        database.executebatch( new UPRSync (AssortProd[0].Id));
        JobRunnerUPRSync Job=new JobRunnerUPRSync(10,'select ICIX_V1__Product1__c,ICIX_V1__Product2__c from ICIX_V1__PP_Relationship__c',1);
        String sch = '0 0 23 * * ?'; 
        system.schedule('Test Territory Check', sch, Job); 
        System.Test.StopTest();  
    }
    catch(Exception e){}
}
     
}
One of my customer created below class. I have created a test class to cover but I am unable to cover the code. It seems I have created a correct data but it is not covering .Please anyone help me on this.

Class:

public class MassQEController{
    
    @Auraenabled
    public static List<string> getAccounts(){
        List<ICIX_V1__Trading_Partner_Relationship__c> tprlist=[select id,ICIX_V1__Responder__r.Facility_Name__c,ICIX_V1__Responder__r.name from ICIX_V1__Trading_Partner_Relationship__c where ICIX_V1__Status__c='Active' and ICIX_V1__Type__c='Vendor' order by ICIX_V1__Responder__r.facility_name__c asc];
        List<String> str=new List<String>();
        for(ICIX_V1__Trading_Partner_Relationship__c tpr:tprlist ){
            if(tpr.ICIX_V1__Responder__r.Facility_Name__c!=null){
                str.add(tpr.ICIX_V1__Responder__r.Facility_Name__c);
            }
        }
        return str;
    }
@Auraenabled
    public static string getprods(string TradingPartnerName,string  parentnumber,string Globalsku,String Productnumber){
        List<ICIX_V1__UP_Relationship__c> uprlsts=new List<ICIX_V1__UP_Relationship__c>();
        set<String> strn=new set<String>();
        strn.add('ASSORTMENT');
        strn.add('SOLID');
        set<Id> pid=new set<Id>();
        if(parentnumber==''){
            parentnumber='XYZ';
        }
        if(Globalsku==''){
            Globalsku='XYZ';
        }
        if(Productnumber==''){
            Productnumber='XYZ';
        }
        if(TradingPartnerName!='No Trading Partner' && TradingPartnerName!= 'All Trading Partners'){
            uprlsts=[select id,ICIX_V1__Product__c,ICIX_V1__Product__r.GlobalSKU__c,ICIX_V1__Product__r.PRODUCTTYPE__c,ICIX_V1__Product__r.Parent_Number__c,ICIX_V1__Product__r.Name,ICIX_V1__Product__r.Product_Number__c,ICIX_V1__Related_Account__r.name,ICIX_V1__Related_Account__r.facility_name__c from ICIX_V1__UP_Relationship__c where ICIX_V1__Related_Account__r.Facility_Name__c=:TradingPartnerName and (ICIX_V1__Product__r.Parent_Number__c like: '%'+parentnumber+'%' or ICIX_V1__Product__r.GlobalSKU__c like: '%'+Globalsku+'%' or ICIX_V1__Product__r.Product_Number__c like: '%'+Productnumber+'%' ) and ICIX_V1__Product__r.PRODUCTTYPE__c in :strn];
        }
        else if(TradingPartnerName=='No Trading Partner'){
            uprlsts=[select id,ICIX_V1__Product__c,ICIX_V1__Product__r.GlobalSKU__c,ICIX_V1__Product__r.PRODUCTTYPE__c,ICIX_V1__Product__r.Parent_Number__c,ICIX_V1__Product__r.Name,ICIX_V1__Product__r.Product_Number__c,ICIX_V1__Related_Account__r.name,ICIX_V1__Related_Account__r.facility_name__c from ICIX_V1__UP_Relationship__c where ICIX_V1__Related_Account__c=null and (ICIX_V1__Product__r.Parent_Number__c like: '%'+parentnumber+'%' or ICIX_V1__Product__r.GlobalSKU__c like: '%'+Globalsku+'%' or ICIX_V1__Product__r.Product_Number__c like: '%'+Productnumber+'%' )  and ICIX_V1__Product__r.PRODUCTTYPE__c in :strn];
        }
        else if(TradingPartnerName == 'All Trading Partners'){
          uprlsts=[select id,ICIX_V1__Product__c,ICIX_V1__Product__r.GlobalSKU__c,ICIX_V1__Product__r.PRODUCTTYPE__c,ICIX_V1__Product__r.Parent_Number__c,ICIX_V1__Product__r.Name,ICIX_V1__Product__r.Product_Number__c,ICIX_V1__Related_Account__r.name,ICIX_V1__Related_Account__r.facility_name__c from ICIX_V1__UP_Relationship__c where ICIX_V1__Related_Account__c !=null AND (ICIX_V1__Product__r.Parent_Number__c like: '%'+parentnumber+'%' or ICIX_V1__Product__r.GlobalSKU__c like: '%'+Globalsku+'%' or ICIX_V1__Product__r.Product_Number__c like: '%'+Productnumber+'%' ) and ICIX_V1__Product__r.PRODUCTTYPE__c in :strn];
     
        }
        set<id> upids=new set<id>();
        for(ICIX_V1__UP_Relationship__c upr:uprlsts){
            upids.add(upr.id);
        }
        map<id,ICIX_V1__UP_Relationship_Attribute__c> map_upr=new map<id,ICIX_V1__UP_Relationship_Attribute__c>();
        List<ICIX_V1__UP_Relationship_Attribute__c> uprAttr=[select id,ICIX_V1__UP_Relationship__c,ICIX_V1__Attribute_Value__c from ICIX_V1__UP_Relationship_Attribute__c where ICIX_V1__UP_Relationship__c in:upids and ICIX_V1__Attribute__r.ICIX_V1__Type__c='Tag' ];
        for(ICIX_V1__UP_Relationship_Attribute__c up:uprAttr){
            map_upr.put(up.ICIX_V1__UP_Relationship__c,up);
        }
        List<prodwrap> prodwraplist=new List<prodwrap>();
        for(ICIX_V1__UP_Relationship__c upr: uprlsts ){
            prodwrap prwrp=new prodwrap();
            prwrp.Productname=upr.ICIX_V1__Product__r.Name;
            prwrp.UprId=upr.Id;
            prwrp.Producttype=upr.ICIX_V1__Product__r.PRODUCTTYPE__c;
            prwrp.SFRecid='/'+upr.ICIX_V1__Product__c;
            prwrp.ProductNumber=upr.ICIX_V1__Product__r.Product_Number__c;
            prwrp.Facility=UPR.ICIX_V1__Related_Account__r.Facility_name__c;
            prwrp.Parentnumber=upr.ICIX_V1__Product__r.Parent_Number__c;
            prwrp.Globalsku=upr.ICIX_V1__Product__r.GlobalSKU__c;
            if(map_upr.containskey(upr.id)){
                if(map_upr.get(upr.id).ICIX_V1__Attribute_Value__c!=null){
                    prwrp.Responsibleqe=map_upr.get(upr.id).ICIX_V1__Attribute_Value__c;
                }
            }
            prodwraplist.add(prwrp);
        }
        string ks=JSON.serialize(prodwraplist,true);
        string ns=ks.replace('children', '_children');
        system.debug(ns);
        return ns;
    }
    @Auraenabled
    public static string UpdateQEs(List<Id> UprIds , String ResponsibleQE ,String FacilityName ){
        System.debug('=========UprIds=========='+UprIds);
        System.debug('=========ResponsibleQE=========='+ResponsibleQE);
        System.debug('=========FacilityName=========='+FacilityName);
        list<ICIX_V1__UP_Relationship_Attribute__c> Upattr=[select id,ICIX_V1__Attribute__c from ICIX_V1__UP_Relationship_Attribute__c where ICIX_V1__UP_Relationship__c in:UprIds and ICIX_V1__Attribute__r.ICIX_V1__Type__c='Tag'];
        delete  Upattr;
        list<ICIX_V1__Attribute__c> attr=[select id,name from ICIX_V1__Attribute__c where name=:ResponsibleQE and ICIX_V1__type__c='Tag' limit 1];
        list<ICIX_V1__UP_Relationship_Attribute__c> Uprattriinsert=new list<ICIX_V1__UP_Relationship_Attribute__c>();
        list<ICIX_V1__UP_Relationship_Attribute__c> UprattriinsertAsst=new list<ICIX_V1__UP_Relationship_Attribute__c>();
        Id AttrId=attr[0].Id;
        system.debug('attribute'+attr);
        for(Id ids:UprIds){
            for(ICIX_V1__Attribute__c c:attr){
                ICIX_V1__UP_Relationship_Attribute__c a=new ICIX_V1__UP_Relationship_Attribute__c();
                a.ICIX_V1__UP_Relationship__c=ids;
                a.ICIX_V1__Attribute_Value__c=ResponsibleQE;
                a.ICIX_V1__Attribute__c=c.id;
                UprattriinsertAsst.add(a);
            }
        }   
        list<ICIX_V1__PP_Relationship__c> pprel=[select id,ICIX_V1__Product1__c,ICIX_V1__Product2__c from ICIX_V1__PP_Relationship__c where ICIX_V1__Product1__c in (select ICIX_V1__Product__c from ICIX_V1__UP_Relationship__c where Id in : UprIds)  and ICIX_V1__type__c='Component'];
        set<id> rids=new set<id>();
        for(ICIX_V1__PP_Relationship__c p:pprel){
            if(p.ICIX_V1__Product2__c !=null){
                rids.add(p.ICIX_V1__Product2__c );
            }
        }
        List<ICIX_V1__UP_Relationship__c> uprlsts = new List<ICIX_V1__UP_Relationship__c>();
        if(FacilityName == 'All Trading Partners'){
         uprlsts = [SELECT Id,ICIX_V1__Product__c,ICIX_V1__Related_Account__c FROM ICIX_V1__UP_Relationship__c WHERE ICIX_V1__Related_Account__r.Facility_Name__c != null AND  ICIX_V1__Product__c in : rids];   
        }
        else{
        uprlsts=[select id,ICIX_V1__Product__c from ICIX_V1__UP_Relationship__c where ICIX_V1__Related_Account__r.Facility_Name__c=:FacilityName and ICIX_V1__Product__c in : rids];
        }
        list<ICIX_V1__UP_Relationship_Attribute__c> UpattrRetailItems=[select id,ICIX_V1__Attribute__c,ICIX_V1__UP_Relationship__c from ICIX_V1__UP_Relationship_Attribute__c where ICIX_V1__UP_Relationship__c in:uprlsts and ICIX_V1__Attribute__c=:AttrId];
        system.debug('Existing Attributess==>'+UpattrRetailItems);
        set<Id> Alreadyexists=new set<Id>();
        for(ICIX_V1__UP_Relationship_Attribute__c uprAtt : UpattrRetailItems){
            Alreadyexists.add(uprAtt.ICIX_V1__UP_Relationship__c);
        }
        system.debug('Existing Attributess==>'+Alreadyexists);
        set<Id> ReIds=new set<Id>();
        set<Id> ReUpr=new set<Id>();
        for(ICIX_V1__UP_Relationship__c Upr:uprlsts){
            if(!Alreadyexists.contains(Upr.Id)){
                for(ICIX_V1__Attribute__c c:attr){
                    ICIX_V1__UP_Relationship_Attribute__c a=new ICIX_V1__UP_Relationship_Attribute__c();
                    a.ICIX_V1__UP_Relationship__c=Upr.Id;
                    a.ICIX_V1__Attribute_Value__c=ResponsibleQE;
                    a.ICIX_V1__Attribute__c=c.id;
                    ReIds.add(Upr.ICIX_V1__Product__c);
                    ReUpr.add(Upr.Id);
                    Uprattriinsert.add(a);
                }
            }else{
                ReIds.add(Upr.ICIX_V1__Product__c);
                ReUpr.add(Upr.Id);
            }
        }
        RecursivePreventer.recursiveFlag=false;
        if(UprattriinsertAsst.size()>0){
            system.debug('UPR Tgas'+UprattriinsertAsst);
            database.insert(UprattriinsertAsst,false);
        }
        if(Uprattriinsert.size()>0){
            // insert Uprattriinsert;
            system.debug('Retail Item tags'+Uprattriinsert);
            Database.SaveResult[] srList=database.insert(Uprattriinsert,false);
            for (Database.SaveResult sr : srList) {
                if (sr.isSuccess()) {
                    // Operation was successful, so get the ID of the record that was processed
                    System.debug('Successfully inserted account. Account ID: ' + sr.getId());
                }
                else {
                    // Operation failed, so get all errors                
                    for(Database.Error err : sr.getErrors()) {
                        System.debug('The following error has occurred.');                    
                        System.debug(err.getStatusCode() + ': ' + err.getMessage());
                        System.debug('Account fields that affected this error: ' + err.getFields());
                    }
                }
            }
            system.debug('Calling Future Method');
            //Calling Future methods..Passing Retail Items Upr , Attribute Id and Facility Name as Parameters 
        } 
        if(FacilityName == 'All Trading Partners'){
       
             System.enqueueJob(new SyncRetailItemsQeQueueable(ReIds,ReUpr,AttrId,FacilityName));
        }
        else{
          MassQEController.SyncRetailItemsQE(ReIds,ReUpr,AttrId,FacilityName); 
        }
        return 'Updated successfully.';
    }
    //Asyncronous Processing of the Removal of Retail Items QE's
    @Future
    public static void SyncRetailItemsQE(set<Id> RetailId,set<Id> RetailUPRId,Id AttrId,string TradingPartnerName){
        system.debug('Retail Id==>'+RetailId);
        system.debug('Retail Id UPR==>'+RetailUPRId);
        system.debug('Retail Id UPR==>'+AttrId);
        system.debug('Trading Partner Name==>'+TradingPartnerName);
        list<ICIX_V1__PP_Relationship__c> pprel=[select id,ICIX_V1__Product1__c,ICIX_V1__Product2__c from ICIX_V1__PP_Relationship__c where ICIX_V1__Product2__c in :RetailId  and ICIX_V1__type__c='Component'];
        //map of Retail Item and Its Assortments...
        map<Id,List<Id>> MpRetailItemMap=new map<Id,List<Id>>();
        set<Id> AsstId=new set<Id>();
        for(ICIX_V1__PP_Relationship__c pp : pprel){
            if(pp.ICIX_V1__Product1__c!=null){
                //Adding All Assortment Product Id's in Set
                AsstId.add(pp.ICIX_V1__Product1__c);
                if(MpRetailItemMap.containskey(pp.ICIX_V1__Product2__c)){
                    list<Id> Aid=MpRetailItemMap.get(pp.ICIX_V1__Product2__c);
                    Aid.add(pp.ICIX_V1__Product1__c);
                    MpRetailItemMap.put(pp.ICIX_V1__Product2__c,Aid);
                }else{
                    list<Id> Aid=new List<Id>();
                    Aid.add(pp.ICIX_V1__Product1__c);
                    MpRetailItemMap.put(pp.ICIX_V1__Product2__c,Aid);
                }
            }
        }
        //Removing if any null is present
        AsstId.remove(null);
        //Querying the Attributes of the Retail Item Upr's
        list<ICIX_V1__UP_Relationship_Attribute__c> UpattrRetailItems=[select id,ICIX_V1__Attribute__c,ICIX_V1__Attribute__r.name,ICIX_V1__UP_Relationship__c,ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c from ICIX_V1__UP_Relationship_Attribute__c where ICIX_V1__UP_Relationship__c in:RetailUPRId and ICIX_V1__Attribute__r.ICIX_V1__type__c='Tag'];
        //Querying the Attributes of the Retail Item Upr's 
        list<ICIX_V1__UP_Relationship_Attribute__c> UpattrAst = new List<ICIX_V1__UP_Relationship_Attribute__c>();
        
       
         UpattrAst=[select id,ICIX_V1__Attribute__c,ICIX_V1__UP_Relationship__c,ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c,ICIX_V1__Attribute__r.name from ICIX_V1__UP_Relationship_Attribute__c where ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c in:AsstId and ICIX_V1__UP_Relationship__r.ICIX_V1__Related_Account__r.Facility_Name__c=:TradingPartnerName  and ICIX_V1__Attribute__r.ICIX_V1__type__c='Tag'];
           
       
            //Adding All the Assortment Id and list of Attribute names in the Map..Since an Assortment UPR contains only one Tag..unlike a Retail Item upr which can have multiple Tags of Responsible QE's.
        system.debug('Attribute Retail Items'+UpattrRetailItems);
        system.debug('Attribute Assortments==>'+UpattrAst);
        map<Id,List<String>> MpTag=new map<Id,List<String>>();
        for(ICIX_V1__UP_Relationship_Attribute__c uat :  UpattrAst){
            if(MpTag.containskey(uat.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c)){
                List<String> Strglst=MpTag.get(uat.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c);
                Strglst.add(uat.ICIX_V1__Attribute__r.name);
                MpTag.put(uat.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c,Strglst);
            }else{
                List<String> Strlst=new list<String>();
                Strlst.add(uat.ICIX_V1__Attribute__r.name);
                MpTag.put(uat.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c,Strlst);
            }
        }
        //Checking to Delete the Responsible QE tags of the Retail Items Upr's when it is not present in the Assortment UPR's of the Related Trading Partner..
        List<ICIX_V1__UP_Relationship_Attribute__c> ToDelete=new List<ICIX_V1__UP_Relationship_Attribute__c>();
        //Looping throgh the Retail Items UPR..
        for(ICIX_V1__UP_Relationship_Attribute__c uar : UpattrRetailItems){
            //Getting the Assortment under which the Retail Items are present..
            if(MpRetailItemMap.containskey(uar.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c)){
                List<Id> Aid=MpRetailItemMap.get(uar.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c);
                if(Aid.size()>0){
                    set<String> Strg=new set<String>();
                    system.debug('Assortment Ids==>'+Aid);
                    system.debug('Assortment Tags==>'+MpTag);
                    for(Id Ids : Aid){
                        if(MpTag.containskey(Ids)){
                            Strg.addAll(MpTag.get(Ids));
                        }
                    }
                    system.debug('Assortment Attributes==>'+Strg);
                    Strg.remove(null);
                    if(!Strg.contains(uar.ICIX_V1__Attribute__r.name)){
                        system.debug('To delete==>'+uar);
                        ToDelete.add(uar); 
                    }
                }
            }
        }
        system.debug('To delete the Attribytes==>'+ToDelete);
        //Deleting the Responsible QE tags which are not under any related Assortment Tags..
        Delete ToDelete;
    }
 
Hi,
I tried a lot but unable to cover below part.

Class:
public class testclassgenerator {
      
    public class ProductWrapper{
        public String productName {get;set;}
        public String internalClass {get;set;}
        public String brandName{get;set;}
        public String OrderNumber {get;set;}
        public String SoldToName {get;set;}
        public String ShipToCountry {get;set;}
        public String DeliveryDate {get;set;}
        public String ProductNumber {get;set;}
        public String FactoryName {get;set;}
        public String DaysRem {get;set;}
        public String EarliestExpDate {get;set;}
        public String TestReportID {get;set;}
        public String CPC {get;set;}
        public String DOC {get;set;}
        public String ukDOC {get;set;}
        public String ResponsibleQE{get;set;}
        public String CPCDocId{get;set;}
        public String DOCDocId{get;set;}
        public String ukDOCDocId{get;set;}
        public Date testDate{get;set;}
        public String ProductId{get;set;}
        public String ReqId{get;set;}
        public String CustomerName{get;set;}
        public String resultType{get;set;}
        public String responsibleQEId{get;set;}
        public String TestingStatus{get;set;}
       
    }
   public void execute(String dataSet,List<sObject> sObjectList,String insightExternalObjectId,Integer partNumber)
    {
        System.debug('List=>'+sObjectList);
        if(!sObjectList.isEmpty())
        {
            List<ICIX_V1_Purchase_Order__c> lstOrder = new List<ICIX_V1_Purchase_Order__c>();
            Set<Id> stOd = new Set<Id>();
            Set<Id> proSt = new Set<Id>();
            Set<Id> accId = new Set<Id>();
            Set<Id> RISet = new Set<Id>();
            Set<Id> MajorProd = new Set<Id>();
            Set<Id> SetParentProd = new Set<Id>();
            Set<Id> SetChildProd = new Set<Id>();
            Set<String> prodNum = new Set<String>();
            Set<Id> HPISt = new Set<Id>();
            Boolean isReqExpBlank = false;
            Boolean isExtend = false;
            lstOrder.addAll((List<ICIX_V1_Purchase_Order__c>)sObjectList);
            List<ICIX_V1_UP_Relationship__c> lstUPRNew = new List<ICIX_V1_UP_Relationship__c>();
            //List<ICIX_V1__Request__c> lstRequest = new List<ICIX_V1__Request__c>();
            List<Product2> lstAllProducts = new list<Product2>();
            List<Date> lstdateReq = new List<Date>();
            List<ProductWrapper> wrapperList = new List<ProductWrapper>();
            List<Id> extendedProductIdsList = new List<Id>();
            for(ICIX_V1_Purchase_Order__c obOrder : lstOrder)
            {
                stOd.add(obOrder.Id);
                accId.add(obOrder.ICIX_V1_Trading_Partner__c);
            }
           
           
            set<Id> tradingPartnersId = new set<Id>();
            List<ICIX_V1_Purchase_Order_Line_Item__c> lstOrderItem = [SELECT Id,
                                                                      
                                                                       ICIX_V1_Purchase_Order__c,ICIX_V1_ICIX_Product__c,
                                                                       ICIX_V1_ICIX_Product__r.Product_Number__c,ICIX_V1_ICIX_Product__r.Name,
                                                                    
                                                                       ICIX_V1_ICIX_Product_Relationship__c,
                                                                    
                                                                       ICIX_V1_Status__c,ICIX_V1_Purchase_Order__r.ICIX_V1_Trading_Partner__c
                                                                       FROM ICIX_V1_Purchase_Order_Line_Item__c
                                                                       where ICIX_V1_Purchase_Order__c in : stOd];
            if(lstOrderItem.size() > 0)
            {
                for(ICIX_V1_Purchase_Order_Line_Item__c obItem : lstOrderItem)
                {
                    proSt.add(obItem.ICIX_V1_ICIX_Product__c);  
                    prodNum.add(obItem.ICIX_V1_ICIX_Product__r.Product_Number__c);
                    tradingPartnersId.add(obItem.ICIX_V1_Purchase_Order__r.ICIX_V1_Trading_Partner__c);
                }
            }
}
}
           

Test class:

@isTest
private class testclassgenerator_Test{
  @testSetup
  static void setupTestData(){
    test.startTest();
      //creating account
    Account account_Obj = new Account(Name = 'Name783', Type = 'Prospect', Facility_Name__c = 'Facil788', ICIX_V1_Status__c = 'Active', ICIX_V1_ICIX_ID__c = 'ICIX_480');
    Insert account_Obj;   
     
    // Creating Products      
    Product2 product2_Obj = new Product2(Name = 'Name381',Global_SKU__c = 'C1918', Manual_Product__c = true, Parent_Number__c = '21', Product_Number__c = '22', Product_Status__c = '23', ProductType__c = 'RETAILITEM', Responsible_QE__c = 'Picklist01');
    Insert product2_Obj; 
    Product2 product2_Obj1 = new Product2(Name = 'Name381', Global_SKU__c = 'C1918', Manual_Product__c = true, Parent_Number__c = '21', Product_Number__c = '22', Product_Status__c = '23', ProductType__c = '24', Responsible_QE__c = 'Picklist01');
    Insert product2_Obj1; 
        ICIX_V1_UP_Relationship__c icix_v1_up_relationship_Obj = new ICIX_V1_UP_Relationship__c(Name = 'Name842', Trading_Partner__c = account_Obj.id, ICIX_V1_Type__c = 'Sell', ICIX_V1_Status__c = 'Suspended', IXIX_V1_Product__c = product2_Obj.id);
    Insert icix_v1_up_relationship_Obj; 
    ICIX_V1_Attribute__c icix_v1_attribute_Obj = new ICIX_V1_Attribute__c(Name = 'Name409', ICIX_V1_Type__c = 'Attribute', ICIX_V1__c = 'Text', ICIX_V1_Relationship_Types_List__c = 'Product');
    Insert icix_v1_attribute_Obj; 
    ICIX_V1_Purchase_Order__c icix_v1_purchase_order_Obj = new ICIX_V1_Purchase_Order__c(Name = 'Name571', ICIX_V1_Trading_Partner__c = account_Obj.id, ICIX_V1_PO_Status__c = 'Open', ICIX_V1_PO_Number__c = 'ICIX_651', ICIX_V1_External_Id__c = 'ICIX_463');
    Insert icix_v1_purchase_order_Obj; 
    ICIX_V1_Purchase_Order_Line_Item__c icix_v1_purchase_order_line_item_Obj = new ICIX_V1_Purchase_Order_Line_Item__c(Name = 'Name824', ICIX_V1_Certificate_Generated__c = false, ICIX_V1_ICIX_Product__c = product2_Obj.id, ICIX_V1_ICIX_Product_Relationship__c = icix_v1_up_relationship_Obj.id, ICIX_V1_Purchase_Order__c = icix_v1_purchase_order_Obj.id, ICIX_V1_Quantity__c = 16, ICIX_V1_Status__c = 'Open', ICIX_V1_Test_Request_Trading_Partner__c = account_Obj.id);
    Insert icix_v1_purchase_order_line_item_Obj; 
    test.stopTest();
  }
  static testMethod void test_SyncRetailItemsQE_UseCase1(){
      List<ICIX_V1_UP_Relationship__c> icix_v1_up_relationship_Obj  =  [SELECT Id,Name,Trading_Partner__c,ICIX_V1_Type__c,ICIX_V1_Status__c,IXIX_V1_Product__c,Product_Type__c from ICIX_V1_UP_Relationship__c];
    System.assertEquals(true,icix_v1_up_relationship_Obj.size()>0);
    List<ICIX_V1_Attribute__c> icix_v1_attribute_Obj  =  [SELECT Id,Name,ICIX_V1_Type__c,ICIX_V1__c,ICIX_V1_Relationship_Types_List__c from ICIX_V1_Attribute__c];
    System.assertEquals(true,icix_v1_attribute_Obj.size()>0);
    List<ICIX_V1_Purchase_Order__c> icix_v1_purchase_order_Obj  =  [SELECT Id,Name,ICIX_V1_Trading_Partner__c,ICIX_V1_Test_Request_Trading_Partner__c,ICIX_V1_PO_Status__c,ICIX_V1_PO_Number__c,ICIX_V1_External_Id__c from ICIX_V1_Purchase_Order__c];
    System.assertEquals(true,icix_v1_purchase_order_Obj.size()>0);
    List<ICIX_V1_Purchase_Order_Line_Item__c> icix_v1_purchase_order_line_item_Obj  =  [SELECT Id,Name,ICIX_V1_Certificate_Generated__c,ICIX_V1_ICIX_Product__c,ICIX_V1_ICIX_Product_Relationship__c,ICIX_V1_Purchase_Order__c,ICIX_V1_Quantity__c,ICIX_V1_Status__c,ICIX_V1_Test_Request_Trading_Partner__c from ICIX_V1_Purchase_Order_Line_Item__c];
    System.assertEquals(true,icix_v1_purchase_order_line_item_Obj.size()>0);
      
    testclassgenerator obj01 = new testclassgenerator();
    obj01.execute('Test',new List<ICIX_V1_Purchase_Order_Line_Item__c>(),'test',1);
  }
}
I have tried to cover below class but unable to cover even single % . Unable to figure out where/what I missed, Please anyone help me

Apex:

public with sharing class customSearchController { public static list<ICIX_V1__ICIX_Product__c> getContactList(string searchKey,string productType) { string sTempSearchKey = '%' + searchKey + '%'; //string sTempSearchKey = '%' + searchKey; // create Product list to store search result list<ICIX_V1__ICIX_Product__c> lstProduct = new list<ICIX_V1__ICIX_Product__c>(); // query Product records for(ICIX_V1__ICIX_Product__c oCon : [Select id,Name,Product_Number__c,ProductType__c,Parent_Name__c From ICIX_V1__ICIX_Product__c WHERE Product_Number__c LIKE : sTempSearchKey and ProductType__c=:productType limit 10]){ lstProduct.add(oCon);
}
return lstProduct;
} }

Test class:

@isTest public class customSearchController_Test { static testMethod void getContactListMethod() { try{ list<Account> acclist=new list<Account>(); Account acc=new Account(); acc.name='Hasbro Dev Stg Res 2'; acc.ICIX_V1__Status__c='Active'; acc.ICIX_V1__ICIX_ID__c='304078'; //acc.ICIX_V1__Internal__c=true; acclist.add(acc); insert acclist; string searchKey; string productType; list<ICIX_V1__ICIX_Product__c> lstProduct = new list<ICIX_V1__ICIX_Product__c>(); string sTempSearchKey = '%' + searchKey + '%'; ICIX_V1__ICIX_Product__c product1=Hasbro_TestDataFactory.createProduct()[0]; product1.Product_Number__c='C6119AV10'; product1.ProductType__c='ASSORTMENT'; lstProduct.add(product1); ICIX_V1__ICIX_Product__c product2=Hasbro_TestDataFactory.NewProduct(); product2.Product_Number__c='C6119AV10'; product2.ProductType__c='ASSORTMENT'; lstProduct.add(product2); insert lstProduct; customSearchController.getContactList('product2.Product_Number__c','product2.ProductType__c'); } catch(Exception e){
} } }


 
I have two triggers , I need to merge these two trigger into one trigger. Can anybody please help me on that.

Trigger 1:

trigger APTS_AgreementTrigger on Apttus__APTS_Agreement__c (after update, before update) { System.Debug('APTS_AgreementTrigger: Entering'); public static boolean createCase = true; public static boolean runOnce = true; APTS_AgreementTriggerHandler handler = new APTS_AgreementTriggerHandler(); //After Update logic if(Trigger.isUpdate && Trigger.isAfter){ if(runOnce){ handler.handleAfterUpdateEvents(Trigger.newMap, trigger.new, Trigger.oldMap); runOnce = false; } } //------------------------------------------------------------------------------- System.Debug('Checking for Trigger Status: isInsert:' + Trigger.isInsert + ' isBefore:' + Trigger.isBefore + ' isAfter:' + Trigger.isAfter + ' isUpdate: ' + Trigger.isUpdate ); final static string PMODTRIGGERCONTROL = 'P-MOD TRIGGER CONTROL'; //Trigger control - proceed if trigger switched ON if(ActiveTriggers__c.getInstance(PMODTRIGGERCONTROL) != null && ActiveTriggers__c.getInstance(PMODTRIGGERCONTROL).APTS_AgreementTrigger__c) { //Create a Case for any agreement generated from Aurora Integration System.Debug('Calling to Create a Case for integration request : createCase : ' + createCase); System.Debug('Checking for Trigger Status: : runonce : ' + runOnce + ' isInsert ' + Trigger.isInsert + ' : isAfter ' + + Trigger.isAfter + ' : isUpdate ' + + Trigger.isUpdate + ' : ' ); if(createCase) { //if(Trigger.isUpdate && Trigger.isAfter) if(Trigger.isUpdate && Trigger.isBefore) { System.Debug('Trigger.isInsert && Trigger.isBefore'); //System.Debug('Trigger.isInsert && Trigger.isAfter'); List<Apttus__APTS_Agreement__c> agreementList = trigger.new; System.Debug('List of Agreement requires Case : Total : ' + agreementList.size() + ' : ' + agreementList ); //call future method if ( agreementList != null && agreementList.size() > 0 ) { System.Debug('Calling future case method'); AgreementCustomerHelper_Cardinal.createCase(trigger.new); System.Debug('Completed future case method'); createCase = false; } } } } System.Debug('APTS_AgreementTrigger: Exiting'); //------------------------------------------------------------------------------- }

Trigger 2:

trigger APTS_AgreementAccountShare on Apttus__APTS_Agreement__c (after Update, after insert) { if( Trigger.isAfter) { Map<String,Apttus__APTS_Agreement__c> agreementIDMap1 = new Map<String,Apttus__APTS_Agreement__c>(); set<String> accountid = new set<String>(); //Account Team Member and AgreementSharing Memember for(Apttus__APTS_Agreement__c eachAgreement: Trigger.new ) { if(eachAgreement.Apttus__Account__c != null) { if(Trigger.isUpdate) { if(eachAgreement.Apttus__Account__c != Trigger.oldMap.get(eachAgreement.Id).Apttus__Account__c) { agreementIDMap1.put(eachAgreement.Id, eachAgreement); accountid.add(eachAgreement.Apttus__Account__c); } }else if ( Trigger.isInsert) { agreementIDMap1.put(eachAgreement.Id, eachAgreement); accountid.add(eachAgreement.Apttus__Account__c); } } } if(accountid != null ) { List <Apttus__APTS_Agreement__Share> agrmShareDelete = [SELECT ID, UserOrGroupId,ParentId FROM Apttus__APTS_Agreement__Share WHERE ParentId IN : agreementIDMap1.keySet() AND rowCause =: Schema.Apttus__APTS_Agreement__Share.RowCause.AgsSharing__c ]; if(agrmShareDelete != null ) { APTS_AgreementAccountShareClass.deletingAgreementShare(agrmShareDelete); } List<AccountTeamMember> listaccTm = [SELECT ID, UserId , AccountId FROM AccountTeamMember WHERE AccountId IN: accountid ]; if( listaccTm != null) { APTS_AgreementAccountShareClass.agreementSharingAddition(agreementIDMap1.values(),listaccTm); } } } }
 

Use Case: If I update a Agreement record ,then all the related Agreements to be updated with Termination Date on Parent agreement record.
On Agreement we have Relationship from and Relationship To Related list.  All the Child records will be created in Relationship From Related List. Parent record will appear in Relationship To Related List.This is nothing but Related agreement records and these are Related Agreement object. On Related Agreement we have Relationship from and Relationship To Lookup fields. Relationship from is the parent agreement record and Relationship To is child Agreement Record.
If we Update Parent agreement then agreement(child agreement) should be updated with same Termination date field value on Parent.
I have created this trigger but am getting 0 rows at line # 16 and null value @11
Class:
public class TerminationDate { public static Boolean isFirstTime = true; }
trigger TerminationDateOnParent on Apttus__APTS_Agreement__c (after insert,after update) {

    if(TerminationDate.isFirstTime){
        TerminationDate.isFirstTime = false;

        Map<Id,Date> acc = new Map<Id,Date>();
        for(Apttus__APTS_Agreement__c a:Trigger.New)    {
    if(a.Apttus__Status_Category__c=='Terminated') {
        Apttus__APTS_Related_Agreement__c ar=new Apttus__APTS_Related_Agreement__c();
        acc.put(a.id,ar.Apttus__APTS_Contract_From__r.CLM_Agreement_Termination_Date__c);
        system.debug(acc);
    }
}
   
        
 List<Apttus__APTS_Related_Agreement__c> relagrmt=[select id,Name,Apttus__APTS_Contract_From__r.id,Apttus__APTS_Contract_To__r.id,Apttus__APTS_Contract_From__r.CLM_Agreement_Termination_Date__c,Apttus__APTS_Contract_To__r.CLM_Agreement_Termination_Date__c,Apttus__APTS_Contract_To__r.Name from Apttus__APTS_Related_Agreement__c where id in:acc.keyset()];
       
        for(Apttus__APTS_Related_Agreement__c ag:relagrmt){
            ag.Apttus__APTS_Contract_To__r.CLM_Agreement_Termination_Date__c=acc.get(ag.id);
            system.debug(ag.Apttus__APTS_Contract_To__r.CLM_Agreement_Termination_Date__c);
            
    update ag;
    system.debug(ag);
}
    
    }
}
I have object called Agreement.
One agreement will have mutliple child agreements.
we  have a Parent Agreement lookup field on Child Agreement with Parent agreement value.

When Status category of Child agreement is Terminated, then on Parent agreement Status category and Termination date should be updated as child record.

The issue is am not getting Parent id from my trigger. So its not updating on Parent record eventhough my if condition satisfied.

Class:
public class UpdateTerminationDate {
public static Boolean isFirstTime = true;
   
          }    
 

Trigger:

trigger UpdateTerminationDateTrigger on Apttus__APTS_Agreement__c (after insert,after update) {
     public static Boolean bool = true;
    If(UpdateTerminationDate.isFirstTime){
        UpdateTerminationDate.isFirstTime = false;
   
   
    List<Apttus__APTS_Agreement__c> agr=new List<Apttus__APTS_Agreement__c>();
     List<id> acc=new List<id>();
    for(Apttus__APTS_Agreement__c a:Trigger.New)
    {
        acc.add(a.id);
        system.debug(acc);
    }

    List<Apttus__APTS_Agreement__c> agreement = [select id,Name,Apttus__Parent_Agreement__r.Apttus__Status_Category__c,CLM_Agreement_Termination_Date__c,Apttus__Parent_Agreement__r.CLM_Agreement_Termination_Date__c,Apttus__Parent_Agreement__c,Apttus__Status_Category__c,Apttus__Status__c,Apttus__Parent_Agreement__r.Apttus__Status__c from Apttus__APTS_Agreement__c where id in: acc];    
    
    for(Apttus__APTS_Agreement__c ag:agreement){
        system.debug(ag.Apttus__Parent_Agreement__r.CLM_Agreement_Termination_Date__c);
        if(ag.Apttus__Status_Category__c=='Terminated')
            {
                ag.Apttus__Parent_Agreement__r.CLM_Agreement_Termination_Date__c=ag.CLM_Agreement_Termination_Date__c;
               //ag.Apttus__Status_Category__c=ag.Apttus__Parent_Agreement__r.Apttus__Status_Category__c;
               //ag.Apttus__Status__c='Terminated';
               
                system.debug('test');
              system.debug(ag.Apttus__Parent_Agreement__r.CLM_Agreement_Termination_Date__c);
                system.debug(ag.CLM_Agreement_Termination_Date__c);
                agr.add(ag);
                
            }
        
        update ag;
        }
     
      update agr;
        system.debug(agr);
    
    }
  }

Isuue is both  agr id and ag id are same(child agreement id)
Hi ,
I have created a Lightning component and I am calling that from Quick action.
I have a validation rule that will throw an error and restrict a user to make changes on a record when Record_Locked field is true. But When validation rule is Active, Success part is not working instead else part is working. If I deactivated a validation rule then IF part is working fine.
Can anyone help me on this if I missed anything?

Class: 

public class ArchiveRecord {

    @AuraEnabled
    public static void getItemSetupForm(Id itemsetupId){
        Item_Setup__c itemsetup= [Select Id, Name,Processed__c,Item_Setup_Form_Status__c from Item_Setup__c where Id=:itemsetupId and Item_Setup_Form_Status__c!='Archived'];
        itemsetup.Item_Setup_Form_Status__c='Archived';
        update itemsetup;
        
        if(itemsetup.Item_Setup_Form_Status__c=='Archived'){
          itemsetup.Name=itemsetup.Name +'_Archived';
        }
        upsert itemsetup;
}

}

Component:
<aura:component controller="ArchiveRecord" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickActionWithoutHeader" access="global">
   <aura:html tag="style">
        .cuf-content {
        padding: 0 0rem !important;
        }
        .slds-p-around--medium {
        padding: 0rem !important;
        }       
        .slds-modal__content{
        overflow-y:hidden !important;
        height:unset !important;
        max-height:unset !important;
        }
    </aura:html>
    
    <aura:attribute name="showSpinner" type="boolean" />
    <aura:attribute name="accessFlag" type="boolean"/>
    <aura:attribute name="noAccessFlag" type="boolean"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:if isTrue="{!v.accessFlag}">
     <div class="modal-header slds-modal__header slds-size_1-of-1">
        <h4 class="title slds-text-heading--medium">Archive</h4>
    </div>
    <!--End Modal Header--> 
     
    <!--Modal Body-->  
    <div class="slds-modal__content slds-p-around--x-large slds-align_absolute-center slds-size_1-of-1 slds-is-relative">
        <form class="slds-form--stacked">
           
                <div class="slds-align_absolute-center">
                    <b>Do you want to Archive this record?</b>
                </div>            
            
        </form> 
    </div>
    <!--End of Modal Body-->
     
    <!--Modal Footer-->
    <div class="modal-footer slds-modal__footer slds-size_1-of-1">
        <lightning:button variant="Neutral" class="slds-button" label="Cancel" onclick="{!c.cancelBtn}"/>
        <lightning:button variant="Brand" class="slds-button" label="Continue" onclick="{!c.updateStatus}"/>
        
    </div>
        
    </aura:if>
    
     <aura:if isTrue="{!v.noAccessFlag}">
         
     <div class="modal-header slds-modal__header slds-size_1-of-1">
        <h4 class="title slds-text-heading--medium">Archive</h4>
    </div>
    <!--End Modal Header--> 
     
    <!--Modal Body-->  
    <div class="slds-modal__content slds-p-around--x-large slds-align_absolute-center slds-size_1-of-1 slds-is-relative">
        <form class="slds-form--stacked">
           
                <div class="slds-align_absolute-center slds-text-color_error">
                    <b>You Don't Have Permission to Archive this Record</b>
                </div>            
            
        </form> 
    </div>
    <!--End of Modal Body-->
     
    <!--Modal Footer-->
    <div class="modal-footer slds-modal__footer slds-size_1-of-1">
        <lightning:button variant="Neutral" class="slds-button" label="Cancel" onclick="{!c.cancelBtn}"/>
        
    </div>
    </aura:if>
    
    <aura:if isTrue="{!v.showSpinner}">
        <lightning:spinner variant="brand" alternativeText="Loading" />
    </aura:if>
</aura:component>

Controller:


({
    updateStatus : function(component, event, helper) {
    var itemsetupId=component.get("v.recordId");
        var action=component.get("c.getItemSetupForm");
        action.setParams({"itemsetupId":itemsetupId
            
        });
        action.setCallback(this,function(response){
            
            var state=response.getState();
            if(state==="SUCCESS"){
               let toastEvent = $A.get("e.force:showToast");
                toastEvent.setParams({
                    "title": "Success!",
                    "message": "The record Archived Successfully",
                    "type": "success"   
                });
                toastEvent.fire();
            }
             else if (state === "ERROR")
        {
            alert("You can't make any changes on Archived Record");
        }
              var dismissActionPanel = $A.get("e.force:closeQuickAction");
                dismissActionPanel.fire();  
              $A.get('e.force:refreshView').fire();
             component.set("v.showSpinner",false);
        });
        $A.enqueueAction(action);
    },

    cancelBtn : function(component, event, helper) {
        // Close the action panel
        var dismissActionPanel = $A.get("e.force:closeQuickAction");
        dismissActionPanel.fire();
    },
     // Checking user access for creating new version record
    doInit: function(component, event, helper){ 
         component.set("v.showSpinner",true);
        var action = component.get("c.checkUserValidity");
        action.setCallback(this, function(response){
           var state = response.getState();
            if(state === "SUCCESS"){
                if(response.getReturnValue()){
                   component.set("v.accessFlag", true); 
                }
                else{
                  component.set("v.noAccessFlag", true);  
                    
                }
                component.set("v.showSpinner",false); 
            }
            
        });
       
        $A.enqueueAction(action);
        
    }
    
})


Validation rule:
condition:  Record_Locked__c =true
error message : The Record Archived, You can't make any changes.
Hi,
Here is the usecase.
On Opportunity record, I want to show a Archive button. Onclick of the Archive button a prompt must display “Do you want to Archive the record?” , Cancel and Continue button must be displayed. Onclick of Cancel button the prompt must be closed.
Onclick of the Continue button the status of the record must be updated as ‘Archived’ and the Name of the record must be appended with ‘_Archived’. How can achieve this use case?
I have tried to create a flow and called from Quick action, but in flow i am not able to update a Status field? Does Lightning component required to achieve this case?
I have created a test class for batch class. But Execute method is not covering even single line. Could anypne help me on this?

Class:
public class UPRSync implements Database.Batchable<sObject>,Database.stateful{
    public string AssortmentId;
    public String InputQuery;
    public UPRSync(String Query1){
        AssortmentId='NA';
        InputQuery=Query1;
    }
    public UPRSync(Id AssortId){
        AssortmentId='NAS';
        AssortmentId=AssortId;
    }
    public Database.QueryLocator start(Database.BatchableContext BC){
        Datetime hourBack = Datetime.now().addMinutes(-60);
        String Query;
        system.debug(AssortmentId);
        if(AssortmentId=='NA'){
            Query=InputQuery;
        }else{
            system.debug('AssortmentId==>'+AssortmentId);
            Query='select ICIX_V1__Product1__c,ICIX_V1__Product2__c from ICIX_V1__PP_Relationship__c where ICIX_V1__Product2__c !=null and  ICIX_V1__Type__c=\'component\' and ICIX_V1__Product1__c=:AssortmentId';
        }
        return Database.getQueryLocator(Query);
    }
    public void execute(Database.BatchableContext BC, List<ICIX_V1__PP_Relationship__c> scope){
        //Assortment or Solid Ids
        Set<Id> AsstId=new set<Id>();
        for(ICIX_V1__PP_Relationship__c pp : Scope){
            AsstId.add(pp.ICIX_V1__Product1__c);
        }
        AsstId.remove(null);
        List<ICIX_V1__ICIX_Product__c> Scope1=[Select Id,Name from ICIX_V1__ICIX_Product__c where Id in : AsstId];
        set<Id> AllIds=new set<Id>();
        map<Id,List<Id>> MpPP=new map<Id,List<Id>>();
        for(ICIX_V1__PP_Relationship__c pp : [select ICIX_V1__Product1__c,ICIX_V1__Product2__c from ICIX_V1__PP_Relationship__c where ICIX_V1__Product2__c !=null and ICIX_V1__Product1__c in: AsstId and ICIX_V1__Type__c='component'] ){
            AllIds.add(pp.ICIX_V1__Product1__c);
            AllIds.add(pp.ICIX_V1__Product2__c);
            //Creating a map of Assortment/Solid and its Retail items
            if(MpPP.containskey(pp.ICIX_V1__Product1__c)){
                MpPP.get(pp.ICIX_V1__Product1__c).add(pp.ICIX_V1__Product2__c);
            }else{
                MpPP.put(pp.ICIX_V1__Product1__c, new list<Id> { pp.ICIX_V1__Product2__c });
            }
        }
        map<Id,ICIX_V1__ICIX_Product__c> Mpprod=new map<Id,ICIX_V1__ICIX_Product__c>([Select id,name from ICIX_V1__ICIX_Product__c where Id in : AllIds]);
        Id InternalAccId=[select Id from Account where ICIX_V1__Internal__c=true].Id;
        AllIds.remove(null);
        //Map of Product and 
        map<Id,List<ICIX_V1__UP_Relationship__c>> MpUprs=new map<Id,List<ICIX_V1__UP_Relationship__c>>();
        List<ICIX_V1__UP_Relationship__c> Uprlst=[select Id,ICIX_V1__Related_Account__c,ICIX_V1__Product__c from ICIX_V1__UP_Relationship__c where ICIX_V1__Product__c in : AllIds ];
        //Capturing the Product and its upr in a map..
        for(ICIX_V1__UP_Relationship__c upr : Uprlst){
            if(MpUprs.containskey(upr.ICIX_V1__Product__c)){
                MpUprs.get(upr.ICIX_V1__Product__c).add(upr);
            }else{
                MpUprs.put(upr.ICIX_V1__Product__c, new list<ICIX_V1__UP_Relationship__c> { upr });
            }
        }
        //List to Insert..
        List<ICIX_V1__UP_Relationship__c> UprlsttoUpdate=new List<ICIX_V1__UP_Relationship__c>();
        List<ICIX_V1__UP_Relationship__c> UprlsttoUpdateset=new List<ICIX_V1__UP_Relationship__c>();
        List<ICIX_V1__UP_Relationship__c> UprlsttoInsertset=new List<ICIX_V1__UP_Relationship__c>();
        for(ICIX_V1__ICIX_Product__c Prd : scope1){
            if(MpPP.containskey(Prd.Id)){
                List<Id> RetailIds=MpPP.get(Prd.Id);
                for(Id Rid: RetailIds){
                    list<ICIX_V1__UP_Relationship__c> UpAsst=MpUprs.get(Prd.Id);
                    list<ICIX_V1__UP_Relationship__c> REuprs=MpUprs.get(Rid);
                    system.debug('Retail Item Ids==>'+Rid);
                    system.debug('Upr Ids==>'+UpAsst.Size());
                    system.debug('Retail Upr Ids==>'+REuprs.size());
                    set<Id> TradingPartners=new set<Id>();
                    Id BlankUpr; 
                    Boolean populateUpr=false;
                    for(ICIX_V1__UP_Relationship__c upr : REuprs){
                        if(upr.ICIX_V1__Related_Account__c==null){
                            BlankUpr=upr.Id;
                            populateUpr=true;
                        }else{
                            TradingPartners.add(upr.ICIX_V1__Related_Account__c);  
                        }
                    }
                    system.debug('Trading Partners size==>'+TradingPartners.size());
                    for(ICIX_V1__UP_Relationship__c uprAt : UpAsst){
                        if(populateUpr){
                            ICIX_V1__UP_Relationship__c upt=new ICIX_V1__UP_Relationship__c();
                            upt.Id=BlankUpr;
                            upt.ICIX_V1__Related_Account__c=uprAt.ICIX_V1__Related_Account__c;
                            UprlsttoUpdateset.add(upt);
                            populateUpr=false;
                        }
                        if(!populateUpr){
                            if(!TradingPartners.contains(uprAt.ICIX_V1__Related_Account__c)){
                                system.debug('Inside');
                                ICIX_V1__UP_Relationship__c uprIn=new ICIX_V1__UP_Relationship__c();
                                uprIn.Name=Mpprod.get(Rid).Name;
                                uprIn.ICIX_V1__Related_Account__c=uprAt.ICIX_V1__Related_Account__c;
                                uprIn.ICIX_V1__Product__c=Rid;
                                uprIn.ICIX_V1__Status__c='Active';
                                uprIn.ICIX_V1__Type__c='Buy';
                                uprIn.ICIX_V1__UBE__c=InternalAccId;
                                
                                UprlsttoInsertset.add(uprIn); 
                                
                            } 
                        }
                    }
                }
            }
        }
        if(!UprlsttoUpdateset.Isempty()){
            RecursivePreventer.recursiveFlag=false;
            for(ICIX_V1__UP_Relationship__c uprt : UprlsttoUpdateset){
                if(uprt.ICIX_V1__Related_Account__c!=null){
                    UprlsttoUpdate.add(uprt);
                }
            }
            database.update(UprlsttoUpdate,false);
        }
        if(!UprlsttoInsertset.Isempty()){
            
            RecursivePreventer.recursiveFlag=false;
            List<ICIX_V1__UP_Relationship__c> UprlsttoInsert=new List<ICIX_V1__UP_Relationship__c>();
            for(ICIX_V1__UP_Relationship__c uprt : UprlsttoInsertset){
                if(uprt.ICIX_V1__Related_Account__c!=null){
                    UprlsttoInsert.add(uprt);
                }
            }
            
            database.insert(UprlsttoInsert,false);
            //Logic for Querying the Attributes and Non Universal Id..
            map<Id,List<Id>> MpInsert=new map<Id,List<Id>>();
            set<Id> NewUprIds=new set<Id>();
            Map<Id, Id> uprIdVsProductIdMap = new Map<Id, Id>();
            for(ICIX_V1__UP_Relationship__c upc : UprlsttoInsert){
                NewUprIds.add(upc.Id);
                uprIdVsProductIdMap.put(upc.Id, upc.ICIX_V1__Product__c);
                if(MpInsert.containskey(upc.ICIX_V1__Product__c)){
                    MpInsert.get(upc.ICIX_V1__Product__c).add(upc.Id);
                }else{
                    MpInsert.put(upc.ICIX_V1__Product__c, new list<Id> { upc.Id });
                }
            }
            NewUprIds.remove(null);
            map<Id,Id> mpUprF=new map<Id,Id>();
            for(ICIX_V1__UP_Relationship__c upr :[select id,ICIX_V1__Product__c,ICIX_V1__Related_Account__c from ICIX_V1__UP_Relationship__c where ICIX_V1__Product__c in : AllIds and ICIX_V1__Related_Account__c!=null and  Id not in : NewUprIds] ){
                mpUprF.put(upr.ICIX_V1__Product__c,upr.Id);
            }
            List<ICIX_V1__UP_Relationship_Attribute__c> uprlsts=new list<ICIX_V1__UP_Relationship_Attribute__c>();
            list<ICIX_V1__Product_Non_Universal_Id__c> ProdNonId=new List<ICIX_V1__Product_Non_Universal_Id__c>();
            map<string,ICIX_V1__UP_Relationship_Attribute__c> MpAttr=new map<string,ICIX_V1__UP_Relationship_Attribute__c>();
            map<string,ICIX_V1__Product_Non_Universal_Id__c> MpNon=new map<string,ICIX_V1__Product_Non_Universal_Id__c>();
            List<ICIX_V1__UP_Relationship_Attribute__c> UprAlst=[select id,ICIX_V1__Attribute__c,ICIX_V1__Attribute_Value__c,ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c,ICIX_V1__UP_Relationship__c from ICIX_V1__UP_Relationship_Attribute__c where ICIX_V1__UP_Relationship__c in : mpUprF.values() and ICIX_V1__Attribute__r.ICIX_V1__Type__c='Attribute'];
            for(ICIX_V1__UP_Relationship_Attribute__c upra: UprAlst){
                MpAttr.put(upra.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c+'-'+upra.ICIX_V1__Attribute__c,upra);
            }
            List<ICIX_V1__Product_Non_Universal_Id__c> ProdNonLst=[select id,ICIX_V1__Id_Type__c,ICIX_V1__Id_Value__c,ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c from ICIX_V1__Product_Non_Universal_Id__c where ICIX_V1__UP_Relationship__c in : mpUprF.values()];
            for(ICIX_V1__Product_Non_Universal_Id__c upra: ProdNonLst){
                MpNon.put(upra.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c+'-'+upra.ICIX_V1__Id_Type__c,upra);
            }
            Hasbro_UpRelationshipTriggerHelper.FirstRun=false;
            for(ICIX_V1__UP_Relationship_Attribute__c uprt: MpAttr.values()){
                if(MpInsert.containskey(uprt.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c)){
                    List<Id> Uprids=MpInsert.get(uprt.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c);
                    for(Id Ids : Uprids){
                        if(Ids!=null){
                            system.debug('====Upr ids=='+ids);
                            ICIX_V1__UP_Relationship_Attribute__c Upra=new ICIX_V1__UP_Relationship_Attribute__c();
                            //Upra.name=ids;
                            Upra.ICIX_V1__Attribute_Value__c=uprt.ICIX_V1__Attribute_Value__c;
                            Upra.ICIX_V1__Attribute__c=uprt.ICIX_V1__Attribute__c;
                            Upra.ICIX_V1__UP_Relationship__c=ids;
                            uprlsts.add(Upra);
                        }
                    }
                }
            }
            Insert uprlsts;//Inserting Product Attributes
            List<Id> prodNonUniIdUprIdList = new List<Id>();
            for(ICIX_V1__Product_Non_Universal_Id__c PnID : MpNon.values() ){
                if(MpInsert.containskey(PnID.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c)){
                    List<Id> Uprids=MpInsert.get(PnID.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c);
                    for(Id Ids : Uprids){
                        if(ids!=null){
                            system.debug('=======>ppnon uid'+ids);
                            ICIX_V1__Product_Non_Universal_Id__c Pid=new ICIX_V1__Product_Non_Universal_Id__c();
                            Pid.ICIX_V1__Id_Type__c=PnID.ICIX_V1__Id_Type__c;
                            pid.ICIX_V1__Id_Value__c=PnID.ICIX_V1__Id_Value__c;
                            pid.ICIX_V1__UP_Relationship__c=Ids;
                            prodNonUniIdUprIdList.add(Ids);
                            ProdNonId.add(Pid);
                        }
                    }
                }
            }
            
            
            List<ICIX_V1__ICIX_Product__c> productsList = [SELECT Id, ICIX_V1__External_Id__c FROM ICIX_V1__ICIX_Product__c WHERE Id IN: MpInsert.keySet() AND ICIX_V1__External_Id__c != null];
            Map<String, String> productIdVsExternalIdMap = new Map<String, String>();
            
            if(productsList.size()>0){
                for(ICIX_V1__ICIX_Product__c pro: productsList){
                    productIdVsExternalIdMap.put(pro.Id, pro.ICIX_V1__External_Id__c);
                    
                }
                
            }
            
            ICIX_V1__Id_Type__c idType = [SELECT Id, Name, ICIX_V1__Type__c, ICIX_V1__Unique_Id__c
                                          FROM ICIX_V1__Id_Type__c
                                          WHERE ICIX_V1__Unique_Id__c = 'ITEM_N'
                                          AND ICIX_V1__Type__c = 'NonUniversal' LIMIT 1];
            System.debug('=========idType========'+idType);
            
            if(idType != null){
                
                for(ICIX_V1__UP_Relationship__c uprId: UprlsttoInsert){
                    if(uprId.Id != null){
                    if(!prodNonUniIdUprIdList.contains(uprId.Id)){
                        if(uprIdVsProductIdMap.containsKey(uprId.Id) && productIdVsExternalIdMap.containsKey(uprIdVsProductIdMap.get(uprId.Id))){
                        
                        ICIX_V1__Product_Non_Universal_Id__c PnuId = new ICIX_V1__Product_Non_Universal_Id__c();
                        PnuId.ICIX_V1__Id_Type__c = idType.Id;
                        PnuId.ICIX_V1__Id_Value__c = productIdVsExternalIdMap.get(uprIdVsProductIdMap.get(uprId.Id));
                        PnuId.ICIX_V1__UP_Relationship__c = uprId.Id;
                        
                        ProdNonId.add(PnuId);
                        
                        
                    }
                    
                    }
                    } 
                }
                
                
                
                
            }
            
            
            if(ProdNonId.size()>0){
                
                insert ProdNonId;//Inserting Product Non Universal Ids
            }
        }
    }
    public void finish(Database.BatchableContext BC){
    }
}

Test class:
@isTest
Public class UPRSync_Test{
    @isTest Static void testUPRSync(){
        try{
        //Create TheCustom settings
        PP_Deletion_Batch__c pp_del=new PP_Deletion_Batch__c();
        pp_del.name='PPDeletionBatch';
        pp_del.Is_Processed__c=true;
        insert pp_del;
        //create Account
        list<Account> accs=Hasbro_TestDataFactory.createAccount();
        accs[0].facility_name__c=accs[0].name;
        Update accs;
        //Create Responder Account
        Account acc=new Account();
        acc.name='Hasbro Dev Stg Req';
        acc.ICIX_V1__Status__c='Active';
        acc.ICIX_V1__ICIX_ID__c='304789';
        acc.ICIX_V1__Internal__c=true;
        acc.facility_name__c='Hasbro Dev Stg Req';
        insert acc;
        //create the product
        list<ICIX_V1__ICIX_Product__c> AssortProd=Hasbro_TestDataFactory.createProduct();
        //Create RetailItem Product
        list<ICIX_V1__ICIX_Product__c> RetailProd=Hasbro_TestDataFactory.createReatilItem();
        //create the PP Relation 
        list<ICIX_V1__PP_Relationship__c> PPr =Hasbro_TestDataFactory.createPP_relationship();
        ppr[0].ICIX_V1__Product1__c=AssortProd[0].id;
        ppr[0].ICIX_V1__Product2__c=RetailProd[0].id;
        ppr[0].ICIX_V1__Type__c='component';
        Update ppr;
        //create Up Relation record
        list< ICIX_V1__UP_Relationship__c> Upr_rel=new list<ICIX_V1__UP_Relationship__c>();
        ICIX_V1__UP_Relationship__c up_realationShip=new ICIX_V1__UP_Relationship__c();
        up_realationShip.name='BLP BLACK PANTHER MOVIE';
        up_realationShip.ICIX_V1__Status__c='Active';
        up_realationShip.ICIX_V1__Type__c='Buy';
        up_realationShip.ICIX_V1__Product__c=AssortProd[0].Id;
        up_realationShip.ICIX_V1__Related_Account__c=acc.Id;
        //up_realationShip.ICIX_V1__UBE__c=acc.id;
        Upr_rel.add(up_realationShip);
        ICIX_V1__UP_Relationship__c up_realationShip1=new ICIX_V1__UP_Relationship__c();
        up_realationShip1.name='BLP BLACK PANTHER MOVIE';
        up_realationShip1.ICIX_V1__Status__c='Active';
        up_realationShip1.ICIX_V1__Type__c='Buy';
        up_realationShip1.ICIX_V1__Product__c=RetailProd[0].Id;
        up_realationShip1.ICIX_V1__Related_Account__c=acc.Id;
       Upr_rel.add(up_realationShip1);
        insert Upr_rel;
        //create Up Relationship attribute
        list<ICIX_V1__UP_Relationship_Attribute__c> attri=Hasbro_TestDataFactory.createUpRealtionShipAttribute();
        attri[0].ICIX_V1__UP_Relationship__c=Upr_rel[1].id;
        insert attri;
        System.Test.Starttest();
        UPRSync sh1 = new UPRSync (AssortProd[0].Id);
        database.executebatch( new UPRSync (AssortProd[0].Id));
        JobRunnerUPRSync Job=new JobRunnerUPRSync(10,'select ICIX_V1__Product1__c,ICIX_V1__Product2__c from ICIX_V1__PP_Relationship__c',1);
        String sch = '0 0 23 * * ?'; 
        system.schedule('Test Territory Check', sch, Job); 
        System.Test.StopTest();  
    }
    catch(Exception e){}
}
     
}
One of my customer created below class. I have created a test class to cover but I am unable to cover the code. It seems I have created a correct data but it is not covering .Please anyone help me on this.

Class:

public class MassQEController{
    
    @Auraenabled
    public static List<string> getAccounts(){
        List<ICIX_V1__Trading_Partner_Relationship__c> tprlist=[select id,ICIX_V1__Responder__r.Facility_Name__c,ICIX_V1__Responder__r.name from ICIX_V1__Trading_Partner_Relationship__c where ICIX_V1__Status__c='Active' and ICIX_V1__Type__c='Vendor' order by ICIX_V1__Responder__r.facility_name__c asc];
        List<String> str=new List<String>();
        for(ICIX_V1__Trading_Partner_Relationship__c tpr:tprlist ){
            if(tpr.ICIX_V1__Responder__r.Facility_Name__c!=null){
                str.add(tpr.ICIX_V1__Responder__r.Facility_Name__c);
            }
        }
        return str;
    }
@Auraenabled
    public static string getprods(string TradingPartnerName,string  parentnumber,string Globalsku,String Productnumber){
        List<ICIX_V1__UP_Relationship__c> uprlsts=new List<ICIX_V1__UP_Relationship__c>();
        set<String> strn=new set<String>();
        strn.add('ASSORTMENT');
        strn.add('SOLID');
        set<Id> pid=new set<Id>();
        if(parentnumber==''){
            parentnumber='XYZ';
        }
        if(Globalsku==''){
            Globalsku='XYZ';
        }
        if(Productnumber==''){
            Productnumber='XYZ';
        }
        if(TradingPartnerName!='No Trading Partner' && TradingPartnerName!= 'All Trading Partners'){
            uprlsts=[select id,ICIX_V1__Product__c,ICIX_V1__Product__r.GlobalSKU__c,ICIX_V1__Product__r.PRODUCTTYPE__c,ICIX_V1__Product__r.Parent_Number__c,ICIX_V1__Product__r.Name,ICIX_V1__Product__r.Product_Number__c,ICIX_V1__Related_Account__r.name,ICIX_V1__Related_Account__r.facility_name__c from ICIX_V1__UP_Relationship__c where ICIX_V1__Related_Account__r.Facility_Name__c=:TradingPartnerName and (ICIX_V1__Product__r.Parent_Number__c like: '%'+parentnumber+'%' or ICIX_V1__Product__r.GlobalSKU__c like: '%'+Globalsku+'%' or ICIX_V1__Product__r.Product_Number__c like: '%'+Productnumber+'%' ) and ICIX_V1__Product__r.PRODUCTTYPE__c in :strn];
        }
        else if(TradingPartnerName=='No Trading Partner'){
            uprlsts=[select id,ICIX_V1__Product__c,ICIX_V1__Product__r.GlobalSKU__c,ICIX_V1__Product__r.PRODUCTTYPE__c,ICIX_V1__Product__r.Parent_Number__c,ICIX_V1__Product__r.Name,ICIX_V1__Product__r.Product_Number__c,ICIX_V1__Related_Account__r.name,ICIX_V1__Related_Account__r.facility_name__c from ICIX_V1__UP_Relationship__c where ICIX_V1__Related_Account__c=null and (ICIX_V1__Product__r.Parent_Number__c like: '%'+parentnumber+'%' or ICIX_V1__Product__r.GlobalSKU__c like: '%'+Globalsku+'%' or ICIX_V1__Product__r.Product_Number__c like: '%'+Productnumber+'%' )  and ICIX_V1__Product__r.PRODUCTTYPE__c in :strn];
        }
        else if(TradingPartnerName == 'All Trading Partners'){
          uprlsts=[select id,ICIX_V1__Product__c,ICIX_V1__Product__r.GlobalSKU__c,ICIX_V1__Product__r.PRODUCTTYPE__c,ICIX_V1__Product__r.Parent_Number__c,ICIX_V1__Product__r.Name,ICIX_V1__Product__r.Product_Number__c,ICIX_V1__Related_Account__r.name,ICIX_V1__Related_Account__r.facility_name__c from ICIX_V1__UP_Relationship__c where ICIX_V1__Related_Account__c !=null AND (ICIX_V1__Product__r.Parent_Number__c like: '%'+parentnumber+'%' or ICIX_V1__Product__r.GlobalSKU__c like: '%'+Globalsku+'%' or ICIX_V1__Product__r.Product_Number__c like: '%'+Productnumber+'%' ) and ICIX_V1__Product__r.PRODUCTTYPE__c in :strn];
     
        }
        set<id> upids=new set<id>();
        for(ICIX_V1__UP_Relationship__c upr:uprlsts){
            upids.add(upr.id);
        }
        map<id,ICIX_V1__UP_Relationship_Attribute__c> map_upr=new map<id,ICIX_V1__UP_Relationship_Attribute__c>();
        List<ICIX_V1__UP_Relationship_Attribute__c> uprAttr=[select id,ICIX_V1__UP_Relationship__c,ICIX_V1__Attribute_Value__c from ICIX_V1__UP_Relationship_Attribute__c where ICIX_V1__UP_Relationship__c in:upids and ICIX_V1__Attribute__r.ICIX_V1__Type__c='Tag' ];
        for(ICIX_V1__UP_Relationship_Attribute__c up:uprAttr){
            map_upr.put(up.ICIX_V1__UP_Relationship__c,up);
        }
        List<prodwrap> prodwraplist=new List<prodwrap>();
        for(ICIX_V1__UP_Relationship__c upr: uprlsts ){
            prodwrap prwrp=new prodwrap();
            prwrp.Productname=upr.ICIX_V1__Product__r.Name;
            prwrp.UprId=upr.Id;
            prwrp.Producttype=upr.ICIX_V1__Product__r.PRODUCTTYPE__c;
            prwrp.SFRecid='/'+upr.ICIX_V1__Product__c;
            prwrp.ProductNumber=upr.ICIX_V1__Product__r.Product_Number__c;
            prwrp.Facility=UPR.ICIX_V1__Related_Account__r.Facility_name__c;
            prwrp.Parentnumber=upr.ICIX_V1__Product__r.Parent_Number__c;
            prwrp.Globalsku=upr.ICIX_V1__Product__r.GlobalSKU__c;
            if(map_upr.containskey(upr.id)){
                if(map_upr.get(upr.id).ICIX_V1__Attribute_Value__c!=null){
                    prwrp.Responsibleqe=map_upr.get(upr.id).ICIX_V1__Attribute_Value__c;
                }
            }
            prodwraplist.add(prwrp);
        }
        string ks=JSON.serialize(prodwraplist,true);
        string ns=ks.replace('children', '_children');
        system.debug(ns);
        return ns;
    }
    @Auraenabled
    public static string UpdateQEs(List<Id> UprIds , String ResponsibleQE ,String FacilityName ){
        System.debug('=========UprIds=========='+UprIds);
        System.debug('=========ResponsibleQE=========='+ResponsibleQE);
        System.debug('=========FacilityName=========='+FacilityName);
        list<ICIX_V1__UP_Relationship_Attribute__c> Upattr=[select id,ICIX_V1__Attribute__c from ICIX_V1__UP_Relationship_Attribute__c where ICIX_V1__UP_Relationship__c in:UprIds and ICIX_V1__Attribute__r.ICIX_V1__Type__c='Tag'];
        delete  Upattr;
        list<ICIX_V1__Attribute__c> attr=[select id,name from ICIX_V1__Attribute__c where name=:ResponsibleQE and ICIX_V1__type__c='Tag' limit 1];
        list<ICIX_V1__UP_Relationship_Attribute__c> Uprattriinsert=new list<ICIX_V1__UP_Relationship_Attribute__c>();
        list<ICIX_V1__UP_Relationship_Attribute__c> UprattriinsertAsst=new list<ICIX_V1__UP_Relationship_Attribute__c>();
        Id AttrId=attr[0].Id;
        system.debug('attribute'+attr);
        for(Id ids:UprIds){
            for(ICIX_V1__Attribute__c c:attr){
                ICIX_V1__UP_Relationship_Attribute__c a=new ICIX_V1__UP_Relationship_Attribute__c();
                a.ICIX_V1__UP_Relationship__c=ids;
                a.ICIX_V1__Attribute_Value__c=ResponsibleQE;
                a.ICIX_V1__Attribute__c=c.id;
                UprattriinsertAsst.add(a);
            }
        }   
        list<ICIX_V1__PP_Relationship__c> pprel=[select id,ICIX_V1__Product1__c,ICIX_V1__Product2__c from ICIX_V1__PP_Relationship__c where ICIX_V1__Product1__c in (select ICIX_V1__Product__c from ICIX_V1__UP_Relationship__c where Id in : UprIds)  and ICIX_V1__type__c='Component'];
        set<id> rids=new set<id>();
        for(ICIX_V1__PP_Relationship__c p:pprel){
            if(p.ICIX_V1__Product2__c !=null){
                rids.add(p.ICIX_V1__Product2__c );
            }
        }
        List<ICIX_V1__UP_Relationship__c> uprlsts = new List<ICIX_V1__UP_Relationship__c>();
        if(FacilityName == 'All Trading Partners'){
         uprlsts = [SELECT Id,ICIX_V1__Product__c,ICIX_V1__Related_Account__c FROM ICIX_V1__UP_Relationship__c WHERE ICIX_V1__Related_Account__r.Facility_Name__c != null AND  ICIX_V1__Product__c in : rids];   
        }
        else{
        uprlsts=[select id,ICIX_V1__Product__c from ICIX_V1__UP_Relationship__c where ICIX_V1__Related_Account__r.Facility_Name__c=:FacilityName and ICIX_V1__Product__c in : rids];
        }
        list<ICIX_V1__UP_Relationship_Attribute__c> UpattrRetailItems=[select id,ICIX_V1__Attribute__c,ICIX_V1__UP_Relationship__c from ICIX_V1__UP_Relationship_Attribute__c where ICIX_V1__UP_Relationship__c in:uprlsts and ICIX_V1__Attribute__c=:AttrId];
        system.debug('Existing Attributess==>'+UpattrRetailItems);
        set<Id> Alreadyexists=new set<Id>();
        for(ICIX_V1__UP_Relationship_Attribute__c uprAtt : UpattrRetailItems){
            Alreadyexists.add(uprAtt.ICIX_V1__UP_Relationship__c);
        }
        system.debug('Existing Attributess==>'+Alreadyexists);
        set<Id> ReIds=new set<Id>();
        set<Id> ReUpr=new set<Id>();
        for(ICIX_V1__UP_Relationship__c Upr:uprlsts){
            if(!Alreadyexists.contains(Upr.Id)){
                for(ICIX_V1__Attribute__c c:attr){
                    ICIX_V1__UP_Relationship_Attribute__c a=new ICIX_V1__UP_Relationship_Attribute__c();
                    a.ICIX_V1__UP_Relationship__c=Upr.Id;
                    a.ICIX_V1__Attribute_Value__c=ResponsibleQE;
                    a.ICIX_V1__Attribute__c=c.id;
                    ReIds.add(Upr.ICIX_V1__Product__c);
                    ReUpr.add(Upr.Id);
                    Uprattriinsert.add(a);
                }
            }else{
                ReIds.add(Upr.ICIX_V1__Product__c);
                ReUpr.add(Upr.Id);
            }
        }
        RecursivePreventer.recursiveFlag=false;
        if(UprattriinsertAsst.size()>0){
            system.debug('UPR Tgas'+UprattriinsertAsst);
            database.insert(UprattriinsertAsst,false);
        }
        if(Uprattriinsert.size()>0){
            // insert Uprattriinsert;
            system.debug('Retail Item tags'+Uprattriinsert);
            Database.SaveResult[] srList=database.insert(Uprattriinsert,false);
            for (Database.SaveResult sr : srList) {
                if (sr.isSuccess()) {
                    // Operation was successful, so get the ID of the record that was processed
                    System.debug('Successfully inserted account. Account ID: ' + sr.getId());
                }
                else {
                    // Operation failed, so get all errors                
                    for(Database.Error err : sr.getErrors()) {
                        System.debug('The following error has occurred.');                    
                        System.debug(err.getStatusCode() + ': ' + err.getMessage());
                        System.debug('Account fields that affected this error: ' + err.getFields());
                    }
                }
            }
            system.debug('Calling Future Method');
            //Calling Future methods..Passing Retail Items Upr , Attribute Id and Facility Name as Parameters 
        } 
        if(FacilityName == 'All Trading Partners'){
       
             System.enqueueJob(new SyncRetailItemsQeQueueable(ReIds,ReUpr,AttrId,FacilityName));
        }
        else{
          MassQEController.SyncRetailItemsQE(ReIds,ReUpr,AttrId,FacilityName); 
        }
        return 'Updated successfully.';
    }
    //Asyncronous Processing of the Removal of Retail Items QE's
    @Future
    public static void SyncRetailItemsQE(set<Id> RetailId,set<Id> RetailUPRId,Id AttrId,string TradingPartnerName){
        system.debug('Retail Id==>'+RetailId);
        system.debug('Retail Id UPR==>'+RetailUPRId);
        system.debug('Retail Id UPR==>'+AttrId);
        system.debug('Trading Partner Name==>'+TradingPartnerName);
        list<ICIX_V1__PP_Relationship__c> pprel=[select id,ICIX_V1__Product1__c,ICIX_V1__Product2__c from ICIX_V1__PP_Relationship__c where ICIX_V1__Product2__c in :RetailId  and ICIX_V1__type__c='Component'];
        //map of Retail Item and Its Assortments...
        map<Id,List<Id>> MpRetailItemMap=new map<Id,List<Id>>();
        set<Id> AsstId=new set<Id>();
        for(ICIX_V1__PP_Relationship__c pp : pprel){
            if(pp.ICIX_V1__Product1__c!=null){
                //Adding All Assortment Product Id's in Set
                AsstId.add(pp.ICIX_V1__Product1__c);
                if(MpRetailItemMap.containskey(pp.ICIX_V1__Product2__c)){
                    list<Id> Aid=MpRetailItemMap.get(pp.ICIX_V1__Product2__c);
                    Aid.add(pp.ICIX_V1__Product1__c);
                    MpRetailItemMap.put(pp.ICIX_V1__Product2__c,Aid);
                }else{
                    list<Id> Aid=new List<Id>();
                    Aid.add(pp.ICIX_V1__Product1__c);
                    MpRetailItemMap.put(pp.ICIX_V1__Product2__c,Aid);
                }
            }
        }
        //Removing if any null is present
        AsstId.remove(null);
        //Querying the Attributes of the Retail Item Upr's
        list<ICIX_V1__UP_Relationship_Attribute__c> UpattrRetailItems=[select id,ICIX_V1__Attribute__c,ICIX_V1__Attribute__r.name,ICIX_V1__UP_Relationship__c,ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c from ICIX_V1__UP_Relationship_Attribute__c where ICIX_V1__UP_Relationship__c in:RetailUPRId and ICIX_V1__Attribute__r.ICIX_V1__type__c='Tag'];
        //Querying the Attributes of the Retail Item Upr's 
        list<ICIX_V1__UP_Relationship_Attribute__c> UpattrAst = new List<ICIX_V1__UP_Relationship_Attribute__c>();
        
       
         UpattrAst=[select id,ICIX_V1__Attribute__c,ICIX_V1__UP_Relationship__c,ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c,ICIX_V1__Attribute__r.name from ICIX_V1__UP_Relationship_Attribute__c where ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c in:AsstId and ICIX_V1__UP_Relationship__r.ICIX_V1__Related_Account__r.Facility_Name__c=:TradingPartnerName  and ICIX_V1__Attribute__r.ICIX_V1__type__c='Tag'];
           
       
            //Adding All the Assortment Id and list of Attribute names in the Map..Since an Assortment UPR contains only one Tag..unlike a Retail Item upr which can have multiple Tags of Responsible QE's.
        system.debug('Attribute Retail Items'+UpattrRetailItems);
        system.debug('Attribute Assortments==>'+UpattrAst);
        map<Id,List<String>> MpTag=new map<Id,List<String>>();
        for(ICIX_V1__UP_Relationship_Attribute__c uat :  UpattrAst){
            if(MpTag.containskey(uat.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c)){
                List<String> Strglst=MpTag.get(uat.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c);
                Strglst.add(uat.ICIX_V1__Attribute__r.name);
                MpTag.put(uat.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c,Strglst);
            }else{
                List<String> Strlst=new list<String>();
                Strlst.add(uat.ICIX_V1__Attribute__r.name);
                MpTag.put(uat.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c,Strlst);
            }
        }
        //Checking to Delete the Responsible QE tags of the Retail Items Upr's when it is not present in the Assortment UPR's of the Related Trading Partner..
        List<ICIX_V1__UP_Relationship_Attribute__c> ToDelete=new List<ICIX_V1__UP_Relationship_Attribute__c>();
        //Looping throgh the Retail Items UPR..
        for(ICIX_V1__UP_Relationship_Attribute__c uar : UpattrRetailItems){
            //Getting the Assortment under which the Retail Items are present..
            if(MpRetailItemMap.containskey(uar.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c)){
                List<Id> Aid=MpRetailItemMap.get(uar.ICIX_V1__UP_Relationship__r.ICIX_V1__Product__c);
                if(Aid.size()>0){
                    set<String> Strg=new set<String>();
                    system.debug('Assortment Ids==>'+Aid);
                    system.debug('Assortment Tags==>'+MpTag);
                    for(Id Ids : Aid){
                        if(MpTag.containskey(Ids)){
                            Strg.addAll(MpTag.get(Ids));
                        }
                    }
                    system.debug('Assortment Attributes==>'+Strg);
                    Strg.remove(null);
                    if(!Strg.contains(uar.ICIX_V1__Attribute__r.name)){
                        system.debug('To delete==>'+uar);
                        ToDelete.add(uar); 
                    }
                }
            }
        }
        system.debug('To delete the Attribytes==>'+ToDelete);
        //Deleting the Responsible QE tags which are not under any related Assortment Tags..
        Delete ToDelete;
    }
 
Hi,
I tried a lot but unable to cover below part.

Class:
public class testclassgenerator {
      
    public class ProductWrapper{
        public String productName {get;set;}
        public String internalClass {get;set;}
        public String brandName{get;set;}
        public String OrderNumber {get;set;}
        public String SoldToName {get;set;}
        public String ShipToCountry {get;set;}
        public String DeliveryDate {get;set;}
        public String ProductNumber {get;set;}
        public String FactoryName {get;set;}
        public String DaysRem {get;set;}
        public String EarliestExpDate {get;set;}
        public String TestReportID {get;set;}
        public String CPC {get;set;}
        public String DOC {get;set;}
        public String ukDOC {get;set;}
        public String ResponsibleQE{get;set;}
        public String CPCDocId{get;set;}
        public String DOCDocId{get;set;}
        public String ukDOCDocId{get;set;}
        public Date testDate{get;set;}
        public String ProductId{get;set;}
        public String ReqId{get;set;}
        public String CustomerName{get;set;}
        public String resultType{get;set;}
        public String responsibleQEId{get;set;}
        public String TestingStatus{get;set;}
       
    }
   public void execute(String dataSet,List<sObject> sObjectList,String insightExternalObjectId,Integer partNumber)
    {
        System.debug('List=>'+sObjectList);
        if(!sObjectList.isEmpty())
        {
            List<ICIX_V1_Purchase_Order__c> lstOrder = new List<ICIX_V1_Purchase_Order__c>();
            Set<Id> stOd = new Set<Id>();
            Set<Id> proSt = new Set<Id>();
            Set<Id> accId = new Set<Id>();
            Set<Id> RISet = new Set<Id>();
            Set<Id> MajorProd = new Set<Id>();
            Set<Id> SetParentProd = new Set<Id>();
            Set<Id> SetChildProd = new Set<Id>();
            Set<String> prodNum = new Set<String>();
            Set<Id> HPISt = new Set<Id>();
            Boolean isReqExpBlank = false;
            Boolean isExtend = false;
            lstOrder.addAll((List<ICIX_V1_Purchase_Order__c>)sObjectList);
            List<ICIX_V1_UP_Relationship__c> lstUPRNew = new List<ICIX_V1_UP_Relationship__c>();
            //List<ICIX_V1__Request__c> lstRequest = new List<ICIX_V1__Request__c>();
            List<Product2> lstAllProducts = new list<Product2>();
            List<Date> lstdateReq = new List<Date>();
            List<ProductWrapper> wrapperList = new List<ProductWrapper>();
            List<Id> extendedProductIdsList = new List<Id>();
            for(ICIX_V1_Purchase_Order__c obOrder : lstOrder)
            {
                stOd.add(obOrder.Id);
                accId.add(obOrder.ICIX_V1_Trading_Partner__c);
            }
           
           
            set<Id> tradingPartnersId = new set<Id>();
            List<ICIX_V1_Purchase_Order_Line_Item__c> lstOrderItem = [SELECT Id,
                                                                      
                                                                       ICIX_V1_Purchase_Order__c,ICIX_V1_ICIX_Product__c,
                                                                       ICIX_V1_ICIX_Product__r.Product_Number__c,ICIX_V1_ICIX_Product__r.Name,
                                                                    
                                                                       ICIX_V1_ICIX_Product_Relationship__c,
                                                                    
                                                                       ICIX_V1_Status__c,ICIX_V1_Purchase_Order__r.ICIX_V1_Trading_Partner__c
                                                                       FROM ICIX_V1_Purchase_Order_Line_Item__c
                                                                       where ICIX_V1_Purchase_Order__c in : stOd];
            if(lstOrderItem.size() > 0)
            {
                for(ICIX_V1_Purchase_Order_Line_Item__c obItem : lstOrderItem)
                {
                    proSt.add(obItem.ICIX_V1_ICIX_Product__c);  
                    prodNum.add(obItem.ICIX_V1_ICIX_Product__r.Product_Number__c);
                    tradingPartnersId.add(obItem.ICIX_V1_Purchase_Order__r.ICIX_V1_Trading_Partner__c);
                }
            }
}
}
           

Test class:

@isTest
private class testclassgenerator_Test{
  @testSetup
  static void setupTestData(){
    test.startTest();
      //creating account
    Account account_Obj = new Account(Name = 'Name783', Type = 'Prospect', Facility_Name__c = 'Facil788', ICIX_V1_Status__c = 'Active', ICIX_V1_ICIX_ID__c = 'ICIX_480');
    Insert account_Obj;   
     
    // Creating Products      
    Product2 product2_Obj = new Product2(Name = 'Name381',Global_SKU__c = 'C1918', Manual_Product__c = true, Parent_Number__c = '21', Product_Number__c = '22', Product_Status__c = '23', ProductType__c = 'RETAILITEM', Responsible_QE__c = 'Picklist01');
    Insert product2_Obj; 
    Product2 product2_Obj1 = new Product2(Name = 'Name381', Global_SKU__c = 'C1918', Manual_Product__c = true, Parent_Number__c = '21', Product_Number__c = '22', Product_Status__c = '23', ProductType__c = '24', Responsible_QE__c = 'Picklist01');
    Insert product2_Obj1; 
        ICIX_V1_UP_Relationship__c icix_v1_up_relationship_Obj = new ICIX_V1_UP_Relationship__c(Name = 'Name842', Trading_Partner__c = account_Obj.id, ICIX_V1_Type__c = 'Sell', ICIX_V1_Status__c = 'Suspended', IXIX_V1_Product__c = product2_Obj.id);
    Insert icix_v1_up_relationship_Obj; 
    ICIX_V1_Attribute__c icix_v1_attribute_Obj = new ICIX_V1_Attribute__c(Name = 'Name409', ICIX_V1_Type__c = 'Attribute', ICIX_V1__c = 'Text', ICIX_V1_Relationship_Types_List__c = 'Product');
    Insert icix_v1_attribute_Obj; 
    ICIX_V1_Purchase_Order__c icix_v1_purchase_order_Obj = new ICIX_V1_Purchase_Order__c(Name = 'Name571', ICIX_V1_Trading_Partner__c = account_Obj.id, ICIX_V1_PO_Status__c = 'Open', ICIX_V1_PO_Number__c = 'ICIX_651', ICIX_V1_External_Id__c = 'ICIX_463');
    Insert icix_v1_purchase_order_Obj; 
    ICIX_V1_Purchase_Order_Line_Item__c icix_v1_purchase_order_line_item_Obj = new ICIX_V1_Purchase_Order_Line_Item__c(Name = 'Name824', ICIX_V1_Certificate_Generated__c = false, ICIX_V1_ICIX_Product__c = product2_Obj.id, ICIX_V1_ICIX_Product_Relationship__c = icix_v1_up_relationship_Obj.id, ICIX_V1_Purchase_Order__c = icix_v1_purchase_order_Obj.id, ICIX_V1_Quantity__c = 16, ICIX_V1_Status__c = 'Open', ICIX_V1_Test_Request_Trading_Partner__c = account_Obj.id);
    Insert icix_v1_purchase_order_line_item_Obj; 
    test.stopTest();
  }
  static testMethod void test_SyncRetailItemsQE_UseCase1(){
      List<ICIX_V1_UP_Relationship__c> icix_v1_up_relationship_Obj  =  [SELECT Id,Name,Trading_Partner__c,ICIX_V1_Type__c,ICIX_V1_Status__c,IXIX_V1_Product__c,Product_Type__c from ICIX_V1_UP_Relationship__c];
    System.assertEquals(true,icix_v1_up_relationship_Obj.size()>0);
    List<ICIX_V1_Attribute__c> icix_v1_attribute_Obj  =  [SELECT Id,Name,ICIX_V1_Type__c,ICIX_V1__c,ICIX_V1_Relationship_Types_List__c from ICIX_V1_Attribute__c];
    System.assertEquals(true,icix_v1_attribute_Obj.size()>0);
    List<ICIX_V1_Purchase_Order__c> icix_v1_purchase_order_Obj  =  [SELECT Id,Name,ICIX_V1_Trading_Partner__c,ICIX_V1_Test_Request_Trading_Partner__c,ICIX_V1_PO_Status__c,ICIX_V1_PO_Number__c,ICIX_V1_External_Id__c from ICIX_V1_Purchase_Order__c];
    System.assertEquals(true,icix_v1_purchase_order_Obj.size()>0);
    List<ICIX_V1_Purchase_Order_Line_Item__c> icix_v1_purchase_order_line_item_Obj  =  [SELECT Id,Name,ICIX_V1_Certificate_Generated__c,ICIX_V1_ICIX_Product__c,ICIX_V1_ICIX_Product_Relationship__c,ICIX_V1_Purchase_Order__c,ICIX_V1_Quantity__c,ICIX_V1_Status__c,ICIX_V1_Test_Request_Trading_Partner__c from ICIX_V1_Purchase_Order_Line_Item__c];
    System.assertEquals(true,icix_v1_purchase_order_line_item_Obj.size()>0);
      
    testclassgenerator obj01 = new testclassgenerator();
    obj01.execute('Test',new List<ICIX_V1_Purchase_Order_Line_Item__c>(),'test',1);
  }
}
I have object called Agreement.
One agreement will have mutliple child agreements.
we  have a Parent Agreement lookup field on Child Agreement with Parent agreement value.

When Status category of Child agreement is Terminated, then on Parent agreement Status category and Termination date should be updated as child record.

The issue is am not getting Parent id from my trigger. So its not updating on Parent record eventhough my if condition satisfied.

Class:
public class UpdateTerminationDate {
public static Boolean isFirstTime = true;
   
          }    
 

Trigger:

trigger UpdateTerminationDateTrigger on Apttus__APTS_Agreement__c (after insert,after update) {
     public static Boolean bool = true;
    If(UpdateTerminationDate.isFirstTime){
        UpdateTerminationDate.isFirstTime = false;
   
   
    List<Apttus__APTS_Agreement__c> agr=new List<Apttus__APTS_Agreement__c>();
     List<id> acc=new List<id>();
    for(Apttus__APTS_Agreement__c a:Trigger.New)
    {
        acc.add(a.id);
        system.debug(acc);
    }

    List<Apttus__APTS_Agreement__c> agreement = [select id,Name,Apttus__Parent_Agreement__r.Apttus__Status_Category__c,CLM_Agreement_Termination_Date__c,Apttus__Parent_Agreement__r.CLM_Agreement_Termination_Date__c,Apttus__Parent_Agreement__c,Apttus__Status_Category__c,Apttus__Status__c,Apttus__Parent_Agreement__r.Apttus__Status__c from Apttus__APTS_Agreement__c where id in: acc];    
    
    for(Apttus__APTS_Agreement__c ag:agreement){
        system.debug(ag.Apttus__Parent_Agreement__r.CLM_Agreement_Termination_Date__c);
        if(ag.Apttus__Status_Category__c=='Terminated')
            {
                ag.Apttus__Parent_Agreement__r.CLM_Agreement_Termination_Date__c=ag.CLM_Agreement_Termination_Date__c;
               //ag.Apttus__Status_Category__c=ag.Apttus__Parent_Agreement__r.Apttus__Status_Category__c;
               //ag.Apttus__Status__c='Terminated';
               
                system.debug('test');
              system.debug(ag.Apttus__Parent_Agreement__r.CLM_Agreement_Termination_Date__c);
                system.debug(ag.CLM_Agreement_Termination_Date__c);
                agr.add(ag);
                
            }
        
        update ag;
        }
     
      update agr;
        system.debug(agr);
    
    }
  }

Isuue is both  agr id and ag id are same(child agreement id)