jamessimone / apex-dml-mocking Goto Github PK
View Code? Open in Web Editor NEWDML mocking, CRUD mocking, dependency injection framework for Salesforce.com (SFDC) using Apex
License: MIT License
DML mocking, CRUD mocking, dependency injection framework for Salesforce.com (SFDC) using Apex
License: MIT License
DML mock is not working for WorkOrderLineItem standard object.. For the other sobjects it is working fine.
Hi @jamessimone
I have the next funny thing for you:
String predValue = String.valueOf(predicate);
//fun fact - you can detect a list
//but you can't detect a set!
if(predValue.startsWith('{') && predValue.endsWith('}')) {
List<String> setInner = predValue.substring(1, predValue.length() -1).split(',');
isSet = setInner.size() > 1;
return this.getPredicate(setInner);
}
the variable "predValue" gets shortened ... I've just played around with a Set of more than 30 Ids ... this piece of code takes 11 ids, where is last value is '...' (which is why it failed and I actually discovered it)
Your Repository class support SYSTEM / USER mode for queries, but not for writes (unless I missed it). Additionally, there's no clean way to set DML options for the entire batch (it has to be set on the individual SObjects).
To avoid the ugliness of having 1000 overloads, just supporting
insert(recordsToInsert, dmlOptions, accessLevel)
for example (along with the update, etc. versions) would be sufficient; the single-record use case can just wrap in a list, and the allOrNone true/false overload is redundant with being able to set that via DMLOptions.
Repository
Hi,
Would it be possible to add a license file to this repo, just to be 100% sure if we can use this code in our projects or not?
Hi James,
In addition to my pending pull request, I was wondering why you are doing an isEmpty check on the records list in the doDelete and doHardDelete methods?
apex-dml-mocking/force-app/dml/DML.cls
Line 49 in e4ff2ea
apex-dml-mocking/force-app/dml/DML.cls
Line 57 in e4ff2ea
Cheers,
Jens
Hi James,
I tried to run the AccountHandlerTests but throwing System.NullPointerException and I have no idea where to fix it.
Could you please advise ? I tried to play around with ExampleFactory and AccountHandlerTests but still can't figure out the solution.
Sorry that I am a noob and just started learning apex programming.
Hi James,
awesome work on this repo,
I've recently played around specificly with this Query.cls class
And I used it to create a where clause with a Set of Ids to finally get a query like this:
SELECT
Id,
Name
FROM Account
WHERE Id IN ('0010O000028pTbxQAE','0011l00000jpAV3AAM','0013X00002fmFN1QAM')
But I discovered, that the method mentioned puts a leading space in front of the second and all following parts of the list (for whatever reason), so the query looks like this:
SELECT
Id,
Name
FROM Account
WHERE Id IN ('0010O000028pTbxQAE',' 0011l00000jpAV3AAM',' 0013X00002fmFN1QAM')
This obviously leads to an error: "System.QueryException: invalid ID field"
So what I've done in my modification of your code - I've added a call to trim().
return '\'' + String.escapeSingleQuotes(input).trim() + '\'';
What's your opinion? Maybe trim() is just a quick fix?
I really wanted to try use your dml mocking framework in my sandbox.
I've tried creating apex classes one by one in these order :
However at step 3 when creating the RepoFactory
class, I get this error:
force-app/main/default/classes/factory/RepoFactory.cls Invalid type: FieldLevelHistoryRepo (8:36)
So I tried creating the FieldLevelHistoryRepo
class , I get this error :
force-app/main/default/classes/repository/FieldLevelHistoryRepo.cls Invalid type: AggregateRepository (1:68)
force-app/main/default/classes/repository/FieldLevelHistoryRepo.cls @Override specified for non-overriding method: Set<String> FieldLevelHistoryRepo.addSelectFields() (32:42)
So I tried creating the AggregateRepository
class, I get this error :
force-app/main/default/classes/repository/AggregateRepository.cls Invalid type: Repository (1:66)
force-app/main/default/classes/repository/AggregateRepository.cls @Override specified for non-overriding method: String AggregateRepository.getFinalQuery(List<Query>) (82:29)
force-app/main/default/classes/repository/AggregateRepository.cls @Override specified for non-overriding method: Set<String> AggregateRepository.addSelectFields() (65:42)
So I'm essentially stuck trying to create all these classes effectively. Help pls?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.