Executing the method 'getAccount' from the Apex class 'AccountManager' failed. Either the service isn't configured with the correct urlMapping, is not global, does not have the proper method name or does not return the requested account and all of its contacts.
Hello @Nishkam Agrawal
,
TestFactory is a custom class which was created into this step -
Or just follow this Solution -
1. Create a Apex class TestFactory
2. Copy this code
@isTest
public class TestFactory {
public static Account getAccount(String name, Boolean doInsert){
Account a = new Account(name = name);
if(doInsert){
insert a;
}
return a;
}
public static Contact getContact(Id accountId, String fname, String lname, Boolean doInsert){
Contact c = new Contact(firstName = fname, lastName = lname, accountId = accountId);
if(doInsert){
insert c;
}
return c;
}
public static void generateAccountWithContacts(Integer numContacts){
Account a = getAccount('default account ltd', true);
List<Contact> contacts = new List<Contact>();
for(Integer i = 0; i < numContacts; i++){
String contactName = 'contact' + i;
contacts.add(getContact(a.id, contactName, contactName, false));
}
insert contacts;
}
public static Opportunity[] generateOppsForAccount(id accountId, Decimal amount, Integer numOpps){
List<Opportunity> opps = new List<Opportunity>();
for(Integer i = 0; i < numOpps; i++){
Opportunity o = new Opportunity();
o.name = 'Account ' + i;
o.accountId = accountid;
o.amount = amount;
o.closeDate = Date.today().addDays(5);
o.stageName = 'Prospecting';
opps.add(o);
}
return opps;
}
public static User generateUser(String profileName){
UserRole userRole = new UserRole(DeveloperName = 'TestingTeam', Name = 'Testing Team');
insert userRole;
User u = new User(
ProfileId = [SELECT Id FROM Profile WHERE Name = :profileName].Id,
LastName = 'last',
Email = 'Cpt.Awesome@awesomesauce.com',
Username = 'Cpt.Awesome@awesomesauce.com',
CompanyName = 'Testing Co',
Title = 'Captian',
Alias = 'alias',
TimeZoneSidKey = 'America/Los_Angeles',
EmailEncodingKey = 'UTF-8',
LanguageLocaleKey = 'en_US',
LocaleSidKey = 'en_US',
UserRoleId = userRole.Id
);
insert u;
return u;
}
}
I am a member of Trailhead Help, Can you please check with the above suggestions and let us know if the issue still exists or is resolved? If it is resolved, please post the solution or mark any one of them above which helped you to resolve your query as it "Best Answer" to close this thread. If not, kindly provide a few more details of the badge along with the error message.
Thank You!
++TrailheadHelpFollowUp
Eric Burté (DEVOTEAM) Forum Ambassador
Hello @Nishkam Agrawal
please see this similar threads and proposed solutions
https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007T46SOSAZEric