You need to sign in to do that
Don't have an account?
System Admin 949
Testclass for Apex
Hi Community,
i am facing some problem for writing the test class for below apex class,can any provide sample code for this to write the test class
apex class
public class ProductNoteListController {
@AuraEnabled
public static List<CustomerProduct__c> getProductNotes(Id meetingRecId) {
List<CustomerProduct__c> pdtNoteList = [SELECT Id, Product__r.Id,Product__r.Name, MeetingNotes__c,MeetingId__c,RecordType.DeveloperName
FROM CustomerProduct__c
WHERE MeetingId__c =: meetingRecId
ORDER BY createdDate DESC];
for(CustomerProduct__c cpRec : pdtNoteList){
if(cpRec.MeetingNotes__c!=Null)
{
cpRec.MeetingNotes__c = cpRec.MeetingNotes__c.replaceAll('<[^>]+>',' ');
}
}
System.debug('**********'+pdtNoteList);
return pdtNoteList;
}
@AuraEnabled
public static void updateCustProdRT(Id recordId)
{
try
{
List<RecordType> rtypes = [Select Id From RecordType where Name='Customer Product' AND SobjectType = 'CustomerProduct__c'];
CustomerProduct__c CP = [select id from CustomerProduct__c WHERE Id=:recordId];
CP.RecordTypeId=rtypes.get(0).Id;
update CP;
}
catch(DmlException ex)
{
throw new AuraHandledException(ex.getMessage());
}
}
}
thanks in advance
i am facing some problem for writing the test class for below apex class,can any provide sample code for this to write the test class
apex class
public class ProductNoteListController {
@AuraEnabled
public static List<CustomerProduct__c> getProductNotes(Id meetingRecId) {
List<CustomerProduct__c> pdtNoteList = [SELECT Id, Product__r.Id,Product__r.Name, MeetingNotes__c,MeetingId__c,RecordType.DeveloperName
FROM CustomerProduct__c
WHERE MeetingId__c =: meetingRecId
ORDER BY createdDate DESC];
for(CustomerProduct__c cpRec : pdtNoteList){
if(cpRec.MeetingNotes__c!=Null)
{
cpRec.MeetingNotes__c = cpRec.MeetingNotes__c.replaceAll('<[^>]+>',' ');
}
}
System.debug('**********'+pdtNoteList);
return pdtNoteList;
}
@AuraEnabled
public static void updateCustProdRT(Id recordId)
{
try
{
List<RecordType> rtypes = [Select Id From RecordType where Name='Customer Product' AND SobjectType = 'CustomerProduct__c'];
CustomerProduct__c CP = [select id from CustomerProduct__c WHERE Id=:recordId];
CP.RecordTypeId=rtypes.get(0).Id;
update CP;
}
catch(DmlException ex)
{
throw new AuraHandledException(ex.getMessage());
}
}
}
thanks in advance
Thank, let us know if it helps you