I need to cover some new functionality with tests, and for this I need to convert the lead in the test. I have two sandboxes (one is where we are developing; the second is for testing). In the first, everything is OK - the test passes and covers my new functionality. And on the second - an error, the test does not pass:
Methods defined as TestMethod do not support Web service callouts.
I have done a lot of manipulations in order to try to figure out where the callout occurs, but to no avail. Please advise me how I can identify the callout?
method for covering
public void fillingAddressForCustomer(List<Lead> newLeads, List<Lead> oldLeads) {
Set<Id> accountsId = new Set<Id>();
for(Integer i = 0, s = Trigger.new.size(); i < s; i++) {
if(!oldLeads[i].isConverted && newLeads[i].isConverted) {
accountsId.add(newLeads[i].convertedAccountId);
}
} if(accountsId.size() > 0) {
Map<Id, Account> mapAccounts = new Map<Id,Account>([SELECT BillingAddress, BillingCity, BillingCountry, BillingPostalCode, BillingState, BillingStreet, ShippingAddress
FROM Account
WHERE ID =:accountsId]);
List<Account> accountsForUpdate = new List<Account>();
for (Lead l : newLeads) {
Account tempAcc = mapAccounts.get(l.convertedAccountId);
if((l.City != null
|| l.Country != null
|| l.PostalCode != null
|| l.State != null
|| l.Street != null)
&& tempAcc.BillingAddress != null
&& (tempAcc.BillingCity != l.City
|| tempAcc.BillingCountry != l.Country
|| tempAcc.BillingPostalCode != l.PostalCode
|| tempAcc.BillingState != l.State
|| tempAcc.BillingStreet != l.Street)) {
tempAcc.ShippingCity = l.City;
tempAcc.ShippingCountry = l.Country;
tempAcc.ShippingPostalCode = l.PostalCode;
tempAcc.ShippingState = l.State;
tempAcc.ShippingStreet = l.Street;
accountsForUpdate.add(tempAcc);
}
}
if (accountsForUpdate.size() > 0) {
update accountsForUpdate;
}
}
}
test method
@isTest private static void testFillingAddressForCustomer() {
Account testAccount = TestFactory.createAccount('Test Account');
testAccount.Was_Lead__c = false;
testAccount.BillingCountry = 'Country';
testAccount.BillingCity = 'City';
testAccount.BillingPostalCode = 'Postal Code';
testAccount.BillingState = 'State';
testAccount.BillingStreet = 'Street';
insert testAccount;
Lead testLead = new Lead(Email = '[email protected]',
LastName = 'Test',
Country = 'Lead Country',
City = 'Lead City',
PostalCode = 'Lead Postal Code',
State = 'Lead State',
Street = 'Lead Street');
insert testLead;
test.startTest();
Database.LeadConvert lc = new Database.LeadConvert();
lc.setDoNotCreateOpportunity(true);
lc.setAccountId(testAccount.Id);
lc.setLeadId(testLead.id);
lc.setConvertedStatus('Closed - Converted');
LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());
test.stopTest();
testAccount = [SELECT ShippingAddress FROM ACCOUNT WHERE ID =: lcr.getAccountId() LIMIT 1];
System.assertNotEquals(testAccount.ShippingAddress, null);
}