A dev created a class that implements the Queueable Interface as follows:
public class without sharing OrderQueueableJob implements Queueable{
public void execute(QueueableContext context){
// logic
System.enqueueJob(New OrderQueueableJob));
}
}
As part of the deployment process, the dev is asked to create a corresponding test class. Which two actions should the dev take to successfully execute the test class?
A. Implement seeAllData=True to ensure the Queueable job is able to run in bulk mode.
B. Ensure the running user of the test class has, at least, View All permissions on the Order object.
C. Enclose System.enqueuJob(new OrderQueueableJob) within Test.startTest() and Test.stopTest()
D. Implement Test. isRunningTest() to prevent chaining jobs during test execution.
How should a developer assert that a trigger with an asynchronous process has successfully run?
A. Create at test data in the test class, use System.runAs() to invoke the trigger, then perform assertions.
B. Insert records into Salesforce, use seeAllData-true, then perform assertions.
C. Create all test data, use @future In the test class, then perform assertions.
D. Create all test data in the test class, invoke Test.startTest() and Test.stopTest() and then perform assertions.
Explanation:
Test.startTest() and Test.stopTest() are used to ensure that any asynchronous processes (like @future methods, batch Apex, or queueable jobs) have been executed and completed within a test method. These methods simulate a fresh execution context and allow the developer to assert that the asynchronous process was executed successfully.
Universal Containers has an Apex trigger on Account that creates an Account Plan record when an Account is marked as a Customer. Recently a record-triggered flow was added so that whenever an Account is marked as a Customer, a ‘Customer Since’ date field is updated with today’s date. Since the addition of the flow, two Account Plan records are created whenever the Account is marked as a Customer. What might cause this to happen?
A. The flow is configured to evaluate when a record is created and every time it is edited.
B. The Apex trigger is not bulk safe and calls insert inside of a for loop.
C. The Apex trigger does not use a static variable to ensure it only fires once.
D. The flow is configured to use an ‘Update Records’ element.
Explanation:
In Salesforce, both a trigger and a flow could be updating the same record, causing the trigger to run multiple times. If the Apex trigger doesn't use a static variable to prevent multiple executions in a single transaction, it can result in creating duplicate records. The static variable ensures that the trigger only fires once, even if the record is updated multiple times within the same transaction.
There are user complaints about slow render times of a custom data table within a Visualforce page that loads thousands of Account records at once. What can a developer do to help alleviate such issues?
A. Use the transient keyword in the Apex code when querying the Account records
B. Use JavaScript remoting to query the accounts
C. Use the standard Account List controller and implement pagination
D. Upload a third-party data table library as a static resource
A developer is building a Lightning web component that searches for Contacts and must communicate the search results to other Lightning web components when the search completes. What should the developer do to implement the communication?
A. Publish an event on an event channel.
B. Fire an application event.
C. Publish a message on a message channel.
D. Fire a custom component event.
A developer is debugging an Apex-based order creation process that has a requirement to have three savepoints, SP1, SP2, and 5P3 {created in order), before the final execution of the process. During the final execution process, the developer has a routine to roll back to SP1 for a given condition. Once the condition is fixed, the code then calls 2 roll back to SP3 to continue with final execution. However, when the roll back to SP3 is called, a Funtime error occurs. Why does the developer receive a runtime error?
A. SP3 became invalid when SP1 was rolled back.
B. The developer has too many DML statements between the savepoints.
C. The developer used too many savepoints in one trigger session.
D. The developer should have called SF2 before calling SP3.
A developer must perform a complex SOQL query that joins two objects in a Lightning component. How can the Lightning component execute the query?
A. Invoke an Apex class with the method annotated as @AuraEnabled to perform the query
B. Use the Salesforce Streaming API to perform the SOQL query
C. Create a Process Builder to execute the query and invoke from the Lightning component
D. Write the query in a custom Lightning web component wrapper and invoke from the Lightning component
Universal Containers implements a private sharing model for the Convention_Attendee_ _c custom object. As part of a new quality assurance effort, the company created an Event_Reviewer_ _c user lookup field on the object. Management wants the event reviewer to automatically gain Read/Write access to every record they are assigned to. What is the best approach to ensure the assigned reviewer obtains Read/Write access to the record?
A. Create a criteria-based sharing rule on the Convention Attendee custom object to share the records to a group of Event Reviewers.
B. Create an After Insert trigger on the Convention Attendee custom object, and use Apex Sharing Reasons and Apex Managed Sharing.
C. Create criteria-based sharing rules on the Convention Attendee custom object to share the records with the Event Reviewers.
D. Create a Before Insert trigger on the Convention Attendee custom object, and use Apex Sharing Reasons and Apex Managed Sharing.
Users report that a button on a custom Lightning web component (LWC) is not saving the data they enter. The button looks to be clicked, but the LWC simply sits there, seemingly doing nothing. What should the developer use to ensure error messages are properly displayed?
A. Add a try-catch block surrounding the DML statement.
B. Use the Database method with a110rNone Set to false.
C. Add the tag to the component.
D. Add JavaScript and HTML to display an error message.
Which statement is true regarding savepoints?
A. You can roll back to any savepoint variable created in any order.
B. Static variables are not reverted during a rollback.
C. Reference to savepoints can cross trigger invocations.
D. Savepoints are not limited by DML statement governor limits.
Universal Containers decided to use Salesforce to manage a new hire interview process. A custom object called Candidate was created with organization-wide defaults set to Private. A lookup on the Candidate object sets an employee as an Interviewer. What should be used to automatically give Read access to the record when the lookup field is set to the Interviewer user?
A. The record can be shared using an Apex class.
B. The record can be shared using a permission set.
C. The record can be shared using a sharing rule.
D. The record cannot he shared with the current setup.
What is the best practice to initialize a Vizualforce page in a test class?
A. Use Test. setCurrentPage (Page. MyTeatPage);
B. Use Test. currantPage .getParamatars put (MyTaestPaga) ;
C. Use controller. currentPage. setPage (MyTastfage) ;
D. Use Test. setCurrentPage MyTestPags;
Page 3 out of 17 Pages |
Previous |