From 46e8c204e4f9f9f18c900a3e7ed2d41c80c8ac3c Mon Sep 17 00:00:00 2001 From: Kevin Poorman Date: Sun, 8 Jun 2025 12:26:31 -0500 Subject: [PATCH 1/3] feat(TestFactory): Deprecates TestFactory TestFactory is dead. Long live SObjectFactory --- .../feature flags/tests/FeatureFlagTests.cls | 2 +- .../polyfills/tests/PolyfillsTests.cls | 60 ++- .../classes/safely/tests/SafelyTests.cls | 42 +-- .../classes/test utilities/TestFactory.cls | 354 ------------------ .../test utilities/TestFactory.cls-meta.xml | 5 - 5 files changed, 50 insertions(+), 413 deletions(-) delete mode 100644 force-app/main/default/classes/test utilities/TestFactory.cls delete mode 100644 force-app/main/default/classes/test utilities/TestFactory.cls-meta.xml diff --git a/force-app/main/default/classes/feature flags/tests/FeatureFlagTests.cls b/force-app/main/default/classes/feature flags/tests/FeatureFlagTests.cls index 275b9295..da09c84d 100644 --- a/force-app/main/default/classes/feature flags/tests/FeatureFlagTests.cls +++ b/force-app/main/default/classes/feature flags/tests/FeatureFlagTests.cls @@ -161,7 +161,7 @@ class FeatureFlagTests { @IsTest private static void testFeatureFoundEnabledViaCustomPermissionPositive() { FeatureFlagDataProvider dataProvider = new FeatureFlagDataProvider(); - TestFactory.enableCustomPermission('ApexKit_Example', UserInfo.getUserId()); + PermissionsHelper.enableCustomPermission('ApexKit_Example', UserInfo.getUserId()); dataProvider.overrideFlags( FeatureFlagCommonTests.getTestFlag('TestFlag', false) ); diff --git a/force-app/main/default/classes/polyfills/tests/PolyfillsTests.cls b/force-app/main/default/classes/polyfills/tests/PolyfillsTests.cls index 4cfe9c54..78dda505 100644 --- a/force-app/main/default/classes/polyfills/tests/PolyfillsTests.cls +++ b/force-app/main/default/classes/polyfills/tests/PolyfillsTests.cls @@ -1,6 +1,6 @@ -@isTest +@IsTest private class PolyfillsTests { - @isTest + @IsTest private static void testGetSObjectTypeFromListPositiveNoType() { Test.startTest(); String results = Polyfills.getSObjectTypeFromListsFirstObject( @@ -13,32 +13,28 @@ private class PolyfillsTests { ); } - @isTest + @IsTest private static void testGenerateUUID() { Test.startTest(); String uuid = Polyfills.generateUUID(); Test.stopTest(); - system.debug(uuid); Assert.isTrue(uuid != null, 'expected to get a uuid back'); Assert.areEqual(5, uuid.split('-').size(), 'expected to get 5 parts back'); } - @isTest + @IsTest private static void testPluckFieldFromList() { - List accounts = (List) TestFactory.createSobjectList( - new Account(), - 200 - ); + List accounts = SObjectFactory.createSObjects(new Account(), 200); Test.startTest(); List results = Polyfills.pluckFieldFromList('Name', accounts); Test.stopTest(); Assert.areEqual(200, results.size()); } - @isTest + @IsTest private static void testGenerateStacktracePositive() { Test.startTest(); - String results = Polyfills.generateStacktrace(); + String results = Polyfills.generateStackTrace(); Test.stopTest(); Assert.isTrue( results.containsIgnoreCase('PolyfillsTests'), @@ -46,7 +42,7 @@ private class PolyfillsTests { ); } - @isTest + @IsTest private static void testTypeObjFromInstance() { Test.startTest(); Type results = Polyfills.typeObjFromInstance(new Account()); @@ -55,7 +51,7 @@ private class PolyfillsTests { Assert.areEqual(results, expected, 'expected to get account back'); } - @isTest + @IsTest private static void testClassNameFromInstance() { Test.startTest(); String results = Polyfills.classNameFromInstance(new Account()); @@ -66,14 +62,14 @@ private class PolyfillsTests { ); } - @isTest + @IsTest private static void testDemonstrateIdMapFromCollectionByKeyPositiveWithList() { - List accounts = (List) TestFactory.createSObjectList( + List accounts = SObjectFactory.createSObjects( new Account(), 5, true ); - List contacts = (List) TestFactory.createSObjectList( + List contacts = SObjectFactory.createSObjects( new Contact(), 5, true @@ -101,7 +97,7 @@ private class PolyfillsTests { 'Expected to get 5 contacts back' ); - for (id accountId : checkAccountMap.keySet()) { + for (Id accountId : checkAccountMap.keySet()) { Assert.areEqual( checkAccountMap.get(accountId).getSObjectType(), Account.getSObjectType(), @@ -109,7 +105,7 @@ private class PolyfillsTests { ); } - for (id contactId : checkContactMap.keySet()) { + for (Id contactId : checkContactMap.keySet()) { Assert.areEqual( checkContactMap.get(contactId).getSObjectType(), Contact.getSObjectType(), @@ -118,15 +114,15 @@ private class PolyfillsTests { } } - @isTest + @IsTest private static void testDemonstrateStringMapFromCollectionByKeyPositiveWithList() { - List accounts = (List) TestFactory.createSObjectList( + List accounts = SObjectFactory.createSObjects( new Account(), 5, true ); for (Account acct : accounts) { - acct.name = acct.id; + acct.Name = acct.Id; } update accounts; Test.startTest(); @@ -143,7 +139,7 @@ private class PolyfillsTests { 'Expected to get 5 accounts back' ); - for (id accountId : checkAccountMap.keySet()) { + for (Id accountId : checkAccountMap.keySet()) { Assert.areEqual( checkAccountMap.get(accountId).getSObjectType(), Account.getSObjectType(), @@ -152,9 +148,9 @@ private class PolyfillsTests { } } - @isTest + @IsTest private static void testMapFromCollectionWithListOfValuesPostive() { - List accounts = (List) TestFactory.createSObjectList( + List accounts = SObjectFactory.createSObjects( new Account(), 5, true @@ -163,8 +159,8 @@ private class PolyfillsTests { List contactList = new List(); for (Account acct : accounts) { contactList.addAll( - (List) TestFactory.createSObjectList( - new Contact(accountId = acct.id), + (List) SObjectFactory.createSObjects( + new Contact(AccountId = acct.Id), 5, false ) @@ -173,7 +169,7 @@ private class PolyfillsTests { insert contactList; Test.startTest(); - Map> checkResults = (Map>) Polyfills.mapFromCollectionWithCollectionValues( + Map> checkResults = Polyfills.mapFromCollectionWithCollectionValues( 'AccountId', contactList ); @@ -181,7 +177,7 @@ private class PolyfillsTests { Assert.areEqual( 5, - checkResults.keyset().size(), + checkResults.keySet().size(), 'Expected to find 5 accountIds' ); @@ -199,7 +195,7 @@ private class PolyfillsTests { for (Contact contact : checkResults.get(accountId)) { Assert.areEqual( contact.getSObjectType(), - Contact.getSObjectType(), + contact.getSObjectType(), 'Expected to find contacts' ); } @@ -207,7 +203,7 @@ private class PolyfillsTests { } @SuppressWarnings('PMD.AvoidHardcodingId') - @isTest + @IsTest private static void testSetContainsAnyItemFromListPositive() { Set testSet = new Set(); testSet.add('0011h00000xR1GfAAK'); @@ -234,7 +230,7 @@ private class PolyfillsTests { } @SuppressWarnings('PMD.AvoidHardcodingId') - @isTest + @IsTest private static void testSetDoesNOTContainsAnyItemFromListPositive() { Set testSet = new Set(); testSet.add('0011h00000xR1GfAAK'); @@ -260,7 +256,7 @@ private class PolyfillsTests { ); } - @isTest + @IsTest private static void givenAStringAndABlob_CanConcatenateIntoOneBlob() { String oneCharacter = '1'; Blob oneCharacterInAFile = Blob.valueOf(oneCharacter); diff --git a/force-app/main/default/classes/safely/tests/SafelyTests.cls b/force-app/main/default/classes/safely/tests/SafelyTests.cls index 3656bc92..1e2c9836 100644 --- a/force-app/main/default/classes/safely/tests/SafelyTests.cls +++ b/force-app/main/default/classes/safely/tests/SafelyTests.cls @@ -1,4 +1,4 @@ -@isTest +@IsTest private class SafelyTests { @IsTest private static void testConstructorChains() { @@ -41,7 +41,7 @@ private class SafelyTests { @IsTest private static void testDoInsertNegative() { - User minAccessUser = TestFactory.createMinAccessUser(true); + User minAccessUser = UserFactory.createMinAccessPersonaUser(true); System.runAs(minAccessUser) { Assert.isTrue(!CanTheUser.create(new Account())); @@ -59,11 +59,11 @@ private class SafelyTests { @IsTest private static void testMarketingProfileGeneratesInsertExceptionPositive() { - User marketingUser = TestFactory.createMarketingUser(true); + User marketingUser = UserFactory.createMarketingPersonaUser(true); Boolean didCatchTheRightException = false; Account account = (Account) new Account( Name = 'TestAccount', - TradeStyle = 'invalid' + Tradestyle = 'invalid' ); Test.startTest(); System.runAs(marketingUser) { @@ -96,7 +96,7 @@ private class SafelyTests { @IsTest private static void testDoUpdateNegative() { - User minAccessUser = TestFactory.createMinAccessUser(true); + User minAccessUser = UserFactory.createMinAccessPersonaUser(true); PermissionSet ps = new PermissionSet( Label = 'testPermSet', @@ -117,7 +117,7 @@ private class SafelyTests { AssigneeId = minAccessUser.Id ); System.runAs(minAccessUser) { - Account account = (Account) new Account(name = 'TestAccount'); + Account account = (Account) new Account(Name = 'TestAccount'); Assert.isTrue(CanTheUser.create(account)); insert account; @@ -137,7 +137,7 @@ private class SafelyTests { @IsTest private static void testMarketingProfileDeleteNegative() { - User marketingUser = TestFactory.createMarketingUser(true); + User marketingUser = UserFactory.createMarketingPersonaUser(true); Case c = (Case) new Case(Subject = 'TestCase'); insert c; @@ -156,11 +156,11 @@ private class SafelyTests { @IsTest private static void testMarketingProfileGeneratesUpdateExceptionPositive() { - User marketingUser = TestFactory.createMarketingUser(true); + User marketingUser = UserFactory.createMarketingPersonaUser(true); Boolean didCatchTheRightException = false; Account account = (Account) new Account(Name = 'TestAccount'); insert account; - account.TradeStyle = 'off limits field'; + account.Tradestyle = 'off limits field'; Test.startTest(); System.runAs(marketingUser) { try { @@ -186,7 +186,7 @@ private class SafelyTests { Account account2 = (Account) new Account(Name = 'TestAccount'); List accounts = new List{ account, account2 }; Test.startTest(); - List insertResults = new Safely().doUpsert(account); + List insertResults = new Safely().doUpsert(account); List mixedResults = new Safely().doUpsert(accounts); Test.stopTest(); Assert.areEqual( @@ -198,7 +198,7 @@ private class SafelyTests { Assert.isTrue(insertResults.get(0).success, 'This dml should succeed'); Integer updated = 0; Integer inserted = 0; - for (Database.upsertResult result : mixedResults) { + for (Database.UpsertResult result : mixedResults) { Assert.isTrue(result.success, 'This dml should succeed'); if (result.created) { inserted++; @@ -212,7 +212,7 @@ private class SafelyTests { @IsTest private static void testDoUpsertMethodsNegative() { - User minAccessUser = TestFactory.createMinAccessUser(true); + User minAccessUser = UserFactory.createMinAccessPersonaUser(true); PermissionSet ps = new PermissionSet( Label = 'testPermSet', @@ -256,11 +256,11 @@ private class SafelyTests { @IsTest private static void testMarketingProfileGeneratesUpsertExceptionPositive() { - User marketingUser = TestFactory.createMarketingUser(true); + User marketingUser = UserFactory.createMarketingPersonaUser(true); Boolean didCatchTheRightException = false; Account account = (Account) new Account(Name = 'TestAccount'); insert account; - account.TradeStyle = 'off limits field'; + account.Tradestyle = 'off limits field'; Test.startTest(); System.runAs(marketingUser) { try { @@ -283,7 +283,7 @@ private class SafelyTests { Account account = (Account) new Account(Name = 'TestAccount'); insert account; Test.startTest(); - List results = new Safely() + List results = new Safely() .throwIfRemovedFields() .doDelete(account); Test.stopTest(); @@ -292,11 +292,11 @@ private class SafelyTests { @IsTest private static void testDeleteWithRegularProfileNegative() { - User minAccessUser = TestFactory.createMinAccessUser(true); + User minAccessUser = UserFactory.createMinAccessPersonaUser(true); Account account = (Account) new Account(Name = 'TestAccount'); insert account; Test.startTest(); - List results; + List results; System.runAs(minAccessUser) { results = new Safely().throwIfRemovedFields().doDelete(account); } @@ -310,16 +310,16 @@ private class SafelyTests { Account account = (Account) new Account(Name = 'TestAccount'); insert account; Test.startTest(); - List accounts = (List) new Safely() + List accounts = new Safely() .throwIfRemovedFields() .doQuery('SELECT ID, Name FROM Account'); Test.stopTest(); - Assert.areEqual(1, Accounts.size(), 'expected to find one record'); + Assert.areEqual(1, accounts.size(), 'expected to find one record'); } @IsTest private static void testDoQueryThrowsRemovedFieldsException() { - User minAccessUser = TestFactory.createMinAccessUser(true); + User minAccessUser = UserFactory.createMinAccessPersonaUser(true); PermissionSet ps = new PermissionSet( Label = 'testPermSet', @@ -347,7 +347,7 @@ private class SafelyTests { Test.startTest(); Safely saf = new Safely(); try { - List accounts = (List) saf + saf .throwIfRemovedFields() .doQuery('SELECT ID, Name, TradeStyle FROM Account'); } catch (Safely.RemovedFieldsException rfe) { diff --git a/force-app/main/default/classes/test utilities/TestFactory.cls b/force-app/main/default/classes/test utilities/TestFactory.cls deleted file mode 100644 index bb0431e2..00000000 --- a/force-app/main/default/classes/test utilities/TestFactory.cls +++ /dev/null @@ -1,354 +0,0 @@ -@IsTest -public class TestFactory { - /** - * @description When we create a list of SObjects, we need to have a unique field for the insert if there isn't an autonumber field. - * Usually we use the Name field, but some objects don't have a name field. - */ - private static final Map NAME_FIELD_OVERRIDE_MAP = new Map{ - Contact.SObjectType => Contact.LastName, - Case.SObjectType => Case.CaseNumber //this is the autonumber field - }; - - /** - * @description Creates a single sObject. - * @param sObj Type of sObject to create. - * @return `SObject` - */ - public static SObject createSObject(SObject sObj) { - // Check what type of object we are creating and add any defaults that are needed. - String objectName = String.valueOf(sObj.getSObjectType()); - // Construct the default values class. Salesforce doesn't allow '__' in class names - String defaultClassName = objectName.replaceAll('__(c|C)$|__', '') + 'Defaults'; - // If there is a class that exists for the default values, then use them - if (Type.forName('TestFactoryDefaults.' + defaultClassName) != null) { - sObj = createSObject(sObj, 'TestFactoryDefaults.' + defaultClassName); - } - return sObj; - } - - /** - * @description Creates a single sObject - * @param sObj Type of sObject to create - * @param doInsert Boolean should this object be inserted? - * @return `SObject` - */ - public static SObject createSObject(SObject sObj, Boolean doInsert) { - SObject retObject = createSObject(sObj); - if (doInsert) { - insert retObject; - } - return retObject; - } - - /** - * @description creates a single sObject - * - * @param sObj Type of sObject to create - * @param defaultClassName Name of the class to provide field defaults - * - * @return `SObject` - * - * @throws TestFactoryException when defaultClassName param is not a valid type. - */ - public static SObject createSObject(SObject sObj, String defaultClassName) { - // Create an instance of the defaults class so we can get the Map of field defaults - Type t = Type.forName(defaultClassName); - if (t == null) { - throw new TestFactoryException('Invalid defaults class.'); - } - FieldDefaults defaults = (FieldDefaults) t.newInstance(); - addFieldDefaults(sObj, defaults.getFieldDefaults()); - return sObj; - } - - /** - * @description Create a single sObject - * @param sObj Type of sObject to create - * @param defaultClassName String name of a class providing default values - * @param doInsert Boolean should this method insert the created object? - * @return `SObject` - */ - public static SObject createSObject(SObject sObj, String defaultClassName, Boolean doInsert) { - SObject retObject = createSObject(sObj, defaultClassName); - if (doInsert) { - insert retObject; - } - return retObject; - } - - /** - * @description Creates a list of sObjects - * @param sObj Type of sObjects to create - * @param numberOfObjects Integer number of objects to create - * @return `SObject[]` - */ - public static SObject[] createSObjectList(SObject sObj, Integer numberOfObjects) { - return createSObjectList(sObj, numberOfObjects, (String) null); - } - - /** - * @description Creates a list of sObjects - * @param sObj Type of sObjects to create - * @param numberOfObjects Integer number of objects to create - * @param doInsert Boolean should this method insert the created object? - * @return `SObject[]` - */ - public static SObject[] createSObjectList(SObject sObj, Integer numberOfObjects, Boolean doInsert) { - SObject[] retList = createSObjectList(sObj, numberOfObjects, (String) null); - if (doInsert) { - insert retList; - } - return retList; - } - - /** - * @description Creates a list of sObjects - * @param sObj Type of sObjects to create - * @param numberOfObjects Integer number of objects to create - * @param defaultClassName String name of a class providing defaults - * @param doInsert Boolean should this method insert the created object? - * @return `SObject[]` - */ - @SuppressWarnings('PMD.ExcessiveParameterList') - public static SObject[] createSObjectList( - SObject sObj, - Integer numberOfObjects, - String defaultClassName, - Boolean doInsert - ) { - SObject[] retList = createSObjectList(sObj, numberOfObjects, defaultClassName); - if (doInsert) { - insert retList; - } - return retList; - } - - /** - * @description Creates a list of sObjects - * @param sObj Type of sObjects to create - * @param numberOfObjects Integer number of objects to create - * @param defaultClassName String name of a class providing defaults - * @return `SObject[]` - */ - public static SObject[] createSObjectList(SObject sObj, Integer numberOfObjects, String defaultClassName) { - SObject[] sObjs = new List{}; - SObject newObj; - - // Get one copy of the object - if (defaultClassName == null) { - newObj = createSObject(sObj); - } else { - newObj = createSObject(sObj, defaultClassName); - } - - // Get the name field for the object - String nameField = String.valueOf(NAME_FIELD_OVERRIDE_MAP.get(sObj.getSObjectType())); - if (nameField == null) { - nameField = 'Name'; - } - Boolean nameIsAutoNumber = sObj.getSObjectType() - .getDescribe() - .fields.getMap() - .get(nameField) - .getDescribe() - .isAutoNumber(); - - // Clone the object the number of times requested. Increment the name field so each record is unique - for (Integer i = 0; i < numberOfObjects; i++) { - SObject clonedSObj = newObj.clone(false, true); - if (!nameIsAutoNumber) { - clonedSObj.put(nameField, (String) clonedSObj.get(nameField) + ' ' + i); - } - sObjs.add(clonedSObj); - } - return sObjs; - } - - /** - * @description Sets field defaults on the sObj given the map of defaults. - * @param sObj Obj to manipulate. - * @param defaults Defaults map of sObjectField to Object to use for values. - */ - private static void addFieldDefaults(SObject sObj, Map defaults) { - // Loop through the map of fields and if they weren't specifically assigned, fill them. - Map populatedFields = sObj.getPopulatedFieldsAsMap(); - for (Schema.SObjectField field : defaults.keySet()) { - if (!populatedFields.containsKey(String.valueOf(field))) { - sObj.put(field, defaults.get(field)); - } - } - } - - /** - * @description Internal custom exception class - */ - public class TestFactoryException extends Exception { - } - - /** - * @description Use the FieldDefaults interface to set up values you want to default in for all objects - */ - public interface FieldDefaults { - /** - * @description Interface used by implementing classes to define defaults. - * @return `Map` - */ - Map getFieldDefaults(); - } - - /** - * @description creates a test user. Useful for permissions testing - * @param profileId Profile Id to use when creating a user. - * @param doInsert Boolean, should this code insert the user? - * @return `User` - */ - public static User createTestUser(Id profileId, Boolean doInsert) { - User u = new User( - ProfileId = profileId, - LastName = 'last', - Email = 'Testuser@test.example.com', - Username = 'Testuser@test.example.com' + Crypto.getRandomInteger(), - CompanyName = 'TEST', - Title = 'title', - Alias = 'alias', - TimeZoneSidKey = 'America/Los_Angeles', - EmailEncodingKey = 'UTF-8', - LanguageLocaleKey = 'en_US', - LocaleSidKey = 'en_US' - ); - if (doInsert) { - insert u; - } - return u; - } - - /** - * @description Creates a test user with a given profile. - * @param doInsert Should this code insert the created user? - * @param profileName Name of the profile to create the user with. - * @return `User` - */ - public static User createTestUser(Boolean doInsert, String profileName) { - Profile selectedProfile = [ - SELECT Id - FROM Profile - WHERE Name = :profileName - LIMIT 1 - ]; - - return createTestUser(selectedProfile.Id, doInsert); - } - - /** - * @description Creates a user with the Minimum Access Profile - * Relies on the previous method for creating the user. - * @param doInsert Should this code insert the user? - * @return `User` - */ - public static User createMinAccessUser(Boolean doInsert) { - Id profileId = [ - SELECT Id - FROM Profile - WHERE Name = 'Minimum Access - Salesforce' - LIMIT 1 - ] - .Id; - return TestFactory.createTestUser(profileId, doInsert); - } - - /** - * @description Assigns a permission set to a given user. - * - * @param user User to assign the permission set to. - * @param permSetName String name of the permission set. - */ - public static void assignPermSetToUser(User user, String permSetName) { - Id permSetId = [ - SELECT Id - FROM PermissionSet - WHERE Name = :permSetName - LIMIT 1 - ] - .Id; - - PermissionSetAssignment psa = new PermissionSetAssignment(AssigneeId = user.Id, PermissionSetId = permSetId); - insert psa; - } - - /** - * @description Intentionally invalidates a list of sObjects. This is useful for - * intentionally causing DML errors during testing. - * @param incoming List of SObjects - * @return `List` - */ - public static List invalidateSObjectList(List incoming) { - for (SObject obj : incoming) { - obj.put('name', ''); - } - return incoming; - } - - /** - * @description Generates a marketing user - a user with the Marketing User profile. - * - * @param doInsert Boolean True if you want this to insert your user. - * - * @return User the created user - */ - public static User createMarketingUser(Boolean doInsert) { - Id profileId = [ - SELECT Id - FROM Profile - WHERE Name = 'Marketing User' - LIMIT 1 - ] - .Id; - return createTestUser(profileId, doInsert); - } - - /** - * @description Generates a test permission set record - no permissions are added to it - * - * @param permSetName String what to call your perm set - * @param doInsert Boolean true if you want this to insert your perm set record. - * - * @return PermissionSet the created permission set. - */ - public static PermissionSet createPermissionSet(String permSetName, Boolean doInsert) { - PermissionSet newPermSet = new PermissionSet(Name = permSetName, Label = 'Test Permission Set'); - if (doInsert) { - insert newPermSet; - } - return newPermSet; - } - - /** - * @description Enables a custom permission using a permission set - * - * @param permissionName String name of the custom permission you want created - * @param forUserId Id user to assign the custom permission to. - */ - public static void enableCustomPermission(String permissionName, Id forUserId) { - PermissionSet permSet = createPermissionSet('TestPermSet', true); - - Id customPermissionId = [ - SELECT Id - FROM CustomPermission - WHERE DeveloperName = :permissionName - LIMIT 1 - ] - .Id; - - SetupEntityAccess permSetPermission = new SetupEntityAccess( - ParentId = permSet.Id, - SetupEntityId = customPermissionId - ); - - PermissionSetAssignment permSetAssignment = new PermissionSetAssignment( - AssigneeId = forUserId, - PermissionSetId = permSet.Id - ); - - insert new List{ permSetPermission, permSetAssignment }; - } -} diff --git a/force-app/main/default/classes/test utilities/TestFactory.cls-meta.xml b/force-app/main/default/classes/test utilities/TestFactory.cls-meta.xml deleted file mode 100644 index 436a726e..00000000 --- a/force-app/main/default/classes/test utilities/TestFactory.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 63.0 - Active - From 7744de57297df46647490b5502014cf4e3fdc419 Mon Sep 17 00:00:00 2001 From: Kevin Poorman Date: Sun, 8 Jun 2025 12:27:25 -0500 Subject: [PATCH 2/3] feat(TestFactory): Deprecates TestFactory TestFactory is dead. Long live SObjectFactory --- .../main/default/classes/polyfills/tests/PolyfillsTests.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/force-app/main/default/classes/polyfills/tests/PolyfillsTests.cls b/force-app/main/default/classes/polyfills/tests/PolyfillsTests.cls index 78dda505..8e7796cc 100644 --- a/force-app/main/default/classes/polyfills/tests/PolyfillsTests.cls +++ b/force-app/main/default/classes/polyfills/tests/PolyfillsTests.cls @@ -257,7 +257,7 @@ private class PolyfillsTests { } @IsTest - private static void givenAStringAndABlob_CanConcatenateIntoOneBlob() { + private static void givenAStringAndABlobCanConcatenateIntoOneBlob() { String oneCharacter = '1'; Blob oneCharacterInAFile = Blob.valueOf(oneCharacter); From 2d1a59fac2be5e89c28a6216ef45e352c388f73f Mon Sep 17 00:00:00 2001 From: Kevin Poorman Date: Sun, 8 Jun 2025 13:17:31 -0500 Subject: [PATCH 3/3] Updating Formatting --- .idea/dictionaries/project.xml | 1 + config/project-scratch-def.json | 36 +++++++++---------- .../default/classes/ULID/tests/ULIDTests.cls | 4 +-- .../feature flags/tests/FeatureFlagTests.cls | 5 ++- package.json | 1 - 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/.idea/dictionaries/project.xml b/.idea/dictionaries/project.xml index 4fdcbddc..1c1a71c0 100644 --- a/.idea/dictionaries/project.xml +++ b/.idea/dictionaries/project.xml @@ -3,6 +3,7 @@ anyvalue memoizes + ulid \ No newline at end of file diff --git a/config/project-scratch-def.json b/config/project-scratch-def.json index 96655d1f..94ea4a0d 100644 --- a/config/project-scratch-def.json +++ b/config/project-scratch-def.json @@ -1,19 +1,19 @@ { - "orgName": "Ignoti Et Quasi Occulti", - "description": "ApexKit", - "edition": "Developer", - "hasSampleData": false, - "features": [ - "EinsteinGPTForDevelopers", - "EnableSetPasswordInApi", - "PlatformCache" - ], - "settings": { - "lightningExperienceSettings": { - "enableS1DesktopEnabled": true - }, - "mobileSettings": { - "enableS1EncryptedStoragePref2": false - } - } -} \ No newline at end of file + "orgName": "Ignoti Et Quasi Occulti", + "description": "ApexKit", + "edition": "Developer", + "hasSampleData": false, + "features": [ + "EinsteinGPTForDevelopers", + "EnableSetPasswordInApi", + "PlatformCache" + ], + "settings": { + "lightningExperienceSettings": { + "enableS1DesktopEnabled": true + }, + "mobileSettings": { + "enableS1EncryptedStoragePref2": false + } + } +} diff --git a/force-app/main/default/classes/ULID/tests/ULIDTests.cls b/force-app/main/default/classes/ULID/tests/ULIDTests.cls index b8143afa..026f95dc 100644 --- a/force-app/main/default/classes/ULID/tests/ULIDTests.cls +++ b/force-app/main/default/classes/ULID/tests/ULIDTests.cls @@ -1,4 +1,4 @@ -@isTest /** +@IsTest /** * @description This seems like a woefully inadequate test class. * However, the ULID class contains no branching logic to test. * The single public method is fully tested by this class' method. @@ -6,7 +6,7 @@ * deterministic output. */ class ULIDTests { - @isTest + @IsTest private static void testGenerateMethod() { Test.startTest(); String ulid = ULID.generate(); diff --git a/force-app/main/default/classes/feature flags/tests/FeatureFlagTests.cls b/force-app/main/default/classes/feature flags/tests/FeatureFlagTests.cls index da09c84d..febfdf08 100644 --- a/force-app/main/default/classes/feature flags/tests/FeatureFlagTests.cls +++ b/force-app/main/default/classes/feature flags/tests/FeatureFlagTests.cls @@ -161,7 +161,10 @@ class FeatureFlagTests { @IsTest private static void testFeatureFoundEnabledViaCustomPermissionPositive() { FeatureFlagDataProvider dataProvider = new FeatureFlagDataProvider(); - PermissionsHelper.enableCustomPermission('ApexKit_Example', UserInfo.getUserId()); + PermissionsHelper.enableCustomPermission( + 'ApexKit_Example', + UserInfo.getUserId() + ); dataProvider.overrideFlags( FeatureFlagCommonTests.getTestFlag('TestFlag', false) ); diff --git a/package.json b/package.json index d2e9a753..2855b0e7 100644 --- a/package.json +++ b/package.json @@ -46,5 +46,4 @@ "volta": { "node": "20.15.0" } - }