Questions tagged [fflib]
The fflib tag has no usage guidance.
56
questions
1
vote
1
answer
29
views
How to verify non-deterministic field values in a unit test that does no DML?
for fflib / apexmocks users
Let's say you have a class/method that inserts new objects where a field value is non-deterministic, say, a UUID
public class AccountsServiceImpl {
public void ...
0
votes
1
answer
44
views
BASHFUL error running testmethod using ApexMocks (StubApi)
Given fflib code that looks like
for (Contact c: contacts) {
uow.registerEmail(someEmailMessage);
}
With testmethod ApexMocks verify (which uses StubApi)
((fflib_SObjectUnitOfWork)mocks.verify(...
2
votes
1
answer
113
views
How to disable CRUD/FLS check from fflib domain layer for only some specific flows. By default it is enabled for all flows using base class
1- I am using fflib for my managed package.
2- By default CRUD/FLS are enabled for all domain/selector flows (Using Base class)
3- In a specific method which is used by site guest users, I want to ...
0
votes
2
answers
43
views
Mocking BusinessHours records returns System.MathException: null
I am stuck on a test method and any help would be highly appreciated.
To provide some context: I created a method that queries a specific BusinessHours record on the DB and validates if a Case was ...
13
votes
2
answers
259
views
fflib as Second Generation Managed Package (2GP)
So, in a project of mine (a Second Generation Managed Package) I have a dependency on fflib.
My initial idea was to include fflib-apex-common and fflib-apex-mocks as 2GPs with the same namespace as my ...
-2
votes
2
answers
47
views
Apex Mock Domain Factory Error
Running into an issue with Implementing Apex Mocking. Everything works fine until I try to set the domain mock in the domain class. Here is My Code:
@IsTest
private static void testMocking(){
...
2
votes
1
answer
199
views
Any option for mocking custom metadata records using fflib-ApexMocks and fflib-apex-common?
Given a project based on fflib-apex-common and using fflib-ApexMocks for unit testing, I would like to mock Custom Metadata records and stop using real org values. Custom metadata queries are ...
0
votes
1
answer
189
views
Apex Mocks avoiding insert when committing fflib Unit of Work
I'm new in Apex Mocks but I'm really excited about all it's advantages. I'm trying to build test without DML. Here is a method I'm trying to test at the moment:
public Id createMmDocument(String ...
0
votes
1
answer
87
views
Testing service methods which fflib unit of work in method's signature
So what I'm tying to do is to unit test one of methods in my service:
@TestVisible
private void insertSerialNumbers(List<AST_Material_Document_Item__c> documentItems, Map<Id, Asset> ...
0
votes
2
answers
55
views
fflib Tests fail with required fields on Account
I was looking to find out what approach to take with the fflib libraries and testing. I have added the fflib common and mocks files to my project and org. When I run the tests for the whole project I ...
6
votes
2
answers
500
views
FFLib Selectors with SOQL For Loops
I'm considering implementation of FFLib, or at least parts of it, throughout our enterprise. Right now I'm focusing on the Selector and Query classes to consolidate our SOQL into a Selector Layer. I'm ...
0
votes
1
answer
60
views
Questions regarding implementing fflib_SObjectSelector
As I understand it a selector would be implemented for each SObject that you need it for i.e
AccountSelector extends fflib_SObjectSelector {}
ServiceAppointmentSelector extendes fflib_SObjectSelector ...
1
vote
1
answer
262
views
Apex Mocks test error for Domain class
We have been using FFLIB(Apex commons) in our org.I have been trying to write a test case for a Content Document Link (Salesforce Files)Domain layer But i have been getting the error : "System....
1
vote
1
answer
76
views
fflib service layer naming convention
I read an article about the service layer here. The names for the services are OpportunitiesService.cls or AccountsService.cls. Does the names of the services always follow the pattern {plural Sobject}...
2
votes
1
answer
139
views
not possible to register an object id with an object of the same type
I am registering two new accounts using the fflib unit of work. The code as follows:
fflib_ISObjectUnitOfWork uow = Application.unitOfWork.newInstance();
Account account1 = new Account(Name = '...
0
votes
1
answer
147
views
Register relationship with FFLIB unit of work
I have been trying to store a big payload as Files and link it to the object EVENT_LOG__c.In the Service layer we have few methods that are called for different events.
public void processEvent(String ...
0
votes
1
answer
45
views
Storing JSON payload as Files based on unit of work pattern
I have been trying to store a huge JSON Payload(received as a response from external Integration) as a salesforce File and attach it to the Object's(called as EventLog) record.But my org is based on ...
0
votes
0
answers
125
views
Enterprise Pattern : AccountsSelector: @Override specified for non-overriding method: List<Schema.SObjectField> sptSObjectFieldList()
We have AccountsSelector class extending ApplicationSObjectSelector abstract class from at4dx library.
ApplicationSObjectSelector class has public virtual method getSObjectFieldList()
I have ...
3
votes
2
answers
408
views
Support of database class methods with fflib UnitOfWork
I am getting a JSON response with multiple account records which I have to upsert in Account object. I am trying to implement this requirement using UOW provided by the fflib library.
Is there a way ...
0
votes
1
answer
369
views
Why does the FFLIB framework enforce CRUD security and sharing rules by default for Domains?
In FFLIB, a Domain enforces CRUD security and sharing rules by default. We use FFLIB Domains for implementing triggers. In the Salesforce standard, triggers run in system context, meaning they don't ...
8
votes
2
answers
950
views
Mocking Database.QueryLocator in Unit Tests using fflib Apex Mocks
Assume we have some basic AccountSelector class that has different implementations of the selector method. QueryLocator variation is helpful once we need to take advantage of SOQL for loops or to use ...
1
vote
1
answer
205
views
SOQL aggregate statement using FFLIB
Please, It is possible to write a SOQL aggregate statement using fflib_SObjectSelector?
For example, I have this SOQL request:
SELECT DX_Support__r.Name support, SUM(total__c) total FROM ...
0
votes
1
answer
270
views
System.QueryException: No such column 'CurrencyIsoCode' on entity 'OpportunityContactRole' while using fflib library
I am using fflib library and querying OpportunityContactRole object in trigger. But its throwing below error ->
Opportunity_Trigger: execution of BeforeUpdate caused by: System.QueryException: No ...
1
vote
0
answers
52
views
fflib and Knowledge__kav
does anyone use ffLib with Knowledge__kav?
I am facing weird issue when using those.
When user without knowledge access fire logic and go trough centralized class that stores references to all ...
0
votes
1
answer
221
views
Mock Selector in fflib
I am new to fflib, currently I am struggling with tests. Maybe there is someone who can help me :)
public class someclass{
SEL_Contact contactSel = SEL_Contact.newInstance();
public ...
0
votes
2
answers
181
views
creating tasks for a queue using fflib
I created a queue and set the queue to handle the task Object:
I can assign a task to a queue and insert the task if I do it via the "Anonymous apex"; however, if I run the same code via a ...
1
vote
1
answer
982
views
mocking database methods using fflib
As fas as I know it is not possible to mock the methods under Database because salesforce does not allow mocking static methods. However, One can circumvent this limitation by wrapping the static ...
2
votes
1
answer
609
views
mocking related objects using fflib
I am trying to add records to Opportunity.OpportunityLineItems; however, I got an error that that field is read-only. I tried to mock that field via fflib, code as follows:
fflib_ApexMocks mocks = new ...
1
vote
1
answer
178
views
ApexMocks - Not able to verify Insert of a sObject record
I'm trying to write unit test (using fflib framework) for a piece of functionality where on insertion of an object files are created.
This is the main piece of code i'm trying to cover:
...
0
votes
1
answer
167
views
issue with pre-defined execution order of fflib unit of work
The commitWork() method in the class fflib_SObjectUnitOfWork has a predefined order of execution that always sends the emails at last, as it can be seen as follows:
private void doCommitWork()
{
...
0
votes
1
answer
328
views
benefits of using interfaces in fflib service layer
I am looking at the fflib-apex-common-samplecode, and I see that the AccountsSelector uses an interface IAccountsSelector, see below:
public class AccountsSelector extends fflib_SObjectSelector ...
4
votes
2
answers
427
views
ApexMocks, Test.createStub and System.TypeException @Override specified for non-overriding method
Simple use case for ApexMocks of a Service layer class, something I've done a 100 times
fflib_ApexMocks mocks = new fflib_ApexMocks();
OpportunitiesServiceImpl mockOpportunitiesService = (...
0
votes
1
answer
112
views
fflib-apexmock not getting verified
I am using fflib mocks and at4dx
Trying to test a simple controller method which is calling a selector method.
Controller Method:
public with sharing class MyController {
public static String ...
3
votes
1
answer
173
views
register relationship
I am using the unit of work design pattern (fflib) to persist objects; however, it does not register relationships, code as follows:
fflib_SObjectUnitOfWork uow = new fflib_SObjectUnitOfWork(
...
1
vote
2
answers
1k
views
How to use fflib_SObjectSelector class? [closed]
I just came across Apex Enterprise Design patterns and this architecture has been really useful. I am trying to implement the selector layer and when I try to extend the fflib_SObjectSelector class, I ...
1
vote
1
answer
416
views
Selector Layer - fflib_SObjectSelector error on Cross-Object and Sub-Select Queries
I'm working on a skipe for this fflib and I'm facing this error when I try to execute a Cross-Object or Sub-Select query:.
|WARN|fflib_QueryFactory.subselectQuery(Schema.SObjectType) is deprecated ...
5
votes
1
answer
2k
views
Why are my matchers not working after adding an overloaded method?
To help getting past our permission checks during unit tests to test actual functionality, I created a mocking class so people could just call the mocking method they needed from that class for the ...
2
votes
1
answer
73
views
Do we have to force all FFLIB classes with `with sharing` keywords to pass security review?
I'm using FFLIB classes in my managed package and i just wanted to know if i should mark FFLIB classes use in my package with with sharing keyword to follow security review requirements ?
Thanks,
4
votes
1
answer
95
views
How to mock App Exchange package's API response?
I am using an app exchange package in my code, they have exposed a few global methods that I can use to get my job done. It all works beautifully. The issue comes with testing.
I want to test ...
0
votes
1
answer
607
views
Doing something dumb with queryfactory and relationship query
I've been using the fflib pattern in salesforce development since before the introduction of the query factory. I'm having a problem making a simple relationship query work using the queryfactory. ...
2
votes
1
answer
431
views
Pros and cons of fflib-common-apex for ISV
This question is aimed to summarize advantages and disadvantages of using fflib-common-apex for developing managed packages for AppExchange. Overall fflib-common-apex and mocks are helpful and speed ...
5
votes
2
answers
2k
views
fflib selector - configure Read and FLS - fflib_SObjectSelector vs fflib_QueryFactory
We're working on a managed package and planning to list it on AppExchange. We are using the fflib-apex-common library in our app.
Now the question: what's the best way to configure Read and FLS when ...
2
votes
2
answers
88
views
Which unit tests should check read access for user?
We are using fflib-apex-common in our project, and we implemented several selectors. By default fflib_SObjectSelector checks for Read permission. But now I am wondering what type of tests, and at what ...
1
vote
1
answer
2k
views
FFLIB Unit of work. how to register a relationship on both new and existing record?
I have been trying to use the FFLIB enterprise service layer module to both insert a new record and update an existing record while registering relationships between both but I am unable to update the ...
1
vote
1
answer
3k
views
fflib apex common Usage [closed]
We have a existing salesforce implementation, we have most of the logic in triggers and trigger handlers. We are still using classic and no mobile or other UI. But still we are planning to implement ...
0
votes
1
answer
225
views
How to add mandatory where clause in SObjectSelector subclasses
I have a Product selector class and would like to enforce a mandatory check on a Product field for every query on products. I'm assuming it has something to do with the QueryFactory, but since there ...
5
votes
1
answer
333
views
What value is there in an Application Service Provider
As I implement Andrew Fawcett's, Apex Common library referring to the fflib-apex-common-samplecode when necessary, I note that his ObjectService classes (i.e. OpportunitiesService.cls) are really more ...
4
votes
1
answer
584
views
Apex Enterprise Patterns: Should UOW only be used with a DML transaction?
After completing the Apex Enterprise Patterns (AEP) trails from trailhead, there are a few questions that I have. One being, when is it necessary to use the Unit of Work (UOW) layer? Considering it is ...
2
votes
1
answer
3k
views
Salesforce Selector layer - subquery
We have been using FF library for Separation of Concerns framework and it is working great. We need to add subquery to it, but running into issues. Example I am following is from this article: https://...
-1
votes
1
answer
758
views
Warning when using fflib_QueryFactory
When performing a sub query, I get the following message:
WARN|fflib_QueryFactory.subselectQuery(Schema.SObjectType) is deprecated and will be removed in a future release. Use fflib_QueryFactory....