You need to sign in to do that
Don't have an account?
Michael M
Test class for apex schedulable class__
Hello, Would someone be able to assist in writing a test class for the following apex class:
global class purgeFiles implements Schedulable{
global void execute(SchedulableContext SC) {
List<ContentDocumentLink > docs;
docs = [SELECT Id, Linkedentity.name, Linkedentity.id,ContentDocument.CreatedDate
FROM contentDocumentLink
WHERE Linkedentityid
IN (SELECT Id FROM lead where createddate < Last_N_Days:7 and isconverted = false) ];
//may want to change to include ALL leads
//AND ContentDocument.CreatedDate < Last_N_Days:7];
if(!docs.isEmpty())
delete docs;
}
}
Thank you very much
global class purgeFiles implements Schedulable{
global void execute(SchedulableContext SC) {
List<ContentDocumentLink > docs;
docs = [SELECT Id, Linkedentity.name, Linkedentity.id,ContentDocument.CreatedDate
FROM contentDocumentLink
WHERE Linkedentityid
IN (SELECT Id FROM lead where createddate < Last_N_Days:7 and isconverted = false) ];
//may want to change to include ALL leads
//AND ContentDocument.CreatedDate < Last_N_Days:7];
if(!docs.isEmpty())
delete docs;
}
}
Thank you very much
You can start with something like this
@isTest
public class purgeFilesTest
{
static testMethod void testMethod1()
{
List<contentDocumentLink> lstCon = new List<contentDocumentLink>();
Account acc = new Account(name='Test Account');
insert acc;
ContentNote n = new ContentNote();
n.title = 'My Note from Apex';
insert n;
for(Integer i=0 ;i <200;i++)
{
ContentDocumentLink contentlink=new ContentDocumentLink();
contentlink.LinkedEntityId = acc.id;
contentlink.ShareType= 'V';
contentlink.ContentDocumentId=n.id;
contentlink.Visibility = 'AllUsers';
lstCon.add(contentlink);
}
insert lstCon;
Test.startTest();
purgeFiles obj = new purgeFiles();
DataBase.executeBatch(obj);
Test.stopTest();
// After the testing stops, Please assert if records are updated properly
}
}
You can learn more about testing batch apex here:
https://trailhead.salesforce.com/en/content/learn/modules/asynchronous_apex/async_apex_batch
Anudeep
All Answers
You can start with something like this
@isTest
public class purgeFilesTest
{
static testMethod void testMethod1()
{
List<contentDocumentLink> lstCon = new List<contentDocumentLink>();
Account acc = new Account(name='Test Account');
insert acc;
ContentNote n = new ContentNote();
n.title = 'My Note from Apex';
insert n;
for(Integer i=0 ;i <200;i++)
{
ContentDocumentLink contentlink=new ContentDocumentLink();
contentlink.LinkedEntityId = acc.id;
contentlink.ShareType= 'V';
contentlink.ContentDocumentId=n.id;
contentlink.Visibility = 'AllUsers';
lstCon.add(contentlink);
}
insert lstCon;
Test.startTest();
purgeFiles obj = new purgeFiles();
DataBase.executeBatch(obj);
Test.stopTest();
// After the testing stops, Please assert if records are updated properly
}
}
You can learn more about testing batch apex here:
https://trailhead.salesforce.com/en/content/learn/modules/asynchronous_apex/async_apex_batch
Anudeep
IPL Teams (https://www.iplteams.xyz/)
IPL 2020 Teams and Players (https://www.iplteams.xyz/)
IPL Players and Team List (https://www.iplteams.xyz/)
Kinemaster Pro (https://happymod19.blogspot.com/2019/06/Download-KineMaster-Mod-APK-For-Android.html) is the best video editing apk which is used by most of the people.
DeadToonsIndia (https://hindimeintoonshd.blogspot.com/) is the best anime website.
Dead Toons India (https://medium.com/@kinemasterpromodapk/deadtoons-india-dead-toons-india-c56de9bbc399)
Also, check Portal Roms (https://www.portalroms.cc/).cc and Portal roms (https://portalroms.org/).org
So what are you waiting for? Join the fun today and explore the vast world of video games that Romskostenlos has to offer. From well-known titles to hidden gems, there's something for everyone. And with support for a wide range of devices, you can play your games wherever you go. So what are you waiting for? Start your gaming journey today with Romskostenlos.