Questions tagged [fflib]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
55 views

Partial mocking using ApexMocks Framework

I want to perform partial mocking using the Salesforce FFLib ApexMocks framework. For example, I have a class like the one below: public class PropertiesServiceImpl implements IPropertiesService { ...
Seleukos2's user avatar
0 votes
1 answer
50 views

fflib_SObjectSelector - Not able to query for RecordType.DeveloperName

So I was going through a selector class and came across an issue: Sample selector class: public List<Schema.SObjectField> getSObjectFieldList() { return new List<Schema.SObjectField>{ ...
NedlaV's user avatar
  • 88
0 votes
1 answer
49 views

Issue getting object API name from relationship field using Schema

In my project we are using fflib_QueryFactory to build queries and also order fields. Example is given below: fflib_QueryFactory qf = new fflib_QueryFactory(Account.SObjectType) ....
Jason Rickert's user avatar
0 votes
1 answer
37 views

FFLIB Framework Can The Context Be Set To Run As a Specific User?

On an implementation I'm currently working on we have the FFLIB Framework in place. I noted for a requirement to delete specific records that the Framework is enforing triggers to run in context of ...
RedQueries's user avatar
0 votes
0 answers
24 views

FFLIB / SOC / Fowler Domain question [duplicate]

There's probably 100000 answers to this, but I'm having a hard time understanding how the domain layer is supposed to handle more advanced trigger logic. For instance, what if a subscription ...
John Pfleger's user avatar
0 votes
1 answer
98 views

unitOfWork (fflib_ISObjectUnitOfWork) clear cache after commitWork()

I have a business process where the Opportunity and Account insertions have to be done in different uow.commitWork() because this use case is using person accounts, and for whatever reason out of my ...
lopez.regalado.fj's user avatar
0 votes
0 answers
24 views

Group records using lookup object reference fields in fflib

I have a use case to group the accounts with the DNB Company Records(lookup in account)'s Global_Ultimate_DUNS_Number__c and check if the accounts tied via Global DUNS if they are present in more than ...
Praveen's user avatar
  • 10.1k
0 votes
1 answer
32 views

Profile.Name accesability linked to 'View setup and configuration' System Permission

Apparently, getDescribe() is returning isAccessible=false for the field Profile.Name (User object) if the System Permission 'View setup and configuration' is disabled. tokenDescribeSchema....
lopez.regalado.fj's user avatar
1 vote
1 answer
172 views

Mocking Relationship Over Multiple Levels With Apex Mocks

I am trying to bring more mocking into our test class. Many of our queries follow the pattern of user.contact__r.patient__c I am struggling to figure out how to mock this using Apex Mocks. I have not ...
Brooks Johnson's user avatar
0 votes
1 answer
186 views

FFLIB Unit of work (fflib_ISObjectUnitOfWork) and a self-relationship field

I can't get FFLIB uow to work with a self-relationship field. Quick use case: Create two accounts and relate the second one with the first one using a custom lookup field (selfRelation__c) ...
lopez.regalado.fj's user avatar
0 votes
1 answer
165 views

Can I mock out lookup relationship using FFLIB ApexMocks

I'm trying to mock out something similar to the following structure: Task.LastModifiedBy.Username; Task.LookupRelationshipToUser__r.Username; Using the makeRelationships method for this doesn't make ...
saclark12000's user avatar
1 vote
1 answer
94 views

fflib Selector issues with System.runAs()

Looking at bringing in a selector pattern to help reduce a lot of cumbersome test code. But as I refactored, I noticed that after introducing a selector class, the existing test will fail when it uses ...
Brooks Johnson's user avatar
-2 votes
2 answers
261 views

what is the role and meaning of "=>" operator (it's called maps to) in apex enterprise pattern application class ? Please explain [duplicate]

@namespaceAccessible public static final fflib_Application.ServiceFactory service = new fflib_Application.ServiceFactory(new Map<Type, Type> { IHospitalService.class => ...
Sagar's user avatar
  • 35
0 votes
1 answer
165 views

how to get Profile name of lastModifiedBy in fflib selector class

I'm facing issue that when I add LastModifiedBy profile name is getting in soql but when query it in fflib then is getting empty list public List<Order> selectOrderIdsByProfileName(Set<Id> ...
Vinitha vino's user avatar
2 votes
1 answer
384 views

Lean, fast and flexible replacement for the fflib QueryFactory

I just decided to kick the fflib QueryFactory out of a customer project because of its complexity and sub-par performance. My Custom Query Building is fast but I fear I will reinvent the wheel. Which ...
Robert Sösemann's user avatar
2 votes
2 answers
196 views

ApexMocks and UoW implementing IDoWork interface

I have extended the main functionality of the fflib_ISObjectUnitOfWork to enable upserts considering External Ids. Basically, I have created a new class implementing the fflib_SObjectUnitOfWork....
lopez.regalado.fj's user avatar
0 votes
1 answer
347 views

How to add ALL ROWS in fflib selector class

I need to get delete records in SOQL query so i have used ALL ROWS in the end of the SOQL in SOQL its working fine but I need to add in fflib selector class Im getting error public List<...
Vinitha vino's user avatar
1 vote
1 answer
125 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 ...
cropredy's user avatar
  • 69.1k
0 votes
1 answer
169 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(...
cropredy's user avatar
  • 69.1k
2 votes
2 answers
754 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 ...
Customer Foster's user avatar
0 votes
2 answers
151 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 ...
user1067017's user avatar
13 votes
2 answers
616 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 ...
lightxx's user avatar
  • 271
-2 votes
2 answers
358 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(){ ...
John Pfleger's user avatar
2 votes
1 answer
649 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 ...
lopez.regalado.fj's user avatar
1 vote
1 answer
965 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 ...
Miłosz's user avatar
  • 25
0 votes
1 answer
817 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> ...
Miłosz's user avatar
  • 25
0 votes
3 answers
209 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 ...
Peter Caitens's user avatar
7 votes
2 answers
1k 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 ...
Morgan Marchese's user avatar
0 votes
1 answer
188 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 ...
Chris C's user avatar
  • 271
1 vote
1 answer
524 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....
Pseudodarwinist's user avatar
1 vote
1 answer
171 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}...
Cuban coffee's user avatar
  • 1,520
2 votes
1 answer
450 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 = '...
Cuban coffee's user avatar
  • 1,520
0 votes
1 answer
471 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 ...
Pseudodarwinist's user avatar
0 votes
1 answer
167 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 ...
Pseudodarwinist's user avatar
1 vote
0 answers
177 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 ...
Sonali takke's user avatar
3 votes
2 answers
1k 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 ...
nica's user avatar
  • 1,338
0 votes
1 answer
1k 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 ...
Daniel Wutz's user avatar
9 votes
2 answers
2k 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 ...
Oleh Berehovskyi's user avatar
1 vote
1 answer
578 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 ...
FOCOMI's user avatar
  • 15
0 votes
1 answer
645 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 ...
arun parmar's user avatar
1 vote
2 answers
127 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 ...
Artur Kępczyński's user avatar
0 votes
1 answer
886 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 ...
Artur Kępczyński's user avatar
0 votes
2 answers
368 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 ...
Cuban coffee's user avatar
  • 1,520
1 vote
1 answer
2k 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 ...
Cuban coffee's user avatar
  • 1,520
2 votes
1 answer
2k 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 ...
Cuban coffee's user avatar
  • 1,520
1 vote
1 answer
315 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: ...
Sagnik's user avatar
  • 575
0 votes
1 answer
337 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() { ...
Cuban coffee's user avatar
  • 1,520
0 votes
1 answer
669 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 ...
Cuban coffee's user avatar
  • 1,520
4 votes
2 answers
812 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 = (...
cropredy's user avatar
  • 69.1k
0 votes
1 answer
219 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 ...
krishna's user avatar