apex-enterprise-patterns / at4dx-samplecode Goto Github PK
View Code? Open in Web Editor NEWSample code demonstrating the usage of the AT4DX Framework
Sample code demonstrating the usage of the AT4DX Framework
How do you mock an AbstractSelectorMethodInjectable
where the class is called from another layer (like Service)?
The sample code shows how to do it when making the selectInjection
call from the actual test. How do you do it when the selectInjection
call is not in the test itself, but rather in the class under test?
For example, this test fails with a NullPointerException
- rygramer@bd26854. (This is essentially a copy and paste from the sample code test, except for line 143.)
If you dont implement the equals
method inside of the Parameters class, when you are creating another instance of the Parameters for testing the injection, that is using a memory reference to compare the objects
Those objects are not equal, thus the mock does not meet its criteria, thus it returns nothing, which you assign to your list
Which you then get a NPE because you are trying to access size of a null list
It worked in the sample because the same instance of the SelectBySloganSelectorMethod.Parameters
was being used, thus it was equal
(obligatory RTFM reference -> https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_collections_maps_keys_userdefined.htm)
The docs are talking about Maps and Sets, but the overall concept is relevant here
np! For reference, we dont add the equals
and hashCode
methods for you, since we arent sure what attributes you are going to define for your Parameters
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.