You need to sign in to do that
Don't have an account?
Runi
How to write test class for below apex class
public class ProductLighting {
@AuraEnabled
public static Opportunity fetchOpportunityLineItem(String opId) {
Opportunity returnContactList = new Opportunity();
returnContactList = [Select Id,StageName,(SELECT Id,UnitPrice,Quantity,Discount__c, From OpportunityLineItems Where Approved_c=True) from Opportunity Where Id=:opId];
return returnContactList ;
}
@AuraEnabled
public static List < String > Records(List < String > lstRecordId) {
List < String > Msg = new List < String > ();
List < OpportunityLineItem > lstDeprecateRec = [select Id,Product_Deprecated__c from OpportunityLineItem where id IN: lstRecordId];
for(OpportunityLineItem ord:lstDeprecateRec)
{
ord.Product_Deprecated__c=True;
}
allowupdateopplineitem__c obj = allowupdateopplineitem__c.getInstance('isallowed');
obj.allowupdate__c = true;
update obj;
Database.SaveResult[] DR_Dels = Database.update(lstDeprecateRec, false);
obj.allowupdate__c = false;
update obj;
for (Database.SaveResult dr: DR_Dels) {
if (dr.isSuccess()) {
system.debug('successful Deprecate Opportunity Line Items');
}
}
return Msg;
}
}
@AuraEnabled
public static Opportunity fetchOpportunityLineItem(String opId) {
Opportunity returnContactList = new Opportunity();
returnContactList = [Select Id,StageName,(SELECT Id,UnitPrice,Quantity,Discount__c, From OpportunityLineItems Where Approved_c=True) from Opportunity Where Id=:opId];
return returnContactList ;
}
@AuraEnabled
public static List < String > Records(List < String > lstRecordId) {
List < String > Msg = new List < String > ();
List < OpportunityLineItem > lstDeprecateRec = [select Id,Product_Deprecated__c from OpportunityLineItem where id IN: lstRecordId];
for(OpportunityLineItem ord:lstDeprecateRec)
{
ord.Product_Deprecated__c=True;
}
allowupdateopplineitem__c obj = allowupdateopplineitem__c.getInstance('isallowed');
obj.allowupdate__c = true;
update obj;
Database.SaveResult[] DR_Dels = Database.update(lstDeprecateRec, false);
obj.allowupdate__c = false;
update obj;
for (Database.SaveResult dr: DR_Dels) {
if (dr.isSuccess()) {
system.debug('successful Deprecate Opportunity Line Items');
}
}
return Msg;
}
}
Try Below Test Code Please Mark It As Best Answer If It Helps
Thank You!
Hi,
Please find the solution.
Please mark it as the Best Answer if it helps you
Thank You