You need to sign in to do that
Don't have an account?
jha pk
batch test class- very very urgent
Please help me to write the test class for below batch class
global class UpdatesObjectFields implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext bc)
{
String query= 'SELECT Id,FirstName, LastName, OtherStreet,OtherCity,OtherState,OtherPostalCode,OtherCountry,OtherStateCode,OtherCountryCode,OtherLatitude,OtherLongitude,OtherGeocodeAccuracy,OtherAddress,MailingStreet,MailingCity,MailingState,MailingPostalCode,MailingCountry,MailingStateCode,MailingCountryCode,MailingLatitude,MailingLongitude,MailingGeocodeAccuracy,MailingAddress,Phone,Fax,MobilePhone,HomePhone,OtherPhone,AssistantPhone,Email,Birthdate,Description,PhotoUrl,Middle_Name__c,Email_2nd__c,Gender__c,Last_Contact_Number__c from Contact';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc, List<Contact> cnct)
{
Contact[] con = new List<Contact>();
List<Contact> my_list = new List<Contact>();
List<Contact> my_list1 = new List<Contact>();
my_list = cnct;
my_list1 = my_list;
Contact ct = new Contact();
for (integer i=0; i<cnct.size();i++ )
{
ct = my_list[i];
integer j=0;
if(i+1 >=my_list.size())
{
ct.FirstName = my_list1[j].FirstName;j++;
}
else
{
ct.FirstName = my_list[i+1].FirstName;
}
if(i+2 >=my_list.size())
{
ct.LastName = my_list1[j].LastName;j++;
}
else
{
ct.LastName = my_list[i+2].LastName;
}
if(i+3 >=my_list.size())
{
ct.OtherStreet = my_list1[j].OtherStreet;j++;
}
else
{
ct.OtherStreet = my_list[i+3].OtherStreet;
}
global class UpdatesObjectFields implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext bc)
{
String query= 'SELECT Id,FirstName, LastName, OtherStreet,OtherCity,OtherState,OtherPostalCode,OtherCountry,OtherStateCode,OtherCountryCode,OtherLatitude,OtherLongitude,OtherGeocodeAccuracy,OtherAddress,MailingStreet,MailingCity,MailingState,MailingPostalCode,MailingCountry,MailingStateCode,MailingCountryCode,MailingLatitude,MailingLongitude,MailingGeocodeAccuracy,MailingAddress,Phone,Fax,MobilePhone,HomePhone,OtherPhone,AssistantPhone,Email,Birthdate,Description,PhotoUrl,Middle_Name__c,Email_2nd__c,Gender__c,Last_Contact_Number__c from Contact';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc, List<Contact> cnct)
{
Contact[] con = new List<Contact>();
List<Contact> my_list = new List<Contact>();
List<Contact> my_list1 = new List<Contact>();
my_list = cnct;
my_list1 = my_list;
Contact ct = new Contact();
for (integer i=0; i<cnct.size();i++ )
{
ct = my_list[i];
integer j=0;
if(i+1 >=my_list.size())
{
ct.FirstName = my_list1[j].FirstName;j++;
}
else
{
ct.FirstName = my_list[i+1].FirstName;
}
if(i+2 >=my_list.size())
{
ct.LastName = my_list1[j].LastName;j++;
}
else
{
ct.LastName = my_list[i+2].LastName;
}
if(i+3 >=my_list.size())
{
ct.OtherStreet = my_list1[j].OtherStreet;j++;
}
else
{
ct.OtherStreet = my_list[i+3].OtherStreet;
}