-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: efficient describe calls (#141)
feat: enable case-insensitive uses
- Loading branch information
Showing
11 changed files
with
589 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
unpackaged/main/default/classes/UnpackagedRecordTypesTest.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/** | ||
* This class contains unit tests for validating the behavior of Apex classes | ||
* and triggers. | ||
* | ||
* Unit tests are class methods that verify whether a particular piece | ||
* of code is working properly. Unit test methods take no arguments, | ||
* commit no data to the database, and are flagged with the testMethod | ||
* keyword in the method definition. | ||
* | ||
* All test methods in an org are executed whenever Apex code is deployed | ||
* to a production org to confirm correctness, ensure code | ||
* coverage, and prevent regressions. All Apex classes are | ||
* required to have at least 75% code coverage in order to be deployed | ||
* to a production org. In addition, all triggers must have some code coverage. | ||
* | ||
* The @isTest class annotation indicates this class only contains test | ||
* methods. Classes defined with the @isTest annotation do not count against | ||
* the org size limit for all Apex scripts. | ||
* | ||
* See the Apex Language Reference for more information about Testing and Code Coverage. | ||
*/ | ||
@isTest | ||
private class UnpackagedRecordTypesTest { | ||
/** | ||
* @description Test against Account, an object with record types in package testing, but with lowercase RT name | ||
* <br>Assumes we have a record type called `Default` and tests `Default` | ||
* @author Evan Callahan | ||
* @author David Schach | ||
*/ | ||
@IsTest | ||
private static void testAccountRecTypes() { | ||
//Test with Account | ||
|
||
Assert.isNotNull(RecordTypes.getRecordTypesForObject('Account'), 'A real sobject should have at least Master record type'); | ||
Assert.isNotNull(RecordTypes.getRecordTypeIdFromName('Account', 'Default'), 'Default record type should exist'); | ||
Assert.isNotNull(RecordTypes.getRecordTypeDevNameFromName('Account', 'Default'), 'Default record type should exist'); | ||
|
||
Assert.isNotNull(RecordTypes.getRecordTypeNameFromDevName('Account', 'Default'), 'Default record type should exist'); | ||
Assert.isNotNull(RecordTypes.getRecordTypeIdFromDevName('Account', 'Default'), 'Default record type should exist'); | ||
|
||
Assert.isNull(RecordTypes.getRecordTypeNameFromId('Account', null), 'Null record type should not exist'); | ||
Assert.isNull(RecordTypes.getRecordTypeDevNameFromId('Account', null), 'Null record type should not exist'); | ||
|
||
Assert.isNotNull(RecordTypes.getRecordTypeIdFromDevName('Account', 'Default'), 'Default record type should exist'); | ||
Assert.isNotNull(RecordTypes.getRecordTypeIdFromName('Account', 'Default'), 'Default record type should exist'); | ||
|
||
//Assert.areEqual('Default', RecordTypes.getDefaultRecordTypeName('Account'), 'Our default Account RT should be "Default"'); | ||
//Assert.areEqual('Default', RecordTypes.getDefaultRecordTypeDevName('Account'), 'Our default Account RT should be "Default"'); | ||
|
||
Assert.areEqual( | ||
'Master', | ||
RecordTypes.getDefaultRecordTypeName('Account'), | ||
'Our default Account RT should be "Master" because we assigned via permission set' | ||
); | ||
Assert.areEqual( | ||
'Master', | ||
RecordTypes.getDefaultRecordTypeDevName('Account'), | ||
'Our default Account RT should be "Master" because we assigned via permission set' | ||
); | ||
|
||
Assert.isNotNull(RecordTypes.getRecordTypeDevNameIdMap('Account'), 'A real sobject should return at least an empty map'); | ||
|
||
Assert.isNotNull( | ||
RecordTypes.getAvailableRecordTypeDevNameIdMap('Account'), | ||
'Should return at least an empty map, and populated one if we have record types for Account.' | ||
); | ||
Assert.isNotNull( | ||
RecordTypes.getAvailableRecordTypeNameIdMap('Account'), | ||
'Should return at least an empty map, and a populated one if we have record types for Account.' | ||
); | ||
|
||
Assert.isNotNull( | ||
RecordTypes.getAvailableRecordTypesIdSet('Account'), | ||
'Should return at least an empty map, and populated one if we have record types for Account.' | ||
); | ||
} | ||
|
||
/** | ||
* @description Test against Account, an object with record types in package testing, but with lowercase RT name | ||
* <br>Assumes we have a record type called `Default` and tests `default` | ||
* @author Evan Callahan | ||
* @author David Schach | ||
*/ | ||
@IsTest | ||
private static void testAccountRecTypesLowercaseRT() { | ||
//Test with Account | ||
|
||
Assert.isNotNull(RecordTypes.getRecordTypesForObject('Account'), 'A real sobject should have at least Master record type'); | ||
Assert.isNotNull(RecordTypes.getRecordTypeIdFromName('Account', 'default'), 'default record type should exist'); | ||
Assert.isNotNull(RecordTypes.getRecordTypeDevNameFromName('Account', 'default'), 'default record type should exist'); | ||
|
||
Assert.isNotNull(RecordTypes.getRecordTypeNameFromDevName('Account', 'default'), 'default record type should exist'); | ||
Assert.isNotNull(RecordTypes.getRecordTypeIdFromDevName('Account', 'default'), 'default record type should exist'); | ||
|
||
Assert.isNotNull(RecordTypes.getRecordTypeIdFromDevName('Account', 'default'), 'default record type should exist'); | ||
Assert.isNotNull(RecordTypes.getRecordTypeIdFromName('Account', 'default'), 'default record type should exist'); | ||
} | ||
|
||
/** | ||
* @description Test for running certain methods without filling maps | ||
*/ | ||
@IsTest | ||
static void testMethodsAfterReset() { | ||
resetTest(); | ||
List<RecordType> queriedRecordTypes = [SELECT Id, Name, DeveloperName FROM RecordType WHERE SObjectType = 'Account']; | ||
Assert.isNotNull(RecordTypes.getRecordTypeNameFromId(queriedRecordTypes[0].Id), 'Error'); | ||
} | ||
|
||
/** | ||
* @description Clear all record type maps to enable using fewer test methods - reset within a method | ||
* @author {@link [David Schach](https://github.com/dschach)} | ||
*/ | ||
private static void resetTest() { | ||
RecordTypes.clearMapsInTest(); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
unpackaged/main/default/classes/UnpackagedRecordTypesTest.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>59.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Package xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<types> | ||
<members>Account-Account %28Marketing%29 Layout</members> | ||
<members>Account-Account %28Sales%29 Layout</members> | ||
<members>Account-Account %28Support%29 Layout</members> | ||
<name>Layout</name> | ||
</types> | ||
<version>60.0</version> | ||
</Package> |
Oops, something went wrong.