You need to sign in to do that
Don't have an account?
![Rahul Rahul](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Hello friends, Iam new with test classes. Can you help me with this test class?
public class caseController {
@AuraEnabled
public static List<Organizational_Payment__c> getCaseList(Id recordId){
Id orgId;
List<Case> org = [select ContactId from Case WHERE Id=:recordId];
for(Case c:org){
orgId=c.ContactId;
}
List<Organizational_Payment__c> orgPaylst = [SELECT Id,Name,Receiving_organization__r.Name,Payment_Status__c,Payment_Date__c,Payable_Amount__c, Bank_Account_Number__c,Concerning_Person_ID__c
FROM Organizational_Payment__c WHERE Concerning_Person_ID__c = :orgId and Payment_Date__c > LAST_N_MONTHS:6
ORDER BY Payment_date__c DESC];
return orgPaylst;
}
@AuraEnabled
public static void updateRecord(List<String> lstRecordId) {
List<Organizational_Payment__c> lstOrgPayUpdate = new List<Organizational_Payment__c>() ;
for(Organizational_Payment__c orgPay :[SELECT Id,Payment_Status__c FROM Organizational_Payment__c where id = : lstRecordId] ){
orgPay.Payment_Status__c= 'Bounced payment';
lstOrgPayUpdate.add(orgPay);
System.debug('Success');
}
if(!lstOrgPayUpdate.isEmpty()){
update lstOrgPayUpdate;
}
}
@AuraEnabled
public static List<Payment_Result__c> getPayResultList(Id recordId){
Id perId;
List<Case> per = [select ContactId from Case WHERE Id=:recordId];
for(Case c:per){
perId=c.ContactId;
}
List<Payment_Result__c> PayReslst = [SELECT Id,Name,Payment_Status__c,Payment_Date__c,Person_ID__c,Bank_Number__c,Total_Amount_Net__c
FROM Payment_Result__c WHERE Person_ID__c = :perId and Payment_Date__c > LAST_N_MONTHS:6
ORDER BY Payment_Date__c DESC];
return PayReslst;
}
@AuraEnabled
public static void updatePaymentRecord(List<String> lstPayId) {
List<Payment_Result__c> lstPayResUpdate = new List<Payment_Result__c>() ;
for(Payment_Result__c Pay :[SELECT Id,Payment_Status__c FROM Payment_Result__c where id = : lstPayId] ){
Pay.Payment_Status__c= 'Bounced payment';
lstPayResUpdate.add(Pay);
System.debug('Success');
}
if(!lstPayResUpdate.isEmpty()){
update lstPayResUpdate;
}
}
}
What i have implemented is this :-
@isTest
public class CaseAuraControllerTest {
public static void setupData(){
Account acc = TestDataFactory.createAccount();
Contact con = TestDataFactory.createContactWithBasicInfo(acc.Id);
Case cas = TestDataFactory.createCase(con.Id);
}
}
Can you help what to do after this?
@AuraEnabled
public static List<Organizational_Payment__c> getCaseList(Id recordId){
Id orgId;
List<Case> org = [select ContactId from Case WHERE Id=:recordId];
for(Case c:org){
orgId=c.ContactId;
}
List<Organizational_Payment__c> orgPaylst = [SELECT Id,Name,Receiving_organization__r.Name,Payment_Status__c,Payment_Date__c,Payable_Amount__c, Bank_Account_Number__c,Concerning_Person_ID__c
FROM Organizational_Payment__c WHERE Concerning_Person_ID__c = :orgId and Payment_Date__c > LAST_N_MONTHS:6
ORDER BY Payment_date__c DESC];
return orgPaylst;
}
@AuraEnabled
public static void updateRecord(List<String> lstRecordId) {
List<Organizational_Payment__c> lstOrgPayUpdate = new List<Organizational_Payment__c>() ;
for(Organizational_Payment__c orgPay :[SELECT Id,Payment_Status__c FROM Organizational_Payment__c where id = : lstRecordId] ){
orgPay.Payment_Status__c= 'Bounced payment';
lstOrgPayUpdate.add(orgPay);
System.debug('Success');
}
if(!lstOrgPayUpdate.isEmpty()){
update lstOrgPayUpdate;
}
}
@AuraEnabled
public static List<Payment_Result__c> getPayResultList(Id recordId){
Id perId;
List<Case> per = [select ContactId from Case WHERE Id=:recordId];
for(Case c:per){
perId=c.ContactId;
}
List<Payment_Result__c> PayReslst = [SELECT Id,Name,Payment_Status__c,Payment_Date__c,Person_ID__c,Bank_Number__c,Total_Amount_Net__c
FROM Payment_Result__c WHERE Person_ID__c = :perId and Payment_Date__c > LAST_N_MONTHS:6
ORDER BY Payment_Date__c DESC];
return PayReslst;
}
@AuraEnabled
public static void updatePaymentRecord(List<String> lstPayId) {
List<Payment_Result__c> lstPayResUpdate = new List<Payment_Result__c>() ;
for(Payment_Result__c Pay :[SELECT Id,Payment_Status__c FROM Payment_Result__c where id = : lstPayId] ){
Pay.Payment_Status__c= 'Bounced payment';
lstPayResUpdate.add(Pay);
System.debug('Success');
}
if(!lstPayResUpdate.isEmpty()){
update lstPayResUpdate;
}
}
}
What i have implemented is this :-
@isTest
public class CaseAuraControllerTest {
public static void setupData(){
Account acc = TestDataFactory.createAccount();
Contact con = TestDataFactory.createContactWithBasicInfo(acc.Id);
Case cas = TestDataFactory.createCase(con.Id);
}
}
Can you help what to do after this?
try below Code Please Mark It As Best Answer If It Helps
Thank You!
All Answers
try below Code Please Mark It As Best Answer If It Helps
Thank You!