-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
10Questions
-
4Replies
plz execute this test code coverage plz
please execute this test class for code coverage.........
global class BatchClass5 implements Database.Batchable<sObject> {
global final string query;
global BatchClass5(String q)
{
query = q;
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope)
{
List<Account> accns = new List<Account>();
List<Contact> lstcon= new List<contact>();
for(Account a : scope)
{
Account a1 = new Account();
contact c = new contact();
c.lastname = a1.name;
c.accountid = a1.id;
lstcon.add(c);
}
insert lstcon;
}
global void finish(Database.BatchableContext BC){
// Get the ID of the AsyncApexJob representing this batch job
// from Database.BatchableContext.
// Query the AsyncApexJob object to retrieve the current job's information.
}
}
testclass
@isTest
private class BatchClass5_Test5
{
static testmethod void m1()
{
Test.startTest();
Account a = new Account(Name='saikumar');
insert a;
contact c = new Contact();
c.LastName =a.Name;
c.AccountId= a.Id;
insert c;
system.assertEquals('saikumar',c.LastName);
BatchClass5 sync = new batchclass5('select id,name from Account');
ID batchprocessid = Database.executeBatch(sync);
Test.stopTest();
}
}
global class BatchClass5 implements Database.Batchable<sObject> {
global final string query;
global BatchClass5(String q)
{
query = q;
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope)
{
List<Account> accns = new List<Account>();
List<Contact> lstcon= new List<contact>();
for(Account a : scope)
{
Account a1 = new Account();
contact c = new contact();
c.lastname = a1.name;
c.accountid = a1.id;
lstcon.add(c);
}
insert lstcon;
}
global void finish(Database.BatchableContext BC){
// Get the ID of the AsyncApexJob representing this batch job
// from Database.BatchableContext.
// Query the AsyncApexJob object to retrieve the current job's information.
}
}
testclass
@isTest
private class BatchClass5_Test5
{
static testmethod void m1()
{
Test.startTest();
Account a = new Account(Name='saikumar');
insert a;
contact c = new Contact();
c.LastName =a.Name;
c.AccountId= a.Id;
insert c;
system.assertEquals('saikumar',c.LastName);
BatchClass5 sync = new batchclass5('select id,name from Account');
ID batchprocessid = Database.executeBatch(sync);
Test.stopTest();
}
}
-
- sai kumar 433
- July 13, 2016
- Like
- 0
- Continue reading or reply
please write test class for this thanx adv?
global class BatchAapex1 implements Database.Batchable<Sobject>
{
global Database.QueryLocator start(Database.BatchableContext bc)
{
String query = 'select id,name from Account';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc,List<Account> Scope)
{
List<Account> acc = new List<Account>();
for(Account a:acc)
{
a.name = 'Mr.' +a.name;
acc.add(a);
}
update acc;
}
global void finish(Database.BatchableContext bc)
{
}
}
{
global Database.QueryLocator start(Database.BatchableContext bc)
{
String query = 'select id,name from Account';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc,List<Account> Scope)
{
List<Account> acc = new List<Account>();
for(Account a:acc)
{
a.name = 'Mr.' +a.name;
acc.add(a);
}
update acc;
}
global void finish(Database.BatchableContext bc)
{
}
}
-
- sai kumar 433
- July 13, 2016
- Like
- 1
- Continue reading or reply
please execute this test class for code coverage.........
global class BatchClass5 implements Database.Batchable<sObject> {
global final string query;
global BatchClass5(String q)
{
query = q;
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope)
{
List<Account> accns = new List<Account>();
List<Contact> lstcon= new List<contact>();
for(Account a : scope)
{
Account a1 = new Account();
contact c = new contact();
c.lastname = a1.name;
c.accountid = a1.id;
lstcon.add(c);
}
insert lstcon;
}
global void finish(Database.BatchableContext BC){
// Get the ID of the AsyncApexJob representing this batch job
// from Database.BatchableContext.
// Query the AsyncApexJob object to retrieve the current job's information.
}
}
testclass
@isTest
private class BatchClass5_Test5
{
static testmethod void m1()
{
Test.startTest();
Account a = new Account(Name='saikumar');
insert a;
contact c = new Contact();
c.LastName =a.Name;
c.AccountId= a.Id;
insert c;
system.assertEquals('saikumar',c.LastName);
BatchClass5 sync = new batchclass5('select id,name from Account');
ID batchprocessid = Database.executeBatch(sync);
Test.stopTest();
}
}
global final string query;
global BatchClass5(String q)
{
query = q;
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope)
{
List<Account> accns = new List<Account>();
List<Contact> lstcon= new List<contact>();
for(Account a : scope)
{
Account a1 = new Account();
contact c = new contact();
c.lastname = a1.name;
c.accountid = a1.id;
lstcon.add(c);
}
insert lstcon;
}
global void finish(Database.BatchableContext BC){
// Get the ID of the AsyncApexJob representing this batch job
// from Database.BatchableContext.
// Query the AsyncApexJob object to retrieve the current job's information.
}
}
testclass
@isTest
private class BatchClass5_Test5
{
static testmethod void m1()
{
Test.startTest();
Account a = new Account(Name='saikumar');
insert a;
contact c = new Contact();
c.LastName =a.Name;
c.AccountId= a.Id;
insert c;
system.assertEquals('saikumar',c.LastName);
BatchClass5 sync = new batchclass5('select id,name from Account');
ID batchprocessid = Database.executeBatch(sync);
Test.stopTest();
}
}
-
- sai kumar 433
- July 13, 2016
- Like
- 0
- Continue reading or reply
please execute this test class code coverage......
global class BatchClass2 implements Database.Batchable<sObject>{
global final String Query;
global final String Entity;
global final String Field;
global final String Value;
global BatchClass2(String q, String e, String f, String v){
Query=q; Entity=e; Field=f;Value=v;
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC,
List<sObject> scope){
for(Sobject s : scope){s.put(Field,Value);
} update scope;
}
global void finish(Database.BatchableContext BC){
}
}
test class
@isTest
public class BatchClass_Test2
{
static testMethod void test() {
Database.QueryLocator QL;
Database.BatchableContext BC;
List<Account> AcctList = new List<Account>();
BatchClass2 AU = new BatchClass2('Name', 'Test');
QL = AU.start(bc);
Database.QueryLocatorIterator QIT = QL.iterator();
while (QIT.hasNext())
{
Account Acc = (Account)QIT.next();
System.debug(Acc);
AcctList.add(Acc);
}
AU.execute(BC, AcctList);
AU.finish(BC);
}
}
global final String Query;
global final String Entity;
global final String Field;
global final String Value;
global BatchClass2(String q, String e, String f, String v){
Query=q; Entity=e; Field=f;Value=v;
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC,
List<sObject> scope){
for(Sobject s : scope){s.put(Field,Value);
} update scope;
}
global void finish(Database.BatchableContext BC){
}
}
test class
@isTest
public class BatchClass_Test2
{
static testMethod void test() {
Database.QueryLocator QL;
Database.BatchableContext BC;
List<Account> AcctList = new List<Account>();
BatchClass2 AU = new BatchClass2('Name', 'Test');
QL = AU.start(bc);
Database.QueryLocatorIterator QIT = QL.iterator();
while (QIT.hasNext())
{
Account Acc = (Account)QIT.next();
System.debug(Acc);
AcctList.add(Acc);
}
AU.execute(BC, AcctList);
AU.finish(BC);
}
}
-
- sai kumar 433
- July 12, 2016
- Like
- 0
- Continue reading or reply
write test class for program plz?
global class CaptureLastLoginDate implements Database.Batchable<sObject>{
//This is the query that is passed to the execute method. .
String ids = UserInfo.getUserId();
String query = 'SELECT id,LastLoginDate__c FROM User ';
global database.queryLocator start(Database.BatchableContext BC) {
System.debug(query);
return database.getQueryLocator(query);
}
//close start method
global void execute(Database.BatchableContext BC, List<sObject> scope){
List<Schema.User> u = new List<Schema.User> ();
for(sObject s: Scope){
Schema.User inv = (Schema.User)s;
inv.LastLoginDate__c= inv.LastLoginDate__c;
u.add(inv);
System.debug(u);
}
update u;
}
global void finish(Database.BatchableContext sc){
}
}
//This is the query that is passed to the execute method. .
String ids = UserInfo.getUserId();
String query = 'SELECT id,LastLoginDate__c FROM User ';
global database.queryLocator start(Database.BatchableContext BC) {
System.debug(query);
return database.getQueryLocator(query);
}
//close start method
global void execute(Database.BatchableContext BC, List<sObject> scope){
List<Schema.User> u = new List<Schema.User> ();
for(sObject s: Scope){
Schema.User inv = (Schema.User)s;
inv.LastLoginDate__c= inv.LastLoginDate__c;
u.add(inv);
System.debug(u);
}
update u;
}
global void finish(Database.BatchableContext sc){
}
}
-
- sai kumar 433
- July 12, 2016
- Like
- 0
- Continue reading or reply
please help test class for this thanks in advance
global class UpdateContactAddresses implements
Database.Batchable<sObject>, Database.Stateful {
// instance member to retain state across transactions
global Integer recordsProcessed = 0;
global Database.QueryLocator start(Database.BatchableContext bc) {
return Database.getQueryLocator(
'SELECT ID, BillingStreet, BillingCity, BillingState, ' +
'BillingPostalCode, (SELECT ID, MailingStreet, MailingCity, ' +
'MailingState, MailingPostalCode FROM Contacts) FROM Account ' +
'Where BillingCountry = \'USA\''
);
}
global void execute(Database.BatchableContext bc, List<Account> scope){
// process each batch of records
List<Contact> contacts = new List<Contact>();
for (Account account : scope) {
for (Contact contact : account.contacts) {
contact.MailingStreet = account.BillingStreet;
contact.MailingCity = account.BillingCity;
contact.MailingState = account.BillingState;
contact.MailingPostalCode = account.BillingPostalCode;
// add contact to list to be updated
contacts.add(contact);
// increment the instance member counter
recordsProcessed = recordsProcessed + 1;
}
}
update contacts;
}
global void finish(Database.BatchableContext bc){
System.debug(recordsProcessed + ' records processed. Shazam!');
AsyncApexJob job = [SELECT Id, Status, NumberOfErrors,
JobItemsProcessed,
TotalJobItems, CreatedBy.Email
FROM AsyncApexJob
WHERE Id = :bc.getJobId()];
// call some utility to send email
}
}
Database.Batchable<sObject>, Database.Stateful {
// instance member to retain state across transactions
global Integer recordsProcessed = 0;
global Database.QueryLocator start(Database.BatchableContext bc) {
return Database.getQueryLocator(
'SELECT ID, BillingStreet, BillingCity, BillingState, ' +
'BillingPostalCode, (SELECT ID, MailingStreet, MailingCity, ' +
'MailingState, MailingPostalCode FROM Contacts) FROM Account ' +
'Where BillingCountry = \'USA\''
);
}
global void execute(Database.BatchableContext bc, List<Account> scope){
// process each batch of records
List<Contact> contacts = new List<Contact>();
for (Account account : scope) {
for (Contact contact : account.contacts) {
contact.MailingStreet = account.BillingStreet;
contact.MailingCity = account.BillingCity;
contact.MailingState = account.BillingState;
contact.MailingPostalCode = account.BillingPostalCode;
// add contact to list to be updated
contacts.add(contact);
// increment the instance member counter
recordsProcessed = recordsProcessed + 1;
}
}
update contacts;
}
global void finish(Database.BatchableContext bc){
System.debug(recordsProcessed + ' records processed. Shazam!');
AsyncApexJob job = [SELECT Id, Status, NumberOfErrors,
JobItemsProcessed,
TotalJobItems, CreatedBy.Email
FROM AsyncApexJob
WHERE Id = :bc.getJobId()];
// call some utility to send email
}
}
-
- sai kumar 433
- July 12, 2016
- Like
- 0
- Continue reading or reply
plz execute this test class code coverage should above 75 thanks advance......
plz execute this test class i want code coverage above 75 thanks advance
class
global class BatchClass5 implements Database.Batchable<sObject> {
global final string query;
global BatchClass5(String q)
{
query = q;
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope)
{
List<Account> accns = new List<Account>();
List<Contact> lstcon= new List<contact>();
for(Account a : scope)
{
Account a1 = new Account();
contact c = new contact();
c.lastname = a1.name;
c.accountid = a1.id;
lstcon.add(c);
}
insert lstcon;
}
global void finish(Database.BatchableContext BC){
// Get the ID of the AsyncApexJob representing this batch job
// from Database.BatchableContext.
// Query the AsyncApexJob object to retrieve the current job's information.
}
}
Test class
@isTest
private class BatchClass5_Test5
{
static testmethod void m1()
{
Test.startTest();
Account a = new Account(Name='saikumar');
insert a;
contact c = new Contact();
c.LastName =a.Name;
c.AccountId= a.Id;
insert c;
system.assertEquals('saikumar',c.LastName);
BatchClass5 sync = new batchclass5('select id,name from Account');
ID batchprocessid = Database.executeBatch(sync);
Test.stopTest();
}
}
-
- sai kumar 433
- July 12, 2016
- Like
- 0
- Continue reading or reply
plz execute this test class i want code coverage above 75 thanks advance
class
global class BatchClass5 implements Database.Batchable<sObject> {
global final string query;
global BatchClass5(String q)
{
query = q;
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope)
{
List<Account> accns = new List<Account>();
List<Contact> lstcon= new List<contact>();
for(Account a : scope)
{
Account a1 = new Account();
contact c = new contact();
c.lastname = a1.name;
c.accountid = a1.id;
lstcon.add(c);
}
insert lstcon;
}
global void finish(Database.BatchableContext BC){
// Get the ID of the AsyncApexJob representing this batch job
// from Database.BatchableContext.
// Query the AsyncApexJob object to retrieve the current job's information.
}
}
Test class
@isTest
private class BatchClass5_Test5
{
static testmethod void m1()
{
Test.startTest();
Account a = new Account(Name='saikumar');
insert a;
contact c = new Contact();
c.LastName =a.Name;
c.AccountId= a.Id;
insert c;
system.assertEquals('saikumar',c.LastName);
BatchClass5 sync = new batchclass5('select id,name from Account');
ID batchprocessid = Database.executeBatch(sync);
Test.stopTest();
}
}
global class BatchClass5 implements Database.Batchable<sObject> {
global final string query;
global BatchClass5(String q)
{
query = q;
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope)
{
List<Account> accns = new List<Account>();
List<Contact> lstcon= new List<contact>();
for(Account a : scope)
{
Account a1 = new Account();
contact c = new contact();
c.lastname = a1.name;
c.accountid = a1.id;
lstcon.add(c);
}
insert lstcon;
}
global void finish(Database.BatchableContext BC){
// Get the ID of the AsyncApexJob representing this batch job
// from Database.BatchableContext.
// Query the AsyncApexJob object to retrieve the current job's information.
}
}
Test class
@isTest
private class BatchClass5_Test5
{
static testmethod void m1()
{
Test.startTest();
Account a = new Account(Name='saikumar');
insert a;
contact c = new Contact();
c.LastName =a.Name;
c.AccountId= a.Id;
insert c;
system.assertEquals('saikumar',c.LastName);
BatchClass5 sync = new batchclass5('select id,name from Account');
ID batchprocessid = Database.executeBatch(sync);
Test.stopTest();
}
}
-
- sai kumar 433
- July 12, 2016
- Like
- 0
- Continue reading or reply
plz execut this code errors getting
global class OpportunityBatch implements database.batchable<sObject>{ global String opptyList;
global Database.QueryLocator start(Database.BatchableContext info){ String status = ‘Submitted’;
List<Opportunity> opptyList = ‘select name,AccountName__c from Opportunity where status__c =\”+ status +’\” ;
return Database.getQueryLocator(opptyList);
}
global void execute(Database.batchableContext info,List<Opportunity> opptyList){ List<Opportunity> opportunitiesList = new List< Opportunity >();
for(Opportunity oppty: opptyList){ oppty.status__c = ‘Approved’; opportunitiesList.add(oppty);
}
Insert opportunitiesList;
}
global void finish(Database.batchableContext info){
}
global Database.QueryLocator start(Database.BatchableContext info){ String status = ‘Submitted’;
List<Opportunity> opptyList = ‘select name,AccountName__c from Opportunity where status__c =\”+ status +’\” ;
return Database.getQueryLocator(opptyList);
}
global void execute(Database.batchableContext info,List<Opportunity> opptyList){ List<Opportunity> opportunitiesList = new List< Opportunity >();
for(Opportunity oppty: opptyList){ oppty.status__c = ‘Approved’; opportunitiesList.add(oppty);
}
Insert opportunitiesList;
}
global void finish(Database.batchableContext info){
}
-
- sai kumar 433
- July 11, 2016
- Like
- 0
- Continue reading or reply
can uplz execute this code?
global class OpportunityBatch implements database.batchable<sObject>{ global String opptyList;
global Database.QueryLocator start(Database.BatchableContext info){ String status = ‘Submitted’;
List<Opportunity> opptyList = ‘select name,AccountName__c from Opportunity where status__c =\”+ status +’\” ;
return Database.getQueryLocator(opptyList);
}
global void execute(Database.batchableContext info,List<Opportunity> opptyList){ List<Opportunity> opportunitiesList = new List< Opportunity >();
for(Opportunity oppty: opptyList){ oppty.status__c = ‘Approved’; opportunitiesList.add(oppty);
}
Insert opportunitiesList;
}
global void finish(Database.batchableContext info){
}
global Database.QueryLocator start(Database.BatchableContext info){ String status = ‘Submitted’;
List<Opportunity> opptyList = ‘select name,AccountName__c from Opportunity where status__c =\”+ status +’\” ;
return Database.getQueryLocator(opptyList);
}
global void execute(Database.batchableContext info,List<Opportunity> opptyList){ List<Opportunity> opportunitiesList = new List< Opportunity >();
for(Opportunity oppty: opptyList){ oppty.status__c = ‘Approved’; opportunitiesList.add(oppty);
}
Insert opportunitiesList;
}
global void finish(Database.batchableContext info){
}
-
- sai kumar 433
- July 11, 2016
- Like
- 0
- Continue reading or reply
please write test class for this thanx adv?
global class BatchAapex1 implements Database.Batchable<Sobject>
{
global Database.QueryLocator start(Database.BatchableContext bc)
{
String query = 'select id,name from Account';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc,List<Account> Scope)
{
List<Account> acc = new List<Account>();
for(Account a:acc)
{
a.name = 'Mr.' +a.name;
acc.add(a);
}
update acc;
}
global void finish(Database.BatchableContext bc)
{
}
}
{
global Database.QueryLocator start(Database.BatchableContext bc)
{
String query = 'select id,name from Account';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc,List<Account> Scope)
{
List<Account> acc = new List<Account>();
for(Account a:acc)
{
a.name = 'Mr.' +a.name;
acc.add(a);
}
update acc;
}
global void finish(Database.BatchableContext bc)
{
}
}
-
- sai kumar 433
- July 13, 2016
- Like
- 1
- Continue reading or reply
plz execute this test code coverage plz
please execute this test class for code coverage.........
global class BatchClass5 implements Database.Batchable<sObject> {
global final string query;
global BatchClass5(String q)
{
query = q;
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope)
{
List<Account> accns = new List<Account>();
List<Contact> lstcon= new List<contact>();
for(Account a : scope)
{
Account a1 = new Account();
contact c = new contact();
c.lastname = a1.name;
c.accountid = a1.id;
lstcon.add(c);
}
insert lstcon;
}
global void finish(Database.BatchableContext BC){
// Get the ID of the AsyncApexJob representing this batch job
// from Database.BatchableContext.
// Query the AsyncApexJob object to retrieve the current job's information.
}
}
testclass
@isTest
private class BatchClass5_Test5
{
static testmethod void m1()
{
Test.startTest();
Account a = new Account(Name='saikumar');
insert a;
contact c = new Contact();
c.LastName =a.Name;
c.AccountId= a.Id;
insert c;
system.assertEquals('saikumar',c.LastName);
BatchClass5 sync = new batchclass5('select id,name from Account');
ID batchprocessid = Database.executeBatch(sync);
Test.stopTest();
}
}
global class BatchClass5 implements Database.Batchable<sObject> {
global final string query;
global BatchClass5(String q)
{
query = q;
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope)
{
List<Account> accns = new List<Account>();
List<Contact> lstcon= new List<contact>();
for(Account a : scope)
{
Account a1 = new Account();
contact c = new contact();
c.lastname = a1.name;
c.accountid = a1.id;
lstcon.add(c);
}
insert lstcon;
}
global void finish(Database.BatchableContext BC){
// Get the ID of the AsyncApexJob representing this batch job
// from Database.BatchableContext.
// Query the AsyncApexJob object to retrieve the current job's information.
}
}
testclass
@isTest
private class BatchClass5_Test5
{
static testmethod void m1()
{
Test.startTest();
Account a = new Account(Name='saikumar');
insert a;
contact c = new Contact();
c.LastName =a.Name;
c.AccountId= a.Id;
insert c;
system.assertEquals('saikumar',c.LastName);
BatchClass5 sync = new batchclass5('select id,name from Account');
ID batchprocessid = Database.executeBatch(sync);
Test.stopTest();
}
}
- sai kumar 433
- July 13, 2016
- Like
- 0
- Continue reading or reply
please execute this test class code coverage......
global class BatchClass2 implements Database.Batchable<sObject>{
global final String Query;
global final String Entity;
global final String Field;
global final String Value;
global BatchClass2(String q, String e, String f, String v){
Query=q; Entity=e; Field=f;Value=v;
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC,
List<sObject> scope){
for(Sobject s : scope){s.put(Field,Value);
} update scope;
}
global void finish(Database.BatchableContext BC){
}
}
test class
@isTest
public class BatchClass_Test2
{
static testMethod void test() {
Database.QueryLocator QL;
Database.BatchableContext BC;
List<Account> AcctList = new List<Account>();
BatchClass2 AU = new BatchClass2('Name', 'Test');
QL = AU.start(bc);
Database.QueryLocatorIterator QIT = QL.iterator();
while (QIT.hasNext())
{
Account Acc = (Account)QIT.next();
System.debug(Acc);
AcctList.add(Acc);
}
AU.execute(BC, AcctList);
AU.finish(BC);
}
}
global final String Query;
global final String Entity;
global final String Field;
global final String Value;
global BatchClass2(String q, String e, String f, String v){
Query=q; Entity=e; Field=f;Value=v;
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC,
List<sObject> scope){
for(Sobject s : scope){s.put(Field,Value);
} update scope;
}
global void finish(Database.BatchableContext BC){
}
}
test class
@isTest
public class BatchClass_Test2
{
static testMethod void test() {
Database.QueryLocator QL;
Database.BatchableContext BC;
List<Account> AcctList = new List<Account>();
BatchClass2 AU = new BatchClass2('Name', 'Test');
QL = AU.start(bc);
Database.QueryLocatorIterator QIT = QL.iterator();
while (QIT.hasNext())
{
Account Acc = (Account)QIT.next();
System.debug(Acc);
AcctList.add(Acc);
}
AU.execute(BC, AcctList);
AU.finish(BC);
}
}
- sai kumar 433
- July 12, 2016
- Like
- 0
- Continue reading or reply
Batch: Too many query rows: 50001
I am executing the batch manually from the developer console and I am getting this error.
System.LimitException: Too many query rows: 50001
Details Below:
Batch Execution:
batchDataGeneration batchable = new batchDataGeneration();
database.executeBatch(batchable);
Error Information:
14:09:41:000 FATAL_ERROR Class.Database.QueryLocatorIterator.hasNext: line 41, column 1
14:09:41:000 FATAL_ERROR Class.batchDataGeneration.execute: line 516, column 1
This is the code from Line 41 and Line 516.
Line 41 Code:
return Database.getQueryLocator([SELECT id,
Name,
Frequency__c,
Start_Date__c,
Activated_Date__c, //Line 41
Date_to_Create_Next_Year_s_Targets__c
FROM Measure__c
where
status__c =:System.Label.Activated
]);
Line 516 code:
Database.QueryLocator qplant = Database.getQueryLocator([Select Id, Fiscal_Period__c, Plant__c,Date__c, Measure__c from Plant_Measure__c where Measure__c in : measureToExecute]);
Database.QueryLocatorIterator plantIterator = qplant.iterator();
while (plantIterator.hasNext()) //Line 516
{
Plant_Measure__c a = (Plant_Measure__c)plantIterator.next();
mapPlantMeasureIds.put(a.id,a);
}
I know the counts are based on the transaction and not on a single query output. I have used Database.querylocator and still I am getting this error. Could someone help me what could be the problem with this code?
System.LimitException: Too many query rows: 50001
Details Below:
Batch Execution:
batchDataGeneration batchable = new batchDataGeneration();
database.executeBatch(batchable);
Error Information:
14:09:41:000 FATAL_ERROR Class.Database.QueryLocatorIterator.hasNext: line 41, column 1
14:09:41:000 FATAL_ERROR Class.batchDataGeneration.execute: line 516, column 1
This is the code from Line 41 and Line 516.
Line 41 Code:
return Database.getQueryLocator([SELECT id,
Name,
Frequency__c,
Start_Date__c,
Activated_Date__c, //Line 41
Date_to_Create_Next_Year_s_Targets__c
FROM Measure__c
where
status__c =:System.Label.Activated
]);
Line 516 code:
Database.QueryLocator qplant = Database.getQueryLocator([Select Id, Fiscal_Period__c, Plant__c,Date__c, Measure__c from Plant_Measure__c where Measure__c in : measureToExecute]);
Database.QueryLocatorIterator plantIterator = qplant.iterator();
while (plantIterator.hasNext()) //Line 516
{
Plant_Measure__c a = (Plant_Measure__c)plantIterator.next();
mapPlantMeasureIds.put(a.id,a);
}
I know the counts are based on the transaction and not on a single query output. I have used Database.querylocator and still I am getting this error. Could someone help me what could be the problem with this code?
- Madhavi Valavala
- July 12, 2016
- Like
- 0
- Continue reading or reply
please help test class for this thanks in advance
global class UpdateContactAddresses implements
Database.Batchable<sObject>, Database.Stateful {
// instance member to retain state across transactions
global Integer recordsProcessed = 0;
global Database.QueryLocator start(Database.BatchableContext bc) {
return Database.getQueryLocator(
'SELECT ID, BillingStreet, BillingCity, BillingState, ' +
'BillingPostalCode, (SELECT ID, MailingStreet, MailingCity, ' +
'MailingState, MailingPostalCode FROM Contacts) FROM Account ' +
'Where BillingCountry = \'USA\''
);
}
global void execute(Database.BatchableContext bc, List<Account> scope){
// process each batch of records
List<Contact> contacts = new List<Contact>();
for (Account account : scope) {
for (Contact contact : account.contacts) {
contact.MailingStreet = account.BillingStreet;
contact.MailingCity = account.BillingCity;
contact.MailingState = account.BillingState;
contact.MailingPostalCode = account.BillingPostalCode;
// add contact to list to be updated
contacts.add(contact);
// increment the instance member counter
recordsProcessed = recordsProcessed + 1;
}
}
update contacts;
}
global void finish(Database.BatchableContext bc){
System.debug(recordsProcessed + ' records processed. Shazam!');
AsyncApexJob job = [SELECT Id, Status, NumberOfErrors,
JobItemsProcessed,
TotalJobItems, CreatedBy.Email
FROM AsyncApexJob
WHERE Id = :bc.getJobId()];
// call some utility to send email
}
}
Database.Batchable<sObject>, Database.Stateful {
// instance member to retain state across transactions
global Integer recordsProcessed = 0;
global Database.QueryLocator start(Database.BatchableContext bc) {
return Database.getQueryLocator(
'SELECT ID, BillingStreet, BillingCity, BillingState, ' +
'BillingPostalCode, (SELECT ID, MailingStreet, MailingCity, ' +
'MailingState, MailingPostalCode FROM Contacts) FROM Account ' +
'Where BillingCountry = \'USA\''
);
}
global void execute(Database.BatchableContext bc, List<Account> scope){
// process each batch of records
List<Contact> contacts = new List<Contact>();
for (Account account : scope) {
for (Contact contact : account.contacts) {
contact.MailingStreet = account.BillingStreet;
contact.MailingCity = account.BillingCity;
contact.MailingState = account.BillingState;
contact.MailingPostalCode = account.BillingPostalCode;
// add contact to list to be updated
contacts.add(contact);
// increment the instance member counter
recordsProcessed = recordsProcessed + 1;
}
}
update contacts;
}
global void finish(Database.BatchableContext bc){
System.debug(recordsProcessed + ' records processed. Shazam!');
AsyncApexJob job = [SELECT Id, Status, NumberOfErrors,
JobItemsProcessed,
TotalJobItems, CreatedBy.Email
FROM AsyncApexJob
WHERE Id = :bc.getJobId()];
// call some utility to send email
}
}
- sai kumar 433
- July 12, 2016
- Like
- 0
- Continue reading or reply