How to insert account records in apex class?
Create an Apex test class called ‘AddPrimaryContactTest’. In the test class, insert 50 Account records for BillingState “NY” and 50 Account records for BillingState “CA”. Create an instance of the AddPrimaryContact class, enqueue the job and assert that a Contact record was inserted for each of the 50 Accounts with the BillingState of “CA”.
How to create queueable apex class that inserts contacts?
The execute method must query for a maximum of 200 Accounts with the BillingState specified by the State abbreviation passed into the constructor and insert the Contact sObject record associated to each Account. Look at the sObject clone () method. Create an Apex test class called ‘AddPrimaryContactTest’.
How does an INSERT statement in apex work?
An insert statement bulk inserts the list of accounts as an argument. Then, the second account record is updated, the billing city is updated, and the update statement is called to persist the change in the database. // Update account Acme2. // Update the billing city. // Make the update call.
How to create a sobject clone in apex?
Look at the sObject clone () method. Create an Apex test class called ‘AddPrimaryContactTest’. In the test class, insert 50 Account records for BillingState “NY” and 50 Account records for BillingState “CA”.
Where do I find the custom object in apex?
You should be able to see the newly inserted (commited) object via the Salesforce UI. Or, use the line in the code that I provided that shows you the Id, and use that to find the object in Apex Explorer. Or, use Apex Explorer to display a list of most recently created CustomObject__c, order by createddate desc.
How to create unit test for queueable apex?
Create an instance of the AddPrimaryContact class, enqueue the job and assert that a Contact record was inserted for each of the 50 Accounts with the BillingState of “CA”. The unit tests must cover all lines of code included in the AddPrimaryContact class, resulting in 100% code coverage.