salesforcelabs / fluentassert Goto Github PK
View Code? Open in Web Editor NEWThis project aims provide better asserts for tests in Apex. Inspired by AssertJ and other fluent libraries.
License: BSD 3-Clause "New" or "Revised" License
This project aims provide better asserts for tests in Apex. Inspired by AssertJ and other fluent libraries.
License: BSD 3-Clause "New" or "Revised" License
Consider:
Use SObject.get(String) to build something like
Fluent__Assert.that(sobject)
.extracting("AccoutNumber, SomeOtherString__c")
.containsExactly(new List<String>{'RealAccountNumber', 'Real Value of SOSc'}
...
back()
Type-specific getters
Fluent__Assert.that(sobject)
.getAsInteger(".....") // Returns IntegerAssertNavigator
...
.back()
Hi
I was trying to use isRecordType from SObject and I found this issue -
I created account like this -
Id customerRecTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Customer').getRecordTypeId();
Account acc = new Account(
Name = 'TEST ACCOUNT',
Source_ID__c = 'ACCOUNT 001',
recordTypeId = customerRecTypeId
);
insert ACC;
Fluent.Assert.that(acc).isRecordType('Customer') -> This fails
But
Fluent.Assert.that(acc).isRecordType(customerRecTypeId) -> This passes.
So it looks like if a record type is set during record creation then it compares against record type id not record type developer name.
I also looked into your code
global SObjectAssert isRecordType(String developerName) {
notNull(actual, 'actual');
notNull(developerName, 'developerName');
**String actualRecordTypeDevName = actual.isSet('RecordTypeId') ? (String) actual.get('RecordTypeId') :** SObjectTypeUtil.getDefaultRecordTypeInfo(Schema.SObjectType.Account).getDeveloperName();
assert(developerName == actualRecordTypeDevName, 'Expected RecordType to be \'{0}\' but found \'{0}\'', new List<Object> {developerName, actualRecordTypeDevName});
return this;
}
It looks like if record type id is set then you are assigning that id to actualRecordTypeDevName . I was expecting you would fetch the developer name from that record type id and use that to compare the values.
Is this an expected behaviour ?
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.