From 579286da0b7807042aa07047604b24dc78e41fb4 Mon Sep 17 00:00:00 2001 From: Jonathan Gillespie Date: Sun, 21 Jan 2024 17:22:33 -0500 Subject: [PATCH] Bugfix for Name-Shadowing Issues with the Schema Namespace (#608) * Added custom Account class (name shadowing), updated all references to 'Account' to instead use 'Schema.Account' * Added custom AuthSession class (name shadowing), updated all references to 'AuthSession' to instead use 'Schema.AuthSession' * Added custom LoginHistory class (name shadowing), updated all references to 'LoginHistory' to instead use 'Schema.LoginHistory' * Added custom Organization class (name shadowing), updated all references to 'Organization' to instead use 'Schema.Organization' * Added custom Profile class (name shadowing), updated all references to 'Profile' to instead use 'Schema.Profile' * Added custom Topic and TopicAssignment classes (name shadowing), updated all references to 'Topic' and 'TopicAssignment' to instead use 'Schema.Topic' and 'Schema.TopicAssignment' * Added custom User class (name shadowing), updated all references to 'User' to instead use 'Schema.User' * Updated some inconsistent uses of 'Network' to instead use 'Schema.Network' * Moved name shadowing classes to a dedicated name-shadowing subdirectory * Regenerated ApexDocs so the fully qualified class names (e.g., Schema.Organization) are used in the docs --- README.md | 10 +-- .../classes/MicrobatchSelfRegController.cls | 6 +- .../classes/MyProfilePageController.cls | 4 +- .../classes/MyProfilePageControllerTest.cls | 6 +- .../classes/SiteRegisterController.cls | 2 +- docs/apex/Configuration/LoggerParameter.md | 18 ++--- .../LogManagementDataSelector.md | 80 +++++++++---------- .../LoggerSettingsController.md | 18 ++--- docs/apex/Logger-Engine/Logger.md | 2 +- .../Logger-Engine/LoggerEngineDataSelector.md | 56 ++++++------- .../Test-Utilities/LoggerMockDataCreator.md | 58 +++++++------- .../configuration/classes/LoggerParameter.cls | 34 ++++---- .../classes/LogEntryEventHandler.cls | 24 +++--- .../log-management/classes/LogHandler.cls | 6 +- .../classes/LogManagementDataSelector.cls | 64 ++++++++------- .../classes/LoggerEmailSender.cls | 2 +- .../classes/LoggerHomeHeaderController.cls | 2 +- .../classes/LoggerSettingsController.cls | 18 ++--- .../classes/LogEntryEventBuilder.cls | 8 +- .../main/logger-engine/classes/Logger.cls | 16 ++-- .../classes/LoggerEngineDataSelector.cls | 56 ++++++------- .../main/logger-engine/lwc/logger/logger.js | 2 +- .../classes/LoggerCache_Tests.cls | 42 +++++----- .../classes/LoggerParameter_Tests.cls | 4 +- .../utilities/LoggerMockDataCreator.cls | 50 ++++++------ .../classes/LogBatchPurgeController_Tests.cls | 6 +- .../classes/LogEntryEventHandler_Tests.cls | 22 ++--- .../classes/LogEntryHandler_Tests.cls | 6 +- .../classes/LogHandler_Tests.cls | 18 ++--- .../LogManagementDataSelector_Tests.cls | 64 ++++++++------- .../LoggerHomeHeaderController_Tests.cls | 6 +- .../classes/LoggerSObjectMetadata_Tests.cls | 2 +- .../LoggerSettingsController_Tests.cls | 26 +++--- .../classes/ComponentLogger_Tests.cls | 6 +- .../classes/FlowCollectionLogEntry_Tests.cls | 8 +- .../classes/FlowRecordLogEntry_Tests.cls | 8 +- .../classes/LogEntryEventBuilder_Tests.cls | 56 ++++++------- .../classes/LogMessage_Tests.cls | 2 +- .../classes/LoggerDataStore_Tests.cls | 6 +- .../LoggerEngineDataSelector_Tests.cls | 18 ++--- .../classes/LoggerSObjectHandler_Tests.cls | 52 ++++++------ .../classes/LoggerSObjectProxy_Tests.cls | 12 +-- .../LoggerTriggerableContext_Tests.cls | 22 ++--- .../logger-engine/classes/Logger_Tests.cls | 54 ++++++------- .../classes/NebulaLogger_E2E_Tests.cls | 4 +- .../{ => name-shadowing}/AccessType.cls | 0 .../AccessType.cls-meta.xml | 0 .../classes/name-shadowing/Account.cls | 10 +++ .../Account.cls-meta.xml} | 0 .../classes/{ => name-shadowing}/Assert.cls | 0 .../Assert.cls-meta.xml} | 0 .../AuraHandledException.cls | 0 .../AuraHandledException.cls-meta.xml} | 0 .../classes/name-shadowing/AuthSession.cls | 10 +++ .../AuthSession.cls-meta.xml} | 0 .../{ => name-shadowing}/CalloutException.cls | 0 .../CalloutException.cls-meta.xml} | 0 .../{ => name-shadowing}/DmlException.cls | 0 .../DmlException.cls-meta.xml} | 0 .../FeatureManagement.cls | 0 .../FeatureManagement.cls-meta.xml} | 0 .../classes/{ => name-shadowing}/FieldSet.cls | 0 .../FieldSet.cls-meta.xml} | 0 .../{ => name-shadowing}/FieldSetMember.cls | 0 .../FieldSetMember.cls-meta.xml} | 0 .../classes/{ => name-shadowing}/Http.cls | 0 .../Http.cls-meta.xml} | 0 .../{ => name-shadowing}/HttpCalloutMock.cls | 0 .../HttpCalloutMock.cls-meta.xml} | 0 .../{ => name-shadowing}/HttpRequest.cls | 0 .../HttpRequest.cls-meta.xml} | 0 .../{ => name-shadowing}/HttpResponse.cls | 0 .../HttpResponse.cls-meta.xml} | 0 .../IllegalArgumentException.cls | 0 .../IllegalArgumentException.cls-meta.xml} | 0 .../classes/{ => name-shadowing}/Limits.cls | 0 .../Limits.cls-meta.xml} | 0 .../{ => name-shadowing}/LoggingLevel.cls | 0 .../LoggingLevel.cls-meta.xml} | 0 .../classes/name-shadowing/LoginHistory.cls | 10 +++ .../LoginHistory.cls-meta.xml} | 0 .../classes/{ => name-shadowing}/Network.cls | 0 .../Network.cls-meta.xml} | 0 .../classes/name-shadowing/Organization.cls | 10 +++ .../Organization.cls-meta.xml} | 0 .../classes/name-shadowing/Profile.cls | 10 +++ .../Profile.cls-meta.xml} | 0 .../SObjectAccessDecision.cls | 0 .../SObjectAccessDecision.cls-meta.xml} | 0 .../{ => name-shadowing}/SObjectField.cls | 0 .../SObjectField.cls-meta.xml} | 0 .../{ => name-shadowing}/SObjectType.cls | 0 .../name-shadowing/SObjectType.cls-meta.xml | 5 ++ .../classes/{ => name-shadowing}/Security.cls | 0 .../name-shadowing/Security.cls-meta.xml | 5 ++ .../classes/{ => name-shadowing}/Test.cls | 0 .../classes/name-shadowing/Test.cls-meta.xml | 5 ++ .../classes/name-shadowing/Topic.cls | 10 +++ .../classes/name-shadowing/Topic.cls-meta.xml | 5 ++ .../name-shadowing/TopicAssignment.cls | 10 +++ .../TopicAssignment.cls-meta.xml | 5 ++ .../classes/{ => name-shadowing}/Type.cls | 0 .../classes/name-shadowing/Type.cls-meta.xml | 5 ++ .../classes/name-shadowing/User.cls | 10 +++ .../classes/name-shadowing/User.cls-meta.xml | 5 ++ .../classes/{ => name-shadowing}/UserInfo.cls | 0 .../name-shadowing/UserInfo.cls-meta.xml | 5 ++ .../tests/LogBatchPurger_Tests_Database.cls | 4 +- .../LogEntryEventBuilder_Tests_Network.cls | 12 +-- .../LogEntryEventBuilder_Tests_Security.cls | 8 +- .../tests/LoggerCache_Tests_PlatformCache.cls | 20 ++--- ...oggerSettingsController_Tests_Security.cls | 14 ++-- .../tests/Logger_Tests_Network.cls | 24 ++++-- .../LogFlowExecutionErrorEventHandler.cls | 8 +- ...ogFlowExecutionErrorEventHandler_Tests.cls | 4 +- .../plugin/classes/LogEntryArchivePlugin.cls | 2 +- .../classes/Account_Batch_Logger_Example.cls | 4 +- .../Account_Trigger_Logger_Example.trigger | 4 +- package.json | 2 +- sfdx-project.json | 7 +- 120 files changed, 686 insertions(+), 533 deletions(-) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/AccessType.cls (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/AccessType.cls-meta.xml (100%) create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/Account.cls rename nebula-logger/extra-tests/classes/{Assert.cls-meta.xml => name-shadowing/Account.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/Assert.cls (100%) rename nebula-logger/extra-tests/classes/{AuraHandledException.cls-meta.xml => name-shadowing/Assert.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/AuraHandledException.cls (100%) rename nebula-logger/extra-tests/classes/{CalloutException.cls-meta.xml => name-shadowing/AuraHandledException.cls-meta.xml} (100%) create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/AuthSession.cls rename nebula-logger/extra-tests/classes/{DmlException.cls-meta.xml => name-shadowing/AuthSession.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/CalloutException.cls (100%) rename nebula-logger/extra-tests/classes/{FeatureManagement.cls-meta.xml => name-shadowing/CalloutException.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/DmlException.cls (100%) rename nebula-logger/extra-tests/classes/{FieldSet.cls-meta.xml => name-shadowing/DmlException.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/FeatureManagement.cls (100%) rename nebula-logger/extra-tests/classes/{FieldSetMember.cls-meta.xml => name-shadowing/FeatureManagement.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/FieldSet.cls (100%) rename nebula-logger/extra-tests/classes/{Http.cls-meta.xml => name-shadowing/FieldSet.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/FieldSetMember.cls (100%) rename nebula-logger/extra-tests/classes/{HttpCalloutMock.cls-meta.xml => name-shadowing/FieldSetMember.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/Http.cls (100%) rename nebula-logger/extra-tests/classes/{HttpRequest.cls-meta.xml => name-shadowing/Http.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/HttpCalloutMock.cls (100%) rename nebula-logger/extra-tests/classes/{HttpResponse.cls-meta.xml => name-shadowing/HttpCalloutMock.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/HttpRequest.cls (100%) rename nebula-logger/extra-tests/classes/{IllegalArgumentException.cls-meta.xml => name-shadowing/HttpRequest.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/HttpResponse.cls (100%) rename nebula-logger/extra-tests/classes/{Limits.cls-meta.xml => name-shadowing/HttpResponse.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/IllegalArgumentException.cls (100%) rename nebula-logger/extra-tests/classes/{LoggingLevel.cls-meta.xml => name-shadowing/IllegalArgumentException.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/Limits.cls (100%) rename nebula-logger/extra-tests/classes/{Network.cls-meta.xml => name-shadowing/Limits.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/LoggingLevel.cls (100%) rename nebula-logger/extra-tests/classes/{SObjectAccessDecision.cls-meta.xml => name-shadowing/LoggingLevel.cls-meta.xml} (100%) create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/LoginHistory.cls rename nebula-logger/extra-tests/classes/{SObjectField.cls-meta.xml => name-shadowing/LoginHistory.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/Network.cls (100%) rename nebula-logger/extra-tests/classes/{SObjectType.cls-meta.xml => name-shadowing/Network.cls-meta.xml} (100%) create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/Organization.cls rename nebula-logger/extra-tests/classes/{Security.cls-meta.xml => name-shadowing/Organization.cls-meta.xml} (100%) create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/Profile.cls rename nebula-logger/extra-tests/classes/{Test.cls-meta.xml => name-shadowing/Profile.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/SObjectAccessDecision.cls (100%) rename nebula-logger/extra-tests/classes/{Type.cls-meta.xml => name-shadowing/SObjectAccessDecision.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/SObjectField.cls (100%) rename nebula-logger/extra-tests/classes/{UserInfo.cls-meta.xml => name-shadowing/SObjectField.cls-meta.xml} (100%) rename nebula-logger/extra-tests/classes/{ => name-shadowing}/SObjectType.cls (100%) create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/SObjectType.cls-meta.xml rename nebula-logger/extra-tests/classes/{ => name-shadowing}/Security.cls (100%) create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/Security.cls-meta.xml rename nebula-logger/extra-tests/classes/{ => name-shadowing}/Test.cls (100%) create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/Test.cls-meta.xml create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/Topic.cls create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/Topic.cls-meta.xml create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/TopicAssignment.cls create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/TopicAssignment.cls-meta.xml rename nebula-logger/extra-tests/classes/{ => name-shadowing}/Type.cls (100%) create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/Type.cls-meta.xml create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/User.cls create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/User.cls-meta.xml rename nebula-logger/extra-tests/classes/{ => name-shadowing}/UserInfo.cls (100%) create mode 100644 nebula-logger/extra-tests/classes/name-shadowing/UserInfo.cls-meta.xml diff --git a/README.md b/README.md index 38c2dd9ab..66a259f9e 100644 --- a/README.md +++ b/README.md @@ -5,15 +5,15 @@ The most robust logger for Salesforce. Works with Apex, Lightning Components, Flow, Process Builder & Integrations. Designed for Salesforce admins, developers & architects. -## Unlocked Package - v4.12.4 +## Unlocked Package - v4.12.5 -[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk5KQAS) -[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk5KQAS) +[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk5PQAS) +[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk5PQAS) [![View Documentation](./images/btn-view-documentation.png)](https://jongpie.github.io/NebulaLogger/) -`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y000001Mk5KQAS` +`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y000001Mk5PQAS` -`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y000001Mk5KQAS` +`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y000001Mk5PQAS` --- diff --git a/config/experience-cloud/classes/MicrobatchSelfRegController.cls b/config/experience-cloud/classes/MicrobatchSelfRegController.cls index 2c6a42571..7473dd437 100644 --- a/config/experience-cloud/classes/MicrobatchSelfRegController.cls +++ b/config/experience-cloud/classes/MicrobatchSelfRegController.cls @@ -23,7 +23,7 @@ public class MicrobatchSelfRegController { String profileId = null; //to be filled by customer String UUID; - User u = new User(); + Schema.User u = new Schema.User(); u.Username = userName; u.Email = email; u.FirstName = firstName; @@ -35,9 +35,9 @@ public class MicrobatchSelfRegController { u.LanguageLocaleKey = 'en_US'; u.EmailEncodingKey = 'UTF-8'; - Account acc = new Account(); + Schema.Account acc = new Schema.Account(); acc.Name = 'Account for ' + lastName; - Contact c = new Contact(); + Schema.Contact c = new Schema.Contact(); c.lastName = lastName; try { diff --git a/config/experience-cloud/classes/MyProfilePageController.cls b/config/experience-cloud/classes/MyProfilePageController.cls index d14780be5..4c345f728 100644 --- a/config/experience-cloud/classes/MyProfilePageController.cls +++ b/config/experience-cloud/classes/MyProfilePageController.cls @@ -3,10 +3,10 @@ Guest users are never able to access this page. */ public with sharing class MyProfilePageController { - private User user; + private Schema.User user; private boolean isEdit = false; - public User getUser() { + public Schema.User getUser() { return user; } diff --git a/config/experience-cloud/classes/MyProfilePageControllerTest.cls b/config/experience-cloud/classes/MyProfilePageControllerTest.cls index ebf6e3934..bd61546c3 100644 --- a/config/experience-cloud/classes/MyProfilePageControllerTest.cls +++ b/config/experience-cloud/classes/MyProfilePageControllerTest.cls @@ -7,10 +7,10 @@ public with sharing class MyProfilePageControllerTest { @IsTest(SeeAllData=true) static void testSave() { // Modify the test to query for a portal user that exists in your org - List existingPortalUsers = [SELECT id, profileId, userRoleId FROM User WHERE UserRoleId != NULL AND UserType = 'CustomerSuccess']; + List existingPortalUsers = [SELECT id, profileId, userRoleId FROM User WHERE UserRoleId != NULL AND UserType = 'CustomerSuccess']; if (existingPortalUsers.isEmpty()) { - User currentUser = [ + Schema.User currentUser = [ SELECT id, title, firstname, lastname, email, phone, mobilephone, fax, street, city, state, postalcode, country FROM User WHERE id = :System.UserInfo.getUserId() @@ -33,7 +33,7 @@ public with sharing class MyProfilePageControllerTest { currentUser = [SELECT id, fax FROM User WHERE id = :currentUser.Id]; // System.Assert.isTrue(currentUser.fax == randFax); } else { - User existingPortalUser = existingPortalUsers[0]; + Schema.User existingPortalUser = existingPortalUsers[0]; String randFax = Math.rint(Math.random() * 1000) + '5551234'; System.runAs(existingPortalUser) { diff --git a/config/experience-cloud/classes/SiteRegisterController.cls b/config/experience-cloud/classes/SiteRegisterController.cls index f68260f15..8e0d37360 100644 --- a/config/experience-cloud/classes/SiteRegisterController.cls +++ b/config/experience-cloud/classes/SiteRegisterController.cls @@ -41,7 +41,7 @@ public with sharing class SiteRegisterController { ApexPages.addMessage(msg); return null; } - User u = new User(); + Schema.User u = new Schema.User(); u.Username = username; u.Email = email; u.CommunityNickname = communityNickname; diff --git a/docs/apex/Configuration/LoggerParameter.md b/docs/apex/Configuration/LoggerParameter.md index d733fe9d2..4895f2a58 100644 --- a/docs/apex/Configuration/LoggerParameter.md +++ b/docs/apex/Configuration/LoggerParameter.md @@ -52,11 +52,11 @@ Controls if Nebula Logger queries `ApexClass` data. When set to `false`, any `Ap #### `QUERY_AUTH_SESSION_DATA` → `Boolean` -Controls if Nebula Logger queries `AuthSession` data. When set to `false`, any `AuthSession` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryAuthSessionData`, or `true` as the default +Controls if Nebula Logger queries `Schema.AuthSession` data. When set to `false`, any `Schema.AuthSession` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryAuthSessionData`, or `true` as the default #### `QUERY_AUTH_SESSION_DATA_SYNCHRONOUSLY` → `Boolean` -Controls if Nebula Logger queries `AuthSession` data synchronously & populated on `LogEntryEvent__e` records. When set to `false`, any `AuthSession` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryAuthSessionDataSynchronously`, or `true` as the default +Controls if Nebula Logger queries `Schema.AuthSession` data synchronously & populated on `LogEntryEvent__e` records. When set to `false`, any `Schema.AuthSession` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryAuthSessionDataSynchronously`, or `true` as the default #### `QUERY_FLOW_DEFINITION_VIEW_DATA` → `Boolean` @@ -64,19 +64,19 @@ Controls if Nebula Logger queries `FlowDefinitionView` data. When set to `false` #### `QUERY_NETWORK_DATA` → `Boolean` -Controls if Nebula Logger queries `Network` data. When set to `false`, any `Network` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryNetworkData`, or `true` as the default +Controls if Nebula Logger queries `Schema.Network` data. When set to `false`, any `Schema.Network` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryNetworkData`, or `true` as the default #### `QUERY_NETWORK_DATA_SYNCHRONOUSLY` → `Boolean` -Controls if Nebula Logger queries `Network` data is queried synchronously & populated on `LogEntryEvent__e` records. When set to `false`, any `Network` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryNetworkDataSynchronously`, or `true` as the default +Controls if Nebula Logger queries `Schema.Network` data is queried synchronously & populated on `LogEntryEvent__e` records. When set to `false`, any `Schema.Network` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryNetworkDataSynchronously`, or `true` as the default #### `QUERY_ORGANIZATION_DATA` → `Boolean` -Controls if Nebula Logger queries `Organization` data. When set to `false`, any `Organization` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryOrganizationData`, or `true` as the default +Controls if Nebula Logger queries `Schema.Organization` data. When set to `false`, any `Schema.Organization` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryOrganizationData`, or `true` as the default #### `QUERY_ORGANIZATION_DATA_SYNCHRONOUSLY` → `Boolean` -Indicates if Nebula Logger queries `Organization` data is queried synchronously & populated on `LogEntryEvent__e` records. When set to `false`, any `Organization` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryOrganizationDataSynchronously`, or `true` as the default +Indicates if Nebula Logger queries `Schema.Organization` data is queried synchronously & populated on `LogEntryEvent__e` records. When set to `false`, any `Schema.Organization` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryOrganizationDataSynchronously`, or `true` as the default #### `QUERY_RELATED_RECORD_DATA` → `Boolean` @@ -84,11 +84,11 @@ Controls if Nebula Logger queries data for records synthetically related to a `L #### `QUERY_USER_DATA` → `Boolean` -Controls if Nebula Logger queries `User` data. When set to `false`, any `User` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryUserData`, or `true` as the default +Controls if Nebula Logger queries `Schema.User` data. When set to `false`, any `Schema.User` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryUserData`, or `true` as the default #### `QUERY_USER_DATA_SYNCHRONOUSLY` → `Boolean` -Indicates if Nebula Logger queries `User` data is queried synchronously & populated on `LogEntryEvent__e` records. When set to `false`, any `User` fields on `LogEntryEvent__e` that rely on querying will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryUserDataSynchronously`, or `true` as the default +Indicates if Nebula Logger queries `Schema.User` data is queried synchronously & populated on `LogEntryEvent__e` records. When set to `false`, any `Schema.User` fields on `LogEntryEvent__e` that rely on querying will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryUserDataSynchronously`, or `true` as the default #### `SEND_ERROR_EMAIL_NOTIFICATIONS` → `Boolean` @@ -112,7 +112,7 @@ Indicates if Platform Cache is used to cache organization & session data in #### `USE_TOPICS_FOR_TAGS` → `Boolean` -Indicates if Logger's tagging will use `Topic` and `TopicAssignment` for storing tags (when `true`), or uses Nebula Logger's custom objects `LoggerTag__c` and `LogEntryTag__c` (when `false`) Controlled by the custom metadata record `LoggerParameter.UseTopicsForTags`, or `false` as the default +Indicates if Logger's tagging will use `Schema.Topic` and `Schema.TopicAssignment` for storing tags (when `true`), or uses Nebula Logger's custom objects `LoggerTag__c` and `LogEntryTag__c` (when `false`) Controlled by the custom metadata record `LoggerParameter.UseTopicsForTags`, or `false` as the default --- diff --git a/docs/apex/Log-Management/LogManagementDataSelector.md b/docs/apex/Log-Management/LogManagementDataSelector.md index b63bed9f1..1599e4002 100644 --- a/docs/apex/Log-Management/LogManagementDataSelector.md +++ b/docs/apex/Log-Management/LogManagementDataSelector.md @@ -337,49 +337,49 @@ List<Log\_\_c> The list of matching `Log__c` records -#### `getProfilesById(List profileIds)` → `List` +#### `getProfilesById(List profileIds)` → `List` -Returns a `List<Profile>` of records with the specified profile IDs +Returns a `List<Schema.Profile>` of records with the specified profile IDs ##### Parameters -| Param | Description | -| ------------ | -------------------------------------------------- | -| `profileIds` | The list of `ID` of the `Profile` records to query | +| Param | Description | +| ------------ | --------------------------------------------------------- | +| `profileIds` | The list of `ID` of the `Schema.Profile` records to query | ##### Return **Type** -List<Profile> +List<Schema.Profile> **Description** -The list of matching `Profile` records +The list of matching `Schema.Profile` records -#### `getProfilesByNameSearch(String searchTerm)` → `List` +#### `getProfilesByNameSearch(String searchTerm)` → `List` -Returns a `List<Profile>` of records where the profile's names partially matches the specified search term +Returns a `List<Schema.Profile>` of records where the profile's names partially matches the specified search term ##### Parameters -| Param | Description | -| ------------ | --------------------------------------------------------------- | -| `searchTerm` | The `String` search term to use for searching `Profile` records | +| Param | Description | +| ------------ | ---------------------------------------------------------------------- | +| `searchTerm` | The `String` search term to use for searching `Schema.Profile` records | ##### Return **Type** -List<Profile> +List<Schema.Profile> **Description** -The list of matching `Profile` records +The list of matching `Schema.Profile` records -#### `getQueuesByDeveloperName(List queueDeveloperNames)` → `List` +#### `getQueuesByDeveloperName(List queueDeveloperNames)` → `List` -Returns a `List<Group>` of records with the specified developer names and type == 'Queue' +Returns a `List<Schema.Group>` of records with the specified developer names and type == 'Queue' ##### Parameters @@ -391,11 +391,11 @@ Returns a `List<Group>` of records with the specified developer names and **Type** -List<Group> +List<Schema.Group> **Description** -The list of matching `Group` records +The list of matching `Schema.Group` records #### `getRecordLogEntries(Id recordId, String fieldsClause, String orderByClause, Integer rowLimit)` → `List` @@ -440,9 +440,9 @@ List<LoggerTag\_\_c> The list of matching `LoggerTag__c` records -#### `getTopicsByName(Set topicNames)` → `List` +#### `getTopicsByName(Set topicNames)` → `List` -Returns a list of `Topic` records with one of the specified topic names +Returns a list of `Schema.Topic` records with one of the specified topic names ##### Parameters @@ -454,55 +454,55 @@ Returns a list of `Topic` records with one of the specified topic names **Type** -List<Topic> +List<Schema.Topic> **Description** -The list of matching `Topic` records +The list of matching `Schema.Topic` records -#### `getUsersById(List userIds)` → `List` +#### `getUsersById(List userIds)` → `List` -Returns a `List<User>` of records with the specified user IDs +Returns a `List<Schema.User>` of records with the specified user IDs ##### Parameters -| Param | Description | -| --------- | ----------------------------------------------- | -| `userIds` | The list of `ID` of the `User` records to query | +| Param | Description | +| --------- | ------------------------------------------------------ | +| `userIds` | The list of `ID` of the `Schema.User` records to query | ##### Return **Type** -List<User> +List<Schema.User> **Description** -The list of matching `User` records +The list of matching `Schema.User` records -#### `getUsersByNameSearch(String searchTerm)` → `List` +#### `getUsersByNameSearch(String searchTerm)` → `List` -Returns a `List<User>` of records where the User's names or username partially matches the specified search term +Returns a `List<Schema.User>` of records where the User's names or username partially matches the specified search term ##### Parameters -| Param | Description | -| ------------ | ------------------------------------------------------------ | -| `searchTerm` | The `String` search term to use for searching `User` records | +| Param | Description | +| ------------ | ------------------------------------------------------------------- | +| `searchTerm` | The `String` search term to use for searching `Schema.User` records | ##### Return **Type** -List<User> +List<Schema.User> **Description** -The list of matching `User` records +The list of matching `Schema.User` records -#### `getUsersByUsername(List usernames)` → `List` +#### `getUsersByUsername(List usernames)` → `List` -Returns a `List<User>` of records with the specified usernames (`Schema.User.Username`) +Returns a `List<Schema.User>` of records with the specified usernames (`Schema.User.Username`) ##### Parameters @@ -514,10 +514,10 @@ Returns a `List<User>` of records with the specified usernames (`Schema.Us **Type** -List<User> +List<Schema.User> **Description** -Tje list of matching `User` records +Tje list of matching `Schema.User` records --- diff --git a/docs/apex/Log-Management/LoggerSettingsController.md b/docs/apex/Log-Management/LoggerSettingsController.md index 7b5eb09b2..705b6bdd7 100644 --- a/docs/apex/Log-Management/LoggerSettingsController.md +++ b/docs/apex/Log-Management/LoggerSettingsController.md @@ -48,19 +48,19 @@ Deletes the specified `LoggerSettings__c` record | ---------------- | -------------------- | | `settingsRecord` | The record to delete | -#### `getOrganization()` → `Organization` +#### `getOrganization()` → `Schema.Organization` -Returns the `Organization` record for the current environment +Returns the `Schema.Organization` record for the current environment ##### Return **Type** -Organization +Schema.Organization **Description** -The current environment's `Organization` record +The current environment's `Schema.Organization` record #### `getPicklistOptions()` → `LoggerSettingsPicklistOptions` @@ -106,10 +106,10 @@ searchForSetupOwner description ##### Parameters -| Param | Description | -| ---------------- | --------------------------------------------- | -| `setupOwnerType` | The object to search (`Profile` or `User`) | -| `searchTerm` | The search term to use when searching records | +| Param | Description | +| ---------------- | -------------------------------------------------------- | +| `setupOwnerType` | The object to search (`Schema.Profile` or `Schema.User`) | +| `searchTerm` | The search term to use when searching records | ##### Return @@ -207,7 +207,7 @@ The sorting result #### LoggerSettingsController.SetupOwnerSearchResult class -Inner class used for returning search results for `Profile` and `User` records +Inner class used for returning search results for `Schema.Profile` and `Schema.User` records --- diff --git a/docs/apex/Logger-Engine/Logger.md b/docs/apex/Logger-Engine/Logger.md index 0718500c0..b7992f20e 100644 --- a/docs/apex/Logger-Engine/Logger.md +++ b/docs/apex/Logger-Engine/Logger.md @@ -3634,7 +3634,7 @@ LoggerSettings\_\_c LoggerSettings\_\_c - The current user's instance of the custom settings -#### `getUserSettings(User loggingUser)` → `LoggerSettings__c` +#### `getUserSettings(Schema.User loggingUser)` → `LoggerSettings__c` **This is only intended to be used internally by Nebula Logger, and is subject to change.** Returns the specified user's instance of `LoggerSettings__c` diff --git a/docs/apex/Logger-Engine/LoggerEngineDataSelector.md b/docs/apex/Logger-Engine/LoggerEngineDataSelector.md index c776d72f7..3f9d0ede3 100644 --- a/docs/apex/Logger-Engine/LoggerEngineDataSelector.md +++ b/docs/apex/Logger-Engine/LoggerEngineDataSelector.md @@ -12,7 +12,7 @@ Selector class used for all queries that are specific to the logger engine layer #### `getAuthSessionProxies(List userIds)` → `Map` -Returns a `Map<Id, AuthSession>` for the specified user IDs & their matching active sessions, or `null` if there is not a current session +Returns a `Map<Id, LoggerSObjectProxy.AuthSession>` for the specified user IDs & their matching active sessions, or `null` if there is not a current session ##### Parameters @@ -28,11 +28,11 @@ Map<Id, LoggerSObjectProxy.AuthSession> **Description** -The instance of `Map<Id, AuthSession>` containing any matching `AuthSession` records +The instance of `Map<Id, LoggerSObjectProxy.AuthSession>` containing any matching `Schema.AuthSession` records #### `getCachedAuthSessionProxy()` → `LoggerSObjectProxy.AuthSession` -Returns a cached copy of `AuthSession` for the current user's current session, or `null` if there is not a current session +Returns a cached copy of `LoggerSObjectProxy.AuthSession` for the current user's current session, or `null` if there is not a current session ##### Return @@ -42,7 +42,7 @@ LoggerSObjectProxy.AuthSession **Description** -The cached `AuthSession` record +The cached `LoggerSObjectProxy.AuthSession` record #### `getCachedLoggerSObjectHandlers()` → `List` @@ -60,13 +60,13 @@ The cached `List<LoggerSObjectHandler_t>` records #### `getCachedNetworkProxy(Id networkId)` → `LoggerSObjectProxy.Network` -Returns a cached copy of the current user's `Network` site, or `null` if the current user is not associated with a `Network` site +Returns a cached copy of the current user's `Schema.Network` site, or `null` if the current user is not associated with a `Schema.Network` site ##### Parameters -| Param | Description | -| ----------- | --------------------------------------- | -| `networkId` | The record ID of the `Network` to query | +| Param | Description | +| ----------- | ---------------------------------------------- | +| `networkId` | The record ID of the `Schema.Network` to query | ##### Return @@ -76,21 +76,21 @@ LoggerSObjectProxy.Network **Description** -The cached `Network` record +The cached `Schema.Network` record -#### `getCachedOrganization()` → `Organization` +#### `getCachedOrganization()` → `Schema.Organization` -Returns a cached copy of the `Organization` record in the org, including some fields that cannot be accessed via `UserInfo` +Returns a cached copy of the `Schema.Organization` record in the org, including some fields that cannot be accessed via `UserInfo` ##### Return **Type** -Organization +Schema.Organization **Description** -The cached `Organization` record +The cached `Schema.Organization` record #### `getCachedTagAssignmentRules()` → `List` @@ -106,7 +106,7 @@ List<LogEntryTagRule_t> The cached `List<LogEntryTagRule_t>` records -#### `getCachedUser()` → `User` +#### `getCachedUser()` → `Schema.User` Returns a cached copy of the current user, including some profile fields that cannot be accessed via `UserInfo` @@ -114,11 +114,11 @@ Returns a cached copy of the current user, including some profile fields that ca **Type** -User +Schema.User **Description** -The cached `User` record for the current user +The cached `Schema.User` record for the current user #### `getInstance()` → `LoggerEngineDataSelector` @@ -136,13 +136,13 @@ The singleton instance of `LoggerEngineDataSelector` #### `getNetworkProxies(List networkIds)` → `Map` -Returns a list of matching `Network` records based on the provided list of network IDs +Returns a list of matching `Schema.Network` records based on the provided list of network IDs ##### Parameters -| Param | Description | -| ------------ | ---------------------------------- | -| `networkIds` | The list of `Network` IDs to query | +| Param | Description | +| ------------ | ----------------------------------------- | +| `networkIds` | The list of `Schema.Network` IDs to query | ##### Return @@ -152,26 +152,26 @@ Map<Id, LoggerSObjectProxy.Network> **Description** -The instance of `Map<Id, SObject>` containing any matching `Network` records +The instance of `Map<Id, SObject>` containing any matching `Schema.Network` records -#### `getUsers(List userIds)` → `Map` +#### `getUsers(List userIds)` → `Map` -Returns a list of matching `User` records based on the provided list of user IDs +Returns a list of matching `Schema.User` records based on the provided list of user IDs ##### Parameters -| Param | Description | -| --------- | ------------------------------- | -| `userIds` | The list of `User` IDs to query | +| Param | Description | +| --------- | -------------------------------------- | +| `userIds` | The list of `Schema.User` IDs to query | ##### Return **Type** -Map<Id, User> +Map<Id, Schema.User> **Description** -The instance of `Map<Id, User>` containing any matching `User` records +The instance of `Map<Id, Schema.User>` containing any matching `Schema.User` records --- diff --git a/docs/apex/Test-Utilities/LoggerMockDataCreator.md b/docs/apex/Test-Utilities/LoggerMockDataCreator.md index 2703807d6..0e2d5152c 100644 --- a/docs/apex/Test-Utilities/LoggerMockDataCreator.md +++ b/docs/apex/Test-Utilities/LoggerMockDataCreator.md @@ -380,53 +380,53 @@ String The mock record ID for the specified SObject Type -#### `createUser()` → `User` +#### `createUser()` → `Schema.User` -Creates a `User` record for testing purposes, using the current user's profile +Creates a `Schema.User` record for testing purposes, using the current user's profile ##### Return **Type** -User +Schema.User **Description** -The generated `User` record - it is not automatically inserted into the database. +The generated `Schema.User` record - it is not automatically inserted into the database. -#### `createUser(Id profileId)` → `User` +#### `createUser(Id profileId)` → `Schema.User` -Creates a `User` record for testing purposes, using the specified profile ID +Creates a `Schema.User` record for testing purposes, using the specified profile ID ##### Parameters -| Param | Description | -| ----------- | ---------------------------------------------- | -| `profileId` | The `Profile` ID to use for the created `User` | +| Param | Description | +| ----------- | ------------------------------------------------------------ | +| `profileId` | The `Schema.Profile` ID to use for the created `Schema.User` | ##### Return **Type** -User +Schema.User **Description** -The generated `User` record - it is not automatically inserted into the database. +The generated `Schema.User` record - it is not automatically inserted into the database. -#### `getOrganization()` → `Organization` +#### `getOrganization()` → `Schema.Organization` -Queries for the `Organization` record for the current environment. +Queries for the `Schema.Organization` record for the current environment. ##### Return **Type** -Organization +Schema.Organization **Description** -The matching `Organization` record +The matching `Schema.Organization` record #### `getOrganizationEnvironmentType()` → `String` @@ -442,7 +442,7 @@ String The environment type -#### `getUser()` → `User` +#### `getUser()` → `Schema.User` Returns the current user @@ -450,52 +450,52 @@ Returns the current user **Type** -User +Schema.User **Description** -The matching `User` record +The matching `Schema.User` record -#### `getUser(Id userId)` → `User` +#### `getUser(Id userId)` → `Schema.User` Returns the specified user ##### Parameters -| Param | Description | -| -------- | ------------------------------------ | -| `userId` | The ID of the `User` record to query | +| Param | Description | +| -------- | ------------------------------------------- | +| `userId` | The ID of the `Schema.User` record to query | ##### Return **Type** -User +Schema.User **Description** -The matching `User` record +The matching `Schema.User` record -#### `insertQueue(String queueDeveloperName, Schema.SObjectType sobjectType)` → `Group` +#### `insertQueue(String queueDeveloperName, Schema.SObjectType sobjectType)` → `Schema.Group` -Creates and inserts a `Group` record for testing queues, using the specified SObject Type +Creates and inserts a `Schema.Group` record for testing queues, using the specified SObject Type ##### Parameters | Param | Description | | -------------------- | --------------------------------------------------------------------------------------------- | -| `queueDeveloperName` | The developer name to use for the new queue (stored in `Group.DeveloperName`) | +| `queueDeveloperName` | The developer name to use for the new queue (stored in `Schema.Group.DeveloperName`) | | `sobjectType` | The `SObjectType` that the queue should be able to own (stored in `QueueSObject.SObjectType`) | ##### Return **Type** -Group +Schema.Group **Description** -The inserted `Group` record - it is automatically inserted into the database, as well as 1 child `QueueSObject` record. +The inserted `Schema.Group` record - it is automatically inserted into the database, as well as 1 child `QueueSObject` record. #### `setReadOnlyField(SObject record, Schema.SObjectField field, Object value)` → `SObject` diff --git a/nebula-logger/core/main/configuration/classes/LoggerParameter.cls b/nebula-logger/core/main/configuration/classes/LoggerParameter.cls index a0273d32e..c6a45db4f 100644 --- a/nebula-logger/core/main/configuration/classes/LoggerParameter.cls +++ b/nebula-logger/core/main/configuration/classes/LoggerParameter.cls @@ -167,8 +167,8 @@ public class LoggerParameter { } /** - * @description Controls if Nebula Logger queries `AuthSession` data. - * When set to `false`, any `AuthSession` fields on `LogEntryEvent__e` and `Log__c` will not be populated + * @description Controls if Nebula Logger queries `Schema.AuthSession` data. + * When set to `false`, any `Schema.AuthSession` fields on `LogEntryEvent__e` and `Log__c` will not be populated * Controlled by the custom metadata record `LoggerParameter.QueryAuthSessionData`, or `true` as the default */ public static final Boolean QUERY_AUTH_SESSION_DATA { @@ -182,8 +182,8 @@ public class LoggerParameter { } /** - * @description Controls if Nebula Logger queries `AuthSession` data synchronously & populated on `LogEntryEvent__e` records. - * When set to `false`, any `AuthSession` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried + * @description Controls if Nebula Logger queries `Schema.AuthSession` data synchronously & populated on `LogEntryEvent__e` records. + * When set to `false`, any `Schema.AuthSession` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried * asynchronously and populated on any resulting `Log__c` records. * Controlled by the custom metadata record `LoggerParameter.QueryAuthSessionDataSynchronously`, or `true` as the default */ @@ -213,8 +213,8 @@ public class LoggerParameter { } /** - * @description Controls if Nebula Logger queries `Network` data. - * When set to `false`, any `Network` fields on `LogEntryEvent__e` and `Log__c` will not be populated + * @description Controls if Nebula Logger queries `Schema.Network` data. + * When set to `false`, any `Schema.Network` fields on `LogEntryEvent__e` and `Log__c` will not be populated * Controlled by the custom metadata record `LoggerParameter.QueryNetworkData`, or `true` as the default */ public static final Boolean QUERY_NETWORK_DATA { @@ -228,8 +228,8 @@ public class LoggerParameter { } /** - * @description Controls if Nebula Logger queries `Network` data is queried synchronously & populated on `LogEntryEvent__e` records. - * When set to `false`, any `Network` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried + * @description Controls if Nebula Logger queries `Schema.Network` data is queried synchronously & populated on `LogEntryEvent__e` records. + * When set to `false`, any `Schema.Network` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried * asynchronously and populated on any resulting `Log__c` records. * Controlled by the custom metadata record `LoggerParameter.QueryNetworkDataSynchronously`, or `true` as the default */ @@ -244,8 +244,8 @@ public class LoggerParameter { } /** - * @description Controls if Nebula Logger queries `Organization` data. - * When set to `false`, any `Organization` fields on `LogEntryEvent__e` and `Log__c` will not be populated + * @description Controls if Nebula Logger queries `Schema.Organization` data. + * When set to `false`, any `Schema.Organization` fields on `LogEntryEvent__e` and `Log__c` will not be populated * Controlled by the custom metadata record `LoggerParameter.QueryOrganizationData`, or `true` as the default */ public static final Boolean QUERY_ORGANIZATION_DATA { @@ -259,8 +259,8 @@ public class LoggerParameter { } /** - * @description Indicates if Nebula Logger queries `Organization` data is queried synchronously & populated on `LogEntryEvent__e` records. - * When set to `false`, any `Organization` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried + * @description Indicates if Nebula Logger queries `Schema.Organization` data is queried synchronously & populated on `LogEntryEvent__e` records. + * When set to `false`, any `Schema.Organization` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried * asynchronously and populated on any resulting `Log__c` records. * Controlled by the custom metadata record `LoggerParameter.QueryOrganizationDataSynchronously`, or `true` as the default */ @@ -290,8 +290,8 @@ public class LoggerParameter { } /** - * @description Controls if Nebula Logger queries `User` data. - * When set to `false`, any `User` fields on `LogEntryEvent__e` and `Log__c` will not be populated + * @description Controls if Nebula Logger queries `Schema.User` data. + * When set to `false`, any `Schema.User` fields on `LogEntryEvent__e` and `Log__c` will not be populated * Controlled by the custom metadata record `LoggerParameter.QueryUserData`, or `true` as the default */ public static final Boolean QUERY_USER_DATA { @@ -305,8 +305,8 @@ public class LoggerParameter { } /** - * @description Indicates if Nebula Logger queries `User` data is queried synchronously & populated on `LogEntryEvent__e` records. - * When set to `false`, any `User` fields on `LogEntryEvent__e` that rely on querying will not be populated - the data + * @description Indicates if Nebula Logger queries `Schema.User` data is queried synchronously & populated on `LogEntryEvent__e` records. + * When set to `false`, any `Schema.User` fields on `LogEntryEvent__e` that rely on querying will not be populated - the data * will instead be queried asynchronously and populated on any resulting `Log__c` records. * Controlled by the custom metadata record `LoggerParameter.QueryUserDataSynchronously`, or `true` as the default */ @@ -393,7 +393,7 @@ public class LoggerParameter { } /** - * @description Indicates if Logger's tagging will use `Topic` and `TopicAssignment` for storing tags (when `true`), + * @description Indicates if Logger's tagging will use `Schema.Topic` and `Schema.TopicAssignment` for storing tags (when `true`), * or uses Nebula Logger's custom objects `LoggerTag__c` and `LogEntryTag__c` (when `false`) * Controlled by the custom metadata record `LoggerParameter.UseTopicsForTags`, or `false` as the default */ diff --git a/nebula-logger/core/main/log-management/classes/LogEntryEventHandler.cls b/nebula-logger/core/main/log-management/classes/LogEntryEventHandler.cls index e2ec66a32..4cff4a20c 100644 --- a/nebula-logger/core/main/log-management/classes/LogEntryEventHandler.cls +++ b/nebula-logger/core/main/log-management/classes/LogEntryEventHandler.cls @@ -67,7 +67,7 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler { final String trueString = String.valueOf(true); List logEntryEventsToSave = new List(); for (LogEntryEvent__e logEntryEvent : newLogEntryEvents) { - User loggingUser = new User(Id = logEntryEvent.LoggedById__c, ProfileId = logEntryEvent.ProfileId__c); + Schema.User loggingUser = new Schema.User(Id = logEntryEvent.LoggedById__c, ProfileId = logEntryEvent.ProfileId__c); LoggerSettings__c loggingUserSettings = Logger.getUserSettings(loggingUser); // Apply logger scenario rules @@ -393,8 +393,8 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler { return; } - // Orgs can be configured to either use LoggerTag__c & LogEntryTag__c (default), or use Topic & TopicAssignment - Schema.SObjectType tagSObjectType = LoggerParameter.USE_TOPICS_FOR_TAGS ? Topic.SObjectType : LoggerTag__c.SObjectType; + // Orgs can be configured to either use LoggerTag__c & LogEntryTag__c (default), or use Schema.Topic & Schema.TopicAssignment + Schema.SObjectType tagSObjectType = LoggerParameter.USE_TOPICS_FOR_TAGS ? Schema.Topic.SObjectType : LoggerTag__c.SObjectType; Map tagNameToId = getTagNameToId(tagSObjectType); this.tagNames.addAll(tagNameToId.keySet()); @@ -412,8 +412,8 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler { if (LoggerParameter.USE_TOPICS_FOR_TAGS) { // Add TopicAssignment records for both the LogEntry__c & the parent Log__c tagAssignmentSObjectType = Schema.TopicAssignment.SObjectType; - tagAssignments.add(new TopicAssignment(EntityId = logEntry.Id, TopicId = tagNameToId.get(tagName))); - tagAssignments.add(new TopicAssignment(EntityId = logEntry.Log__c, TopicId = tagNameToId.get(tagName))); + tagAssignments.add(new Schema.TopicAssignment(EntityId = logEntry.Id, TopicId = tagNameToId.get(tagName))); + tagAssignments.add(new Schema.TopicAssignment(EntityId = logEntry.Log__c, TopicId = tagNameToId.get(tagName))); } else { // Add a LogEntryTag__c record for only the LogEntry__c - this approach does not directly link to the Log__c record tagAssignmentSObjectType = Schema.LogEntryTag__c.SObjectType; @@ -431,7 +431,7 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler { .upsertRecords(new List(tagAssignments), Schema.LogEntryTag__c.UniqueId__c); LoggerEmailSender.sendErrorEmail(tagAssignmentSObjectType, upsertResults); } - when TopicAssignment topicAssignment { + when Schema.TopicAssignment topicAssignment { Database.DmlOptions topicAssignmentDmlOptions = createDmlOptions(); topicAssignmentDmlOptions.OptAllOrNone = false; List saveResults = LoggerDataStore.getDatabase() @@ -444,7 +444,9 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler { private Id determineLogOwnerId(LogEntryEvent__e logEntryEvent) { Id logOwnerId = logEntryEvent.LoggedById__c; - LoggerSettings__c loggingUserSettings = Logger.getUserSettings(new User(Id = logEntryEvent.LoggedById__c, ProfileId = logEntryEvent.ProfileId__c)); + LoggerSettings__c loggingUserSettings = Logger.getUserSettings( + new Schema.User(Id = logEntryEvent.LoggedById__c, ProfileId = logEntryEvent.ProfileId__c) + ); if (logEntryEvent.UserType__c == GUEST_USER_TYPE || String.isBlank(logOwnerId) || loggingUserSettings.IsAnonymousModeEnabled__c) { logOwnerId = System.UserInfo.getUserId(); } @@ -470,7 +472,7 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler { when LoggerTag__c loggerTag { tagRecords = LogManagementDataSelector.getInstance().getTagsByName(this.tagNames); } - when Topic topic { + when Schema.Topic topic { tagRecords = LogManagementDataSelector.getInstance().getTopicsByName(this.tagNames); } } @@ -637,7 +639,7 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler { return; } - Organization cachedOrganization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); + Schema.Organization cachedOrganization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); if (cachedOrganization == null) { return; } @@ -663,13 +665,13 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler { } } - Map userIdToUser = LoggerEngineDataSelector.getInstance().getUsers(userIds); + Map userIdToUser = LoggerEngineDataSelector.getInstance().getUsers(userIds); for (Log__c log : logs) { if (log.LoggedBy__c == null) { continue; } - User matchingUser = userIdToUser.get(log.LoggedBy__c); + Schema.User matchingUser = userIdToUser.get(log.LoggedBy__c); log.LoggedByUsername__c = matchingUser.Username; log.ProfileName__c = matchingUser.Profile.Name; log.UserLicenseDefinitionKey__c = matchingUser.Profile.UserLicense.LicenseDefinitionKey; diff --git a/nebula-logger/core/main/log-management/classes/LogHandler.cls b/nebula-logger/core/main/log-management/classes/LogHandler.cls index 8cfc05edb..e81e4d5bc 100644 --- a/nebula-logger/core/main/log-management/classes/LogHandler.cls +++ b/nebula-logger/core/main/log-management/classes/LogHandler.cls @@ -242,7 +242,7 @@ public without sharing class LogHandler extends LoggerSObjectHandler { } private static LoggerSettings__c getLoggingUserSettings(Log__c log) { - User loggingUser = new User(Id = log.LoggedBy__c, ProfileId = log.ProfileId__c); + Schema.User loggingUser = new Schema.User(Id = log.LoggedBy__c, ProfileId = log.ProfileId__c); return Logger.getUserSettings(loggingUser); } @@ -285,7 +285,7 @@ public without sharing class LogHandler extends LoggerSObjectHandler { private static Map queryQueues(List possibleQueueNames) { Map queuesByDeveloperName = new Map(); - for (Group queue : LogManagementDataSelector.getInstance().getQueuesByDeveloperName(possibleQueueNames)) { + for (Schema.Group queue : LogManagementDataSelector.getInstance().getQueuesByDeveloperName(possibleQueueNames)) { queuesByDeveloperName.put(queue.DeveloperName, queue.Id); } return queuesByDeveloperName; @@ -293,7 +293,7 @@ public without sharing class LogHandler extends LoggerSObjectHandler { private static Map queryUsers(List possibleUsernames) { Map usersByUsername = new Map(); - for (User user : LogManagementDataSelector.getInstance().getUsersByUsername(possibleUsernames)) { + for (Schema.User user : LogManagementDataSelector.getInstance().getUsersByUsername(possibleUsernames)) { usersByUsername.put(user.Username, user.Id); } return usersByUsername; diff --git a/nebula-logger/core/main/log-management/classes/LogManagementDataSelector.cls b/nebula-logger/core/main/log-management/classes/LogManagementDataSelector.cls index 2bbf17cc2..bb1e99504 100644 --- a/nebula-logger/core/main/log-management/classes/LogManagementDataSelector.cls +++ b/nebula-logger/core/main/log-management/classes/LogManagementDataSelector.cls @@ -76,7 +76,11 @@ public without sharing virtual class LogManagementDataSelector { return (List) LoggerCache.getOrganizationCache().get(cacheKey); } - List apexEmailNotifications = [SELECT Email, UserId FROM ApexEmailNotification WHERE Email != NULL OR User.IsActive = TRUE]; + List apexEmailNotifications = [ + SELECT Email, UserId + FROM ApexEmailNotification + WHERE Email != NULL OR User.IsActive = TRUE + ]; LoggerCache.getOrganizationCache().put(cacheKey, apexEmailNotifications); return apexEmailNotifications; } @@ -86,7 +90,7 @@ public without sharing virtual class LogManagementDataSelector { * that has API details populated from calling https://api.status.salesforce.com * @return The cached `Log__c` record, or `null` if no match is found */ - public Log__c getCachedRecentLogWithApiReleaseDetails() { + public virtual Log__c getCachedRecentLogWithApiReleaseDetails() { String cacheKey = 'RecentLogWithApiReleaseDetails'; if (LoggerCache.getOrganizationCache().contains(cacheKey)) { return (Log__c) LoggerCache.getOrganizationCache().get(cacheKey); @@ -155,7 +159,7 @@ public without sharing virtual class LogManagementDataSelector { Description, DurableId, Label, - LastModifiedBy, // This is a text field of the person's name - it's NOT a lookup to User :'( + LastModifiedBy, // This is a text field of the person's name - it's NOT a lookup to Schema.User :'( LastModifiedDate, ManageableState, ProcessType, @@ -255,29 +259,29 @@ public without sharing virtual class LogManagementDataSelector { } /** - * @description Returns a `List` of records with the specified profile IDs - * @param profileIds The list of `ID` of the `Profile` records to query - * @return The list of matching `Profile` records + * @description Returns a `List` of records with the specified profile IDs + * @param profileIds The list of `ID` of the `Schema.Profile` records to query + * @return The list of matching `Schema.Profile` records */ - public virtual List getProfilesById(List profileIds) { + public virtual List getProfilesById(List profileIds) { return [SELECT Id, Name FROM Profile WHERE Id IN :profileIds]; } /** - * @description Returns a `List` of records where the profile's names partially matches the specified search term - * @param searchTerm The `String` search term to use for searching `Profile` records - * @return The list of matching `Profile` records + * @description Returns a `List` of records where the profile's names partially matches the specified search term + * @param searchTerm The `String` search term to use for searching `Schema.Profile` records + * @return The list of matching `Schema.Profile` records */ - public virtual List getProfilesByNameSearch(String searchTerm) { + public virtual List getProfilesByNameSearch(String searchTerm) { return [SELECT Id, Name, UserLicense.Name FROM Profile WHERE Name LIKE :searchTerm]; } /** - * @description Returns a `List` of records with the specified developer names and type == 'Queue' + * @description Returns a `List` of records with the specified developer names and type == 'Queue' * @param queueDeveloperNames The list of `String` queue developer names to query - * @return The list of matching `Group` records + * @return The list of matching `Schema.Group` records */ - public virtual List getQueuesByDeveloperName(List queueDeveloperNames) { + public virtual List getQueuesByDeveloperName(List queueDeveloperNames) { return [SELECT Id, DeveloperName FROM Group WHERE Type = 'Queue' AND DeveloperName IN :queueDeveloperNames]; } @@ -290,7 +294,7 @@ public without sharing virtual class LogManagementDataSelector { * @return The list of matching `LogEntry__c` records */ @SuppressWarnings('PMD.ExcessiveParameterList') - public List getRecordLogEntries(Id recordId, String fieldsClause, String orderByClause, Integer rowLimit) { + public virtual List getRecordLogEntries(Id recordId, String fieldsClause, String orderByClause, Integer rowLimit) { List queryTextReplacements = new List{ fieldsClause, Schema.LogEntry__c.SObjectType.getDescribe().getName(), @@ -314,42 +318,42 @@ public without sharing virtual class LogManagementDataSelector { } /** - * @description Returns a list of `Topic` records with one of the specified topic names + * @description Returns a list of `Schema.Topic` records with one of the specified topic names * @param topicNames The set of `String` topic names to query - * @return The list of matching `Topic` records + * @return The list of matching `Schema.Topic` records */ - public virtual List getTopicsByName(Set topicNames) { + public virtual List getTopicsByName(Set topicNames) { return [SELECT Id, Name FROM Topic WHERE Name IN :topicNames]; } /** - * @description Returns a `List` of records with the specified user IDs - * @param userIds The list of `ID` of the `User` records to query - * @return The list of matching `User` records + * @description Returns a `List` of records with the specified user IDs + * @param userIds The list of `ID` of the `Schema.User` records to query + * @return The list of matching `Schema.User` records */ - public virtual List getUsersById(List userIds) { + public virtual List getUsersById(List userIds) { return [SELECT Id, Username FROM User WHERE Id IN :userIds]; } /** - * @description Returns a `List` of records where the User's names or username partially matches the specified search term - * @param searchTerm The `String` search term to use for searching `User` records - * @return The list of matching `User` records + * @description Returns a `List` of records where the User's names or username partially matches the specified search term + * @param searchTerm The `String` search term to use for searching `Schema.User` records + * @return The list of matching `Schema.User` records */ - public virtual List getUsersByNameSearch(String searchTerm) { + public virtual List getUsersByNameSearch(String searchTerm) { if (String.isBlank(searchTerm)) { - return new List(); + return new List(); } return [SELECT Id, Name, Username, SmallPhotoUrl FROM User WHERE Name LIKE :searchTerm OR Username LIKE :searchTerm ORDER BY Username LIMIT 20]; } /** - * @description Returns a `List` of records with the specified usernames (`Schema.User.Username`) + * @description Returns a `List` of records with the specified usernames (`Schema.User.Username`) * @param usernames The list of `String` user usernames to query - * @return Tje list of matching `User` records + * @return Tje list of matching `Schema.User` records */ - public virtual List getUsersByUsername(List usernames) { + public virtual List getUsersByUsername(List usernames) { return [SELECT Id, Username FROM User WHERE Username IN :userNames]; } diff --git a/nebula-logger/core/main/log-management/classes/LoggerEmailSender.cls b/nebula-logger/core/main/log-management/classes/LoggerEmailSender.cls index a598b3742..29cab5c51 100644 --- a/nebula-logger/core/main/log-management/classes/LoggerEmailSender.cls +++ b/nebula-logger/core/main/log-management/classes/LoggerEmailSender.cls @@ -177,7 +177,7 @@ public without sharing class LoggerEmailSender { } private static String buildHtmlBody(Schema.SObjectType sobjectType, List errorMessages) { - final String emailBodyTemplate = 'Logger failed to save {0} {1} records for {2} (User ID: {3})

Errors:
    {4}
'; + final String emailBodyTemplate = 'Logger failed to save {0} {1} records for {2} (Schema.User ID: {3})

Errors:
    {4}
'; final String formattedErrorMessages = '
  • ' + String.join(errorMessages, '
  • ') + '
  • '; List emailBodyInputs = new List{ errorMessages.size(), diff --git a/nebula-logger/core/main/log-management/classes/LoggerHomeHeaderController.cls b/nebula-logger/core/main/log-management/classes/LoggerHomeHeaderController.cls index a089c60d1..43d2b745c 100644 --- a/nebula-logger/core/main/log-management/classes/LoggerHomeHeaderController.cls +++ b/nebula-logger/core/main/log-management/classes/LoggerHomeHeaderController.cls @@ -14,7 +14,7 @@ public without sharing class LoggerHomeHeaderController { */ @AuraEnabled(cacheable=true) public static Environment getEnvironmentDetails() { - Organization organization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); + Schema.Organization organization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); Environment environment = new Environment(); environment.loggerNamespacePrefix = String.isNotBlank(Logger.getNamespacePrefix()) ? Logger.getNamespacePrefix() : '(none)'; diff --git a/nebula-logger/core/main/log-management/classes/LoggerSettingsController.cls b/nebula-logger/core/main/log-management/classes/LoggerSettingsController.cls index 1719dab22..c77903c47 100644 --- a/nebula-logger/core/main/log-management/classes/LoggerSettingsController.cls +++ b/nebula-logger/core/main/log-management/classes/LoggerSettingsController.cls @@ -125,17 +125,17 @@ public without sharing class LoggerSettingsController { // Setup Owner methods /** - * @description Returns the `Organization` record for the current environment - * @return The current environment's `Organization` record + * @description Returns the `Schema.Organization` record for the current environment + * @return The current environment's `Schema.Organization` record */ @AuraEnabled(cacheable=true) - public static Organization getOrganization() { + public static Schema.Organization getOrganization() { return LoggerEngineDataSelector.getInstance().getCachedOrganization(); } /** * @description searchForSetupOwner description - * @param setupOwnerType The object to search (`Profile` or `User`) + * @param setupOwnerType The object to search (`Schema.Profile` or `Schema.User`) * @param searchTerm The search term to use when searching records * @return The list of `SetupOwnerSearchResult`, based on any matching SObject records */ @@ -146,7 +146,7 @@ public without sharing class LoggerSettingsController { List searchResults = new List(); switch on setupOwnerType { when 'Profile' { - for (Profile matchingProfile : LogManagementDataSelector.getInstance().getProfilesByNameSearch(searchTerm)) { + for (Schema.Profile matchingProfile : LogManagementDataSelector.getInstance().getProfilesByNameSearch(searchTerm)) { SetupOwnerSearchResult result = new SetupOwnerSearchResult(); result.recordId = matchingProfile.Id; result.label = matchingProfile.Name; @@ -156,7 +156,7 @@ public without sharing class LoggerSettingsController { } } when 'User' { - for (User matchingUser : LogManagementDataSelector.getInstance().getUsersByNameSearch(searchTerm)) { + for (Schema.User matchingUser : LogManagementDataSelector.getInstance().getUsersByNameSearch(searchTerm)) { SetupOwnerSearchResult result = new SetupOwnerSearchResult(); result.recordId = matchingUser.Id; result.label = matchingUser.Username; @@ -324,10 +324,10 @@ public without sharing class LoggerSettingsController { private static Map querySetupOwnerNames(List setupOwnerIds) { Map setupOwnerIdToName = new Map(); - for (Profile profile : LogManagementDataSelector.getInstance().getProfilesById(setupOwnerIds)) { + for (Schema.Profile profile : LogManagementDataSelector.getInstance().getProfilesById(setupOwnerIds)) { setupOwnerIdToName.put(profile.Id, profile.Name); } - for (User user : LogManagementDataSelector.getInstance().getUsersById(setupOwnerIds)) { + for (Schema.User user : LogManagementDataSelector.getInstance().getUsersById(setupOwnerIds)) { setupOwnerIdToName.put(user.Id, user.Username); } return setupOwnerIdToName; @@ -401,7 +401,7 @@ public without sharing class LoggerSettingsController { } /** - * @description Inner class used for returning search results for `Profile` and `User` records + * @description Inner class used for returning search results for `Schema.Profile` and `Schema.User` records */ public class SetupOwnerSearchResult { @AuraEnabled diff --git a/nebula-logger/core/main/logger-engine/classes/LogEntryEventBuilder.cls b/nebula-logger/core/main/logger-engine/classes/LogEntryEventBuilder.cls index dbc165859..353f7cfa2 100644 --- a/nebula-logger/core/main/logger-engine/classes/LogEntryEventBuilder.cls +++ b/nebula-logger/core/main/logger-engine/classes/LogEntryEventBuilder.cls @@ -13,7 +13,7 @@ ) global with sharing class LogEntryEventBuilder { private static final Map CACHED_SOBJECT_NAME_TO_CLASSIFICATION = new Map(); - private static final User CURRENT_USER = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + private static final Schema.User CURRENT_USER = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); private static final String HTTP_HEADER_FORMAT = '{0}: {1}'; private static final String NEW_LINE_DELIMITER = '\n'; @@ -870,7 +870,7 @@ global with sharing class LogEntryEventBuilder { return; } - Organization cachedOrganization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); + Schema.Organization cachedOrganization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); if (cachedOrganization == null) { return; } @@ -888,7 +888,7 @@ global with sharing class LogEntryEventBuilder { return; } - User cachedUser = LoggerEngineDataSelector.getInstance().getCachedUser(); + Schema.User cachedUser = LoggerEngineDataSelector.getInstance().getCachedUser(); if (cachedUser == null) { return; } @@ -975,7 +975,7 @@ global with sharing class LogEntryEventBuilder { return ''; } - Organization cachedOrganization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); + Schema.Organization cachedOrganization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); String cachedOrganizationEnvironmentType; if (cachedOrganization == null) { cachedOrganizationEnvironmentType = ''; diff --git a/nebula-logger/core/main/logger-engine/classes/Logger.cls b/nebula-logger/core/main/logger-engine/classes/Logger.cls index 531804b2b..3f54df8a0 100644 --- a/nebula-logger/core/main/logger-engine/classes/Logger.cls +++ b/nebula-logger/core/main/logger-engine/classes/Logger.cls @@ -15,7 +15,7 @@ global with sharing class Logger { // There's no reliable way to get the version number dynamically in Apex @TestVisible - private static final String CURRENT_VERSION_NUMBER = 'v4.12.4'; + private static final String CURRENT_VERSION_NUMBER = 'v4.12.5'; private static final System.LoggingLevel FALLBACK_LOGGING_LEVEL = System.LoggingLevel.DEBUG; private static final Set IGNORED_APEX_CLASSES = initializeIgnoredApexClasses(); private static final List LOG_ENTRIES_BUFFER = new List(); @@ -45,8 +45,8 @@ global with sharing class Logger { // Serializing any SObject w/ an ID will include the API version // So, use System.UserInfo.getUserId() to create the current user's record without querying // Then parse the JSON to get the API version - // Expected JSON: {"attributes":{"type":"User","url":"/services/data/v53.0/sobjects/User/005J000000AugnYIAR"} - String userJson = JSON.serialize(new User(Id = System.UserInfo.getUserId())); + // Expected JSON: {"attributes":{"type":"Schema.User","url":"/services/data/v53.0/sobjects/Schema.User/005J000000AugnYIAR"} + String userJson = JSON.serialize(new Schema.User(Id = System.UserInfo.getUserId())); ORGANIZATION_API_VERSION = userJson.substringAfter('/data/').substringBefore('/sobjects/User'); } return ORGANIZATION_API_VERSION; @@ -98,7 +98,7 @@ global with sharing class Logger { // The rest of the codebase should use a method in Logger.cls System.debug(System.LoggingLevel.INFO, 'Nebula Logger - Version Number: ' + getVersionNumber()); System.debug(System.LoggingLevel.INFO, 'Nebula Logger - Transaction ID: ' + getTransactionId()); - System.debug(System.LoggingLevel.INFO, 'Nebula Logger - Organization API Version: ' + getOrganizationApiVersion()); + System.debug(System.LoggingLevel.INFO, 'Nebula Logger - Schema.Organization API Version: ' + getOrganizationApiVersion()); setScenario(getUserSettings().DefaultScenario__c); } @@ -318,7 +318,7 @@ global with sharing class Logger { public static LoggerSettings__c getUserSettings() { // Only load the current user's settings once - this allows the instance to be modified in memory (as well as upserted if any changes should be persisted) if (userSettings == null) { - User currentUser = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User currentUser = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); userSettings = getUserSettings(currentUser); } return userSettings; @@ -330,7 +330,7 @@ global with sharing class Logger { * @param loggingUser The user record - at a minimum, this record should have the user Id and Profile fields populated * @return LoggerSettings__c - The specified user's instance of the custom settings */ - public static LoggerSettings__c getUserSettings(User loggingUser) { + public static LoggerSettings__c getUserSettings(Schema.User loggingUser) { // Typically, using LoggerSettings__c.getInstance() would be easier // However, some settings fields are expected to have null values, which conflicts with how `getInstance()` behaves // So, instead use LoggerSettings__c.getValues(Id userOrProfileId) to load exactly what's been configured (including nulls) @@ -338,7 +338,7 @@ global with sharing class Logger { // TODO cache the generated instances of LoggerSettings__c in LoggerCache.getTransactionCache().put() // (key would be 'Settings' + user ID) LoggerSettings__c loggingUserSettings; - // First, check for User-level settings + // First, check for Schema.User-level settings if (loggingUser.Id != null && LoggerSettings__c.getValues(loggingUser.Id) != null) { LoggerSettings__c userSettings = LoggerSettings__c.getValues(loggingUser.Id); if (hasValidStartAndEndTimes(userSettings)) { @@ -3274,7 +3274,7 @@ global with sharing class Logger { return null; } - Organization organization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); + Schema.Organization organization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); String statusApiEndpoint = 'https://api.status.salesforce.com/v1/instances/' + organization.InstanceName + '/status'; System.HttpRequest request = new System.HttpRequest(); diff --git a/nebula-logger/core/main/logger-engine/classes/LoggerEngineDataSelector.cls b/nebula-logger/core/main/logger-engine/classes/LoggerEngineDataSelector.cls index ded472551..58602f6e1 100644 --- a/nebula-logger/core/main/logger-engine/classes/LoggerEngineDataSelector.cls +++ b/nebula-logger/core/main/logger-engine/classes/LoggerEngineDataSelector.cls @@ -28,10 +28,10 @@ public without sharing virtual class LoggerEngineDataSelector { } /** - * @description Returns a `Map` for the specified user IDs & their matching active sessions, + * @description Returns a `Map` for the specified user IDs & their matching active sessions, * or `null` if there is not a current session * @param userIds userIds description - * @return The instance of `Map` containing any matching `AuthSession` records + * @return The instance of `Map` containing any matching `Schema.AuthSession` records */ public virtual Map getAuthSessionProxies(List userIds) { Map userIdToAuthSessionProxy = new Map(); @@ -40,7 +40,7 @@ public without sharing virtual class LoggerEngineDataSelector { return userIdToAuthSessionProxy; } - for (AuthSession authSession : [ + for (Schema.AuthSession authSession : [ SELECT Id, LoginType, @@ -64,9 +64,9 @@ public without sharing virtual class LoggerEngineDataSelector { } /** - * @description Returns a cached copy of `AuthSession` for the current user's current session, + * @description Returns a cached copy of `LoggerSObjectProxy.AuthSession` for the current user's current session, * or `null` if there is not a current session - * @return The cached `AuthSession` record + * @return The cached `LoggerSObjectProxy.AuthSession` record */ public virtual LoggerSObjectProxy.AuthSession getCachedAuthSessionProxy() { Id userId = System.UserInfo.getUserId(); @@ -104,10 +104,10 @@ public without sharing virtual class LoggerEngineDataSelector { } /** - * @description Returns a cached copy of the current user's `Network` site, or `null` if the current user is not associated - * with a `Network` site - * @param networkId The record ID of the `Network` to query - * @return The cached `Network` record + * @description Returns a cached copy of the current user's `Schema.Network` site, or `null` if the current user is not associated + * with a `Schema.Network` site + * @param networkId The record ID of the `Schema.Network` to query + * @return The cached `Schema.Network` record */ public virtual LoggerSObjectProxy.Network getCachedNetworkProxy(Id networkId) { if (networkId == null || IS_EXPERIENCE_CLOUD_ENABLED == false) { @@ -128,16 +128,16 @@ public without sharing virtual class LoggerEngineDataSelector { } /** - * @description Returns a cached copy of the `Organization` record in the org, including some fields that cannot be accessed via `UserInfo` - * @return The cached `Organization` record + * @description Returns a cached copy of the `Schema.Organization` record in the org, including some fields that cannot be accessed via `UserInfo` + * @return The cached `Schema.Organization` record */ - public virtual Organization getCachedOrganization() { + public virtual Schema.Organization getCachedOrganization() { String cacheKey = 'Organization'; if (LoggerCache.getOrganizationCache().contains(cacheKey)) { - return (Organization) LoggerCache.getOrganizationCache().get(cacheKey); + return (Schema.Organization) LoggerCache.getOrganizationCache().get(cacheKey); } - Organization organization; + Schema.Organization organization; if (LoggerParameter.QUERY_ORGANIZATION_DATA) { organization = [ SELECT @@ -187,16 +187,16 @@ public without sharing virtual class LoggerEngineDataSelector { /** * @description Returns a cached copy of the current user, including some profile fields that cannot be accessed via `UserInfo` - * @return The cached `User` record for the current user + * @return The cached `Schema.User` record for the current user */ - public virtual User getCachedUser() { + public virtual Schema.User getCachedUser() { Id userId = System.UserInfo.getUserId(); String cacheKey = 'User' + userId; if (LoggerCache.getSessionCache().contains(cacheKey)) { - return (User) LoggerCache.getSessionCache().get(cacheKey); + return (Schema.User) LoggerCache.getSessionCache().get(cacheKey); } - User user; + Schema.User user; if (LoggerParameter.QUERY_USER_DATA) { user = getUsers(new List{ userId }).get(userId); LoggerCache.getSessionCache().put(cacheKey, user); @@ -205,9 +205,9 @@ public without sharing virtual class LoggerEngineDataSelector { } /** - * @description Returns a list of matching `Network` records based on the provided list of network IDs - * @param networkIds The list of `Network` IDs to query - * @return The instance of `Map` containing any matching `Network` records + * @description Returns a list of matching `Schema.Network` records based on the provided list of network IDs + * @param networkIds The list of `Schema.Network` IDs to query + * @return The instance of `Map` containing any matching `Schema.Network` records */ public Map getNetworkProxies(List networkIds) { // TODO add caching in a future release @@ -216,7 +216,7 @@ public without sharing virtual class LoggerEngineDataSelector { } // Networks (aka experience sites aka community sites aka portal sites ò_ô) - // may not be enabled in the org (no Network object), so run everything dynamically + // may not be enabled in the org (no Schema.Network object), so run everything dynamically // return new Map(Database.query(String.escapeSingleQuotes(query))); Map networkIdToNetworkProxy = new Map(); String query = 'SELECT Id, Name, UrlPathPrefix FROM Network WHERE Id IN :networkIds'; @@ -228,16 +228,16 @@ public without sharing virtual class LoggerEngineDataSelector { } /** - * @description Returns a list of matching `User` records based on the provided list of user IDs - * @param userIds The list of `User` IDs to query - * @return The instance of `Map` containing any matching `User` records + * @description Returns a list of matching `Schema.User` records based on the provided list of user IDs + * @param userIds The list of `Schema.User` IDs to query + * @return The instance of `Map` containing any matching `Schema.User` records */ - public Map getUsers(List userIds) { + public Map getUsers(List userIds) { if (LoggerParameter.QUERY_USER_DATA == false) { - return new Map(); + return new Map(); } - return new Map( + return new Map( [ SELECT Id, Profile.Name, Profile.UserLicenseId, Profile.UserLicense.LicenseDefinitionKey, Profile.UserLicense.Name, Username, UserRole.Name FROM User diff --git a/nebula-logger/core/main/logger-engine/lwc/logger/logger.js b/nebula-logger/core/main/logger-engine/lwc/logger/logger.js index ce3a91d2b..0a0f20e0e 100644 --- a/nebula-logger/core/main/logger-engine/lwc/logger/logger.js +++ b/nebula-logger/core/main/logger-engine/lwc/logger/logger.js @@ -6,7 +6,7 @@ import { LightningElement, api } from 'lwc'; import { createLoggerService } from './loggerService'; -const CURRENT_VERSION_NUMBER = 'v4.12.4'; +const CURRENT_VERSION_NUMBER = 'v4.12.5'; export default class Logger extends LightningElement { #loggerService = createLoggerService(); diff --git a/nebula-logger/core/tests/configuration/classes/LoggerCache_Tests.cls b/nebula-logger/core/tests/configuration/classes/LoggerCache_Tests.cls index 86f75e9f5..cb58c1467 100644 --- a/nebula-logger/core/tests/configuration/classes/LoggerCache_Tests.cls +++ b/nebula-logger/core/tests/configuration/classes/LoggerCache_Tests.cls @@ -18,7 +18,7 @@ private class LoggerCache_Tests { @IsTest static void it_adds_new_key_to_transaction_cache() { String mockKey = 'SomeKey'; - User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User mockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); System.Assert.isFalse(LoggerCache.getTransactionCache().contains(mockKey)); LoggerCache.getTransactionCache().put(mockKey, mockValue); @@ -30,7 +30,7 @@ private class LoggerCache_Tests { @IsTest static void it_adds_new_key_with_null_value_to_transaction_cache() { String mockKey = 'SomeKey'; - User mockValue = null; + Schema.User mockValue = null; System.Assert.isFalse(LoggerCache.getTransactionCache().contains(mockKey)); LoggerCache.getTransactionCache().put(mockKey, mockValue); @@ -42,11 +42,11 @@ private class LoggerCache_Tests { @IsTest static void it_updates_value_for_existing_key_in_transaction_cache() { String mockKey = 'SomeKey'; - User oldMockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User oldMockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); LoggerCache.getTransactionCache().put(mockKey, oldMockValue); System.Assert.isTrue(LoggerCache.getTransactionCache().contains(mockKey)); System.Assert.areEqual(oldMockValue, LoggerCache.getTransactionCache().get(mockKey)); - Account newMockValue = new Account(Name = 'Some fake account'); + Schema.Account newMockValue = new Schema.Account(Name = 'Some fake account'); LoggerCache.getTransactionCache().put(mockKey, newMockValue); @@ -57,7 +57,7 @@ private class LoggerCache_Tests { @IsTest static void it_removes_value_for_existing_key_in_transaction_cache() { String mockKey = 'SomeKey'; - User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User mockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); System.Assert.isFalse(LoggerCache.getTransactionCache().contains(mockKey)); LoggerCache.getTransactionCache().put(mockKey, mockValue); System.Assert.isTrue(LoggerCache.getTransactionCache().contains(mockKey)); @@ -71,7 +71,7 @@ private class LoggerCache_Tests { @IsTest static void it_adds_new_key_to_organization_and_transaction_cache_when_platform_cache_is_available() { String mockKey = 'SomeKey'; - User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User mockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionDelegate mockOrganizationPartitionDelegate = new MockPlatformCachePartitionDelegate(true); System.Assert.isTrue(mockOrganizationPartitionDelegate.isAvailable()); LoggerCache.setMockOrganizationPartitionDelegate(mockOrganizationPartitionDelegate); @@ -95,7 +95,7 @@ private class LoggerCache_Tests { @IsTest static void it_adds_new_key_with_null_value_to_organization_and_transaction_cache_when_platform_cache_is_available() { String mockKey = 'SomeKey'; - User mockValue = null; + Schema.User mockValue = null; MockPlatformCachePartitionDelegate mockOrganizationPartitionDelegate = new MockPlatformCachePartitionDelegate(true); System.Assert.isTrue(mockOrganizationPartitionDelegate.isAvailable()); LoggerCache.setMockOrganizationPartitionDelegate(mockOrganizationPartitionDelegate); @@ -119,7 +119,7 @@ private class LoggerCache_Tests { @IsTest static void it_adds_new_key_to_only_transaction_cache_when_organization_platform_cache_is_not_available() { String mockKey = 'SomeKey'; - User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User mockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionDelegate mockOrganizationPartitionDelegate = new MockPlatformCachePartitionDelegate(false); System.Assert.isFalse(mockOrganizationPartitionDelegate.isAvailable()); LoggerCache.setMockOrganizationPartitionDelegate(mockOrganizationPartitionDelegate); @@ -143,7 +143,7 @@ private class LoggerCache_Tests { @IsTest static void it_updates_value_for_existing_key_in_organization_and_transaction_cache_when_platform_cache_is_available() { String mockKey = 'SomeKey'; - User oldMockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User oldMockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionDelegate mockOrganizationPartitionDelegate = new MockPlatformCachePartitionDelegate(true); System.Assert.isTrue(mockOrganizationPartitionDelegate.isAvailable()); LoggerCache.setMockOrganizationPartitionDelegate(mockOrganizationPartitionDelegate); @@ -153,7 +153,7 @@ private class LoggerCache_Tests { System.Assert.areEqual(oldMockValue, LoggerCache.getOrganizationCache().get(mockKey)); System.Assert.isTrue(LoggerCache.getTransactionCache().contains(mockKey)); System.Assert.areEqual(oldMockValue, LoggerCache.getTransactionCache().get(mockKey)); - Account newMockValue = new Account(Name = 'Some fake account'); + Schema.Account newMockValue = new Schema.Account(Name = 'Some fake account'); System.Assert.areEqual(1, mockOrganizationPartitionDelegate.putMethodCallCount); LoggerCache.getOrganizationCache().put(mockKey, newMockValue); @@ -170,8 +170,8 @@ private class LoggerCache_Tests { @IsTest static void it_returns_value_in_transaction_cache_when_organization_and_transaction_cache_both_contain_key() { String mockKey = 'SomeKey'; - User transactionCacheValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); - Account organizationCacheValue = new Account(Name = 'Some fake account'); + Schema.User transactionCacheValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.Account organizationCacheValue = new Schema.Account(Name = 'Some fake account'); MockPlatformCachePartitionDelegate mockOrganizationPartitionDelegate = new MockPlatformCachePartitionDelegate(true); System.Assert.isTrue(mockOrganizationPartitionDelegate.isAvailable()); LoggerCache.setMockOrganizationPartitionDelegate(mockOrganizationPartitionDelegate); @@ -188,7 +188,7 @@ private class LoggerCache_Tests { @IsTest static void it_removes_value_for_existing_key_in_organization_and_transaction_cache_when_platform_cache_is_available() { String mockKey = 'SomeKey'; - User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User mockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionDelegate mockOrganizationPartitionDelegate = new MockPlatformCachePartitionDelegate(true); System.Assert.isTrue(mockOrganizationPartitionDelegate.isAvailable()); LoggerCache.setMockOrganizationPartitionDelegate(mockOrganizationPartitionDelegate); @@ -214,7 +214,7 @@ private class LoggerCache_Tests { @IsTest static void it_adds_new_key_to_session_and_transaction_cache_when_platform_cache_is_available() { String mockKey = 'SomeKey'; - User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User mockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionDelegate mockSessionPartitionDelegate = new MockPlatformCachePartitionDelegate(true); System.Assert.isTrue(mockSessionPartitionDelegate.isAvailable()); LoggerCache.setMockSessionPartitionDelegate(mockSessionPartitionDelegate); @@ -238,7 +238,7 @@ private class LoggerCache_Tests { @IsTest static void it_adds_new_key_with_null_value_to_session_and_transaction_cache_when_platform_cache_is_available() { String mockKey = 'SomeKey'; - User mockValue = null; + Schema.User mockValue = null; MockPlatformCachePartitionDelegate mockSessionPartitionDelegate = new MockPlatformCachePartitionDelegate(true); System.Assert.isTrue(mockSessionPartitionDelegate.isAvailable()); LoggerCache.setMockSessionPartitionDelegate(mockSessionPartitionDelegate); @@ -262,7 +262,7 @@ private class LoggerCache_Tests { @IsTest static void it_adds_new_key_to_only_transaction_cache_when_session_platform_cache_is_not_available() { String mockKey = 'SomeKey'; - User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User mockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionDelegate mockSessionPartitionDelegate = new MockPlatformCachePartitionDelegate(false); System.Assert.isFalse(mockSessionPartitionDelegate.isAvailable()); LoggerCache.setMockSessionPartitionDelegate(mockSessionPartitionDelegate); @@ -286,7 +286,7 @@ private class LoggerCache_Tests { @IsTest static void it_updates_value_for_existing_key_in_session_and_transaction_cache_when_platform_cache_is_available() { String mockKey = 'SomeKey'; - User oldMockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User oldMockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionDelegate mockSessionPartitionDelegate = new MockPlatformCachePartitionDelegate(true); System.Assert.isTrue(mockSessionPartitionDelegate.isAvailable()); LoggerCache.setMockSessionPartitionDelegate(mockSessionPartitionDelegate); @@ -296,7 +296,7 @@ private class LoggerCache_Tests { System.Assert.areEqual(oldMockValue, LoggerCache.getSessionCache().get(mockKey)); System.Assert.isTrue(LoggerCache.getTransactionCache().contains(mockKey)); System.Assert.areEqual(oldMockValue, LoggerCache.getTransactionCache().get(mockKey)); - Account newMockValue = new Account(Name = 'Some fake account'); + Schema.Account newMockValue = new Schema.Account(Name = 'Some fake account'); System.Assert.areEqual(1, mockSessionPartitionDelegate.putMethodCallCount); LoggerCache.getSessionCache().put(mockKey, newMockValue); @@ -313,8 +313,8 @@ private class LoggerCache_Tests { @IsTest static void it_returns_value_in_transaction_cache_when_session_and_transaction_cache_both_contain_key() { String mockKey = 'SomeKey'; - User transactionCacheValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); - Account sessionCacheValue = new Account(Name = 'Some fake account'); + Schema.User transactionCacheValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.Account sessionCacheValue = new Schema.Account(Name = 'Some fake account'); MockPlatformCachePartitionDelegate mockSessionPartitionDelegate = new MockPlatformCachePartitionDelegate(true); System.Assert.isTrue(mockSessionPartitionDelegate.isAvailable()); LoggerCache.setMockSessionPartitionDelegate(mockSessionPartitionDelegate); @@ -331,7 +331,7 @@ private class LoggerCache_Tests { @IsTest static void it_removes_value_for_existing_key_in_session_and_transaction_cache_when_platform_cache_is_available() { String mockKey = 'SomeKey'; - User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User mockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionDelegate mockSessionPartitionDelegate = new MockPlatformCachePartitionDelegate(true); System.Assert.isTrue(mockSessionPartitionDelegate.isAvailable()); LoggerCache.setMockSessionPartitionDelegate(mockSessionPartitionDelegate); diff --git a/nebula-logger/core/tests/configuration/classes/LoggerParameter_Tests.cls b/nebula-logger/core/tests/configuration/classes/LoggerParameter_Tests.cls index 702a472ad..9887e43ca 100644 --- a/nebula-logger/core/tests/configuration/classes/LoggerParameter_Tests.cls +++ b/nebula-logger/core/tests/configuration/classes/LoggerParameter_Tests.cls @@ -6,8 +6,8 @@ @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions, PMD.NcssMethodCount') @IsTest(IsParallel=true) private class LoggerParameter_Tests { - private static User getUserRecord() { - return new User(Id = System.UserInfo.getUserId(), Username = System.UserInfo.getUsername()); + private static Schema.User getUserRecord() { + return new Schema.User(Id = System.UserInfo.getUserId(), Username = System.UserInfo.getUsername()); } @IsTest diff --git a/nebula-logger/core/tests/configuration/utilities/LoggerMockDataCreator.cls b/nebula-logger/core/tests/configuration/utilities/LoggerMockDataCreator.cls index 23d2b718b..38a8bc70c 100644 --- a/nebula-logger/core/tests/configuration/utilities/LoggerMockDataCreator.cls +++ b/nebula-logger/core/tests/configuration/utilities/LoggerMockDataCreator.cls @@ -18,7 +18,7 @@ public class LoggerMockDataCreator { private static final Map> SOBJECT_TYPE_TO_REQUIRED_FIELDS = new Map>(); private static final Map SOBJECT_TYPE_TO_MOCK_ID_COUNT = new Map(); - private static Organization cachedOrganization; + private static Schema.Organization cachedOrganization; private static Integer userMockUsernameCount = 0; /** @@ -290,20 +290,20 @@ public class LoggerMockDataCreator { } /** - * @description Creates a `User` record for testing purposes, using the current user's profile - * @return The generated `User` record - it is not automatically inserted into the database. + * @description Creates a `Schema.User` record for testing purposes, using the current user's profile + * @return The generated `Schema.User` record - it is not automatically inserted into the database. */ - public static User createUser() { + public static Schema.User createUser() { return createUser(System.UserInfo.getProfileId()); } /** - * @description Creates a `User` record for testing purposes, using the specified profile ID - * @param profileId The `Profile` ID to use for the created `User` - * @return The generated `User` record - it is not automatically inserted into the database. + * @description Creates a `Schema.User` record for testing purposes, using the specified profile ID + * @param profileId The `Schema.Profile` ID to use for the created `Schema.User` + * @return The generated `Schema.User` record - it is not automatically inserted into the database. */ - public static User createUser(Id profileId) { - return new User( + public static Schema.User createUser(Id profileId) { + return new Schema.User( Alias = 'user_xyz', Email = 'user_xyz@test.com.net.org', EmailEncodingKey = 'ISO-8859-1', @@ -317,11 +317,11 @@ public class LoggerMockDataCreator { } /** - * @description Queries for the `Organization` record for the current environment. - * @return The matching `Organization` record + * @description Queries for the `Schema.Organization` record for the current environment. + * @return The matching `Schema.Organization` record */ - public static Organization getOrganization() { - // TODO Switch to creating mock instance of Organization with sensible defaults that tests can then update as needed for different scenarios + public static Schema.Organization getOrganization() { + // TODO Switch to creating mock instance of Schema.Organization with sensible defaults that tests can then update as needed for different scenarios if (cachedOrganization == null) { cachedOrganization = [SELECT Id, Name, InstanceName, IsSandbox, NamespacePrefix, OrganizationType, TrialExpirationDate FROM Organization]; } @@ -333,7 +333,7 @@ public class LoggerMockDataCreator { * @return The environment type */ public static String getOrganizationEnvironmentType() { - Organization organization = getOrganization(); + Schema.Organization organization = getOrganization(); String orgEnvironmentType; if (organization.IsSandbox && organization.TrialExpirationDate != null) { @@ -348,18 +348,18 @@ public class LoggerMockDataCreator { /** * @description Returns the current user - * @return The matching `User` record + * @return The matching `Schema.User` record */ - public static User getUser() { + public static Schema.User getUser() { return getUser(System.UserInfo.getUserId()); } /** * @description Returns the specified user - * @param userId The ID of the `User` record to query - * @return The matching `User` record + * @param userId The ID of the `Schema.User` record to query + * @return The matching `Schema.User` record */ - public static User getUser(Id userId) { + public static Schema.User getUser(Id userId) { return [ SELECT Id, Profile.Name, Profile.UserLicenseId, Profile.UserLicense.LicenseDefinitionKey, Profile.UserLicense.Name, Username, UserRole.Name FROM User @@ -368,17 +368,17 @@ public class LoggerMockDataCreator { } /** - * @description Creates and inserts a `Group` record for testing queues, using the specified SObject Type - * @param queueDeveloperName The developer name to use for the new queue (stored in `Group.DeveloperName`) + * @description Creates and inserts a `Schema.Group` record for testing queues, using the specified SObject Type + * @param queueDeveloperName The developer name to use for the new queue (stored in `Schema.Group.DeveloperName`) * @param sobjectType The `SObjectType` that the queue should be able to own (stored in `QueueSObject.SObjectType`) - * @return The inserted `Group` record - it is automatically inserted into the database, as well as 1 child `QueueSObject` record. + * @return The inserted `Schema.Group` record - it is automatically inserted into the database, as well as 1 child `QueueSObject` record. */ - public static Group insertQueue(String queueDeveloperName, Schema.SObjectType sobjectType) { - Group queue = new Group(DeveloperName = queueDeveloperName, Name = queueDeveloperName, Type = 'Queue'); + public static Schema.Group insertQueue(String queueDeveloperName, Schema.SObjectType sobjectType) { + Schema.Group queue = new Schema.Group(DeveloperName = queueDeveloperName, Name = queueDeveloperName, Type = 'Queue'); insert queue; // To avoid a MIXED_DML_OPERATION exception, use System.runs() for inserting the QueueSObject record - System.runAs(new User(Id = System.UserInfo.getUserId())) { + System.runAs(new Schema.User(Id = System.UserInfo.getUserId())) { QueueSObject queueSObject = new QueueSObject(QueueId = queue.Id, SObjectType = sobjectType.getDescribe().getName()); insert queueSObject; } diff --git a/nebula-logger/core/tests/log-management/classes/LogBatchPurgeController_Tests.cls b/nebula-logger/core/tests/log-management/classes/LogBatchPurgeController_Tests.cls index 31f5dc198..63f808e2c 100644 --- a/nebula-logger/core/tests/log-management/classes/LogBatchPurgeController_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogBatchPurgeController_Tests.cls @@ -8,7 +8,7 @@ private class LogBatchPurgeController_Tests { private static final String CUSTOM_PURGE_ACTION = 'Custom'; private static final String DEFAULT_PURGE_ACTION = 'Delete'; private static final String CAN_EXECUTE_LOG_BATCH_PURGER_PERMISSION = 'CanExecuteLogBatchPurger'; - private static final Profile STANDARD_USER_PROFILE = [SELECT Id FROM Profile WHERE Name IN ('Standard User', 'Usuario estándar')]; + private static final Schema.Profile STANDARD_USER_PROFILE = [SELECT Id FROM Profile WHERE Name IN ('Standard User', 'Usuario estándar')]; @IsTest static void it_should_return_logPurgeAction_options() { @@ -315,7 +315,7 @@ private class LogBatchPurgeController_Tests { @IsTest static void it_should_permit_user_to_execute_purge_batch_when_custom_permission_is_assigned() { - User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); + Schema.User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); insert standardUser; PermissionSet permissionSet = new PermissionSet(Name = 'CanExecuteLogBatchPurger', Label = 'Custom Permisison Enabled'); insert permissionSet; @@ -358,7 +358,7 @@ private class LogBatchPurgeController_Tests { @IsTest static void it_should_not_permit_user_to_execute_purge_batch_when_custom_permission_is_not_assigned() { - User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); + Schema.User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); insert standardUser; PermissionSet permissionSet = new PermissionSet(Name = 'CanExecuteLogBatchPurger', Label = 'Custom Permisison Enabled'); insert permissionSet; diff --git a/nebula-logger/core/tests/log-management/classes/LogEntryEventHandler_Tests.cls b/nebula-logger/core/tests/log-management/classes/LogEntryEventHandler_Tests.cls index 6c1a7eb57..149f4dd93 100644 --- a/nebula-logger/core/tests/log-management/classes/LogEntryEventHandler_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogEntryEventHandler_Tests.cls @@ -490,12 +490,12 @@ private class LogEntryEventHandler_Tests { LoggerTestConfigurator.getSObjectHandlerConfiguration(Schema.Log__c.SObjectType).IsEnabled__c = false; LoggerTestConfigurator.getSObjectHandlerConfiguration(Schema.LogEntry__c.SObjectType).IsEnabled__c = false; String automatedProcessUsername = 'autoproc@' + System.UserInfo.getOrganizationId(); - User automatedProcessUser = [ + Schema.User automatedProcessUser = [ SELECT Id, TimeZoneSidKey FROM User WHERE Username = :automatedProcessUsername AND Profile.Name = NULL ]; - User currentUser = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User currentUser = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); LoggerSettings__c currentUserSettings = Logger.getUserSettings(currentUser); currentUserSettings.IsAnonymousModeEnabled__c = false; insert currentUserSettings; @@ -517,12 +517,12 @@ private class LogEntryEventHandler_Tests { LoggerTestConfigurator.getSObjectHandlerConfiguration(Schema.Log__c.SObjectType).IsEnabled__c = false; LoggerTestConfigurator.getSObjectHandlerConfiguration(Schema.LogEntry__c.SObjectType).IsEnabled__c = false; String automatedProcessUsername = 'autoproc@' + System.UserInfo.getOrganizationId(); - User automatedProcessUser = [ + Schema.User automatedProcessUser = [ SELECT Id, TimeZoneSidKey FROM User WHERE Username = :automatedProcessUsername AND Profile.Name = NULL ]; - User currentUser = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User currentUser = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); LoggerSettings__c currentUserSettings = Logger.getUserSettings(currentUser); currentUserSettings.IsAnonymousModeEnabled__c = true; insert currentUserSettings; @@ -544,7 +544,7 @@ private class LogEntryEventHandler_Tests { LoggerTestConfigurator.getSObjectHandlerConfiguration(Schema.LoggerScenario__c.SObjectType).IsEnabled__c = false; LoggerTestConfigurator.getSObjectHandlerConfiguration(Schema.Log__c.SObjectType).IsEnabled__c = false; LoggerTestConfigurator.getSObjectHandlerConfiguration(Schema.LogEntry__c.SObjectType).IsEnabled__c = false; - User loggerScenarioOwner = LoggerMockDataCreator.createUser(); + Schema.User loggerScenarioOwner = LoggerMockDataCreator.createUser(); insert loggerScenarioOwner; LoggerScenario__c loggerScenario = new LoggerScenario__c(Name = 'Some Scenario', OwnerId = loggerScenarioOwner.Id, UniqueId__c = 'Some Scenario'); insert loggerScenario; @@ -574,7 +574,7 @@ private class LogEntryEventHandler_Tests { LoggerTestConfigurator.getSObjectHandlerConfiguration(Schema.LogEntry__c.SObjectType).IsEnabled__c = false; LogEntryEvent__e logEntryEvent = createLogEntryEvent(); // The createLogEntryEvent() method sets all fields on LogEntryEvent__e, so clear the relevant fields to ensure - // that the values are only set based on the queried AuthSession record + // that the values are only set based on the queried Schema.AuthSession record logEntryEvent.LoginApplication__c = null; logEntryEvent.LoginBrowser__c = null; logEntryEvent.LoginHistoryId__c = null; @@ -620,7 +620,7 @@ private class LogEntryEventHandler_Tests { LoggerMockDataStore.getEventBus().publishRecord(logEntryEvent); LoggerMockDataStore.getEventBus().deliver(new LogEntryEventHandler()); - Organization expectedOrganization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); + Schema.Organization expectedOrganization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); Log__c log = getLog(); System.Assert.areEqual(String.valueOf(expectedOrganization.Id), log.OrganizationId__c); System.Assert.areEqual(expectedOrganization.InstanceName, log.OrganizationInstanceName__c); @@ -643,7 +643,7 @@ private class LogEntryEventHandler_Tests { LoggerMockDataStore.getEventBus().deliver(new LogEntryEventHandler()); List userIds = new List{ logEntryEvent.LoggedById__c }; - User expectedUser = LoggerEngineDataSelector.getInstance().getUsers(userIds).get(logEntryEvent.LoggedById__c); + Schema.User expectedUser = LoggerEngineDataSelector.getInstance().getUsers(userIds).get(logEntryEvent.LoggedById__c); Log__c log = getLog(); System.Assert.areEqual(expectedUser.Username, log.LoggedByUsername__c); System.Assert.areEqual(expectedUser.Profile.Name, log.ProfileName__c); @@ -687,8 +687,8 @@ private class LogEntryEventHandler_Tests { // validateLogEntryFields(logEntryEvent, logEntry); // Set tagsSet = new Set(tags); - // List topicAssignments = [SELECT Id, EntityId, TopicId, Topic.Name FROM TopicAssignment WHERE EntityId = :logEntry.Id]; - // for (TopicAssignment topicAssignment : topicAssignments) { + // List topicAssignments = [SELECT Id, EntityId, TopicId, Topic.Name FROM TopicAssignment WHERE EntityId = :logEntry.Id]; + // for (Schema.TopicAssignment topicAssignment : topicAssignments) { // System.Assert.isTrue(tagsSet.contains(topicAssignment.Topic.Name)); // } // } @@ -1379,7 +1379,7 @@ private class LogEntryEventHandler_Tests { } private static void validateLogFields(LogEntryEvent__e logEntryEvent, Log__c log) { - Organization org = [SELECT Id, Name, InstanceName, IsSandbox, NamespacePrefix, OrganizationType, TrialExpirationDate FROM Organization]; + Schema.Organization org = [SELECT Id, Name, InstanceName, IsSandbox, NamespacePrefix, OrganizationType, TrialExpirationDate FROM Organization]; String orgEnvironmentType; if (org.IsSandbox && org.TrialExpirationDate != null) { orgEnvironmentType = 'Scratch Org'; diff --git a/nebula-logger/core/tests/log-management/classes/LogEntryHandler_Tests.cls b/nebula-logger/core/tests/log-management/classes/LogEntryHandler_Tests.cls index c2591415a..f7fe91867 100644 --- a/nebula-logger/core/tests/log-management/classes/LogEntryHandler_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogEntryHandler_Tests.cls @@ -55,7 +55,7 @@ private class LogEntryHandler_Tests { @IsTest static void it_should_populate_related_record_fields_on_log_entry_with_related_user_record_id() { Log__c log = [SELECT Id FROM Log__c LIMIT 1]; - User currentUser = [SELECT Id, Username FROM User WHERE Id = :System.UserInfo.getUserId()]; + Schema.User currentUser = [SELECT Id, Username FROM User WHERE Id = :System.UserInfo.getUserId()]; LogEntry__c logEntry = new LogEntry__c(Log__c = log.Id, RecordId__c = currentUser.Id); LoggerDataStore.getDatabase().insertRecord(logEntry); @@ -73,7 +73,7 @@ private class LogEntryHandler_Tests { @IsTest static void it_should_populate_related_record_fields_on_log_entry_with_related_profile_record_id() { Log__c log = [SELECT Id FROM Log__c LIMIT 1]; - Profile currentProfile = [SELECT Id, Name FROM Profile WHERE Id = :System.UserInfo.getProfileId()]; + Schema.Profile currentProfile = [SELECT Id, Name FROM Profile WHERE Id = :System.UserInfo.getProfileId()]; LogEntry__c logEntry = new LogEntry__c(Log__c = log.Id, RecordId__c = currentProfile.Id); LoggerDataStore.getDatabase().insertRecord(logEntry); @@ -109,7 +109,7 @@ private class LogEntryHandler_Tests { @IsTest static void it_should_not_populate_related_record_fields_on_log_entry_when_disabled_via_logger_parameter() { Log__c log = [SELECT Id FROM Log__c LIMIT 1]; - User currentUser = [SELECT Id, Username FROM User WHERE Id = :System.UserInfo.getUserId()]; + Schema.User currentUser = [SELECT Id, Username FROM User WHERE Id = :System.UserInfo.getUserId()]; LogEntry__c logEntry = new LogEntry__c(Log__c = log.Id, RecordId__c = currentUser.Id); LoggerParameter.setMock(new LoggerParameter__mdt(DeveloperName = 'QueryRelatedRecordData', Value__c = String.valueOf(false))); diff --git a/nebula-logger/core/tests/log-management/classes/LogHandler_Tests.cls b/nebula-logger/core/tests/log-management/classes/LogHandler_Tests.cls index eaa6a6340..cf33beba6 100644 --- a/nebula-logger/core/tests/log-management/classes/LogHandler_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogHandler_Tests.cls @@ -171,8 +171,8 @@ private class LogHandler_Tests { @IsTest static void it_should_set_owner_when_default_configured_with_user_id() { setupConfigurations(); - User currentUser = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); - User expectedLogOwnerUser = LoggerMockDataCreator.createUser(); + Schema.User currentUser = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User expectedLogOwnerUser = LoggerMockDataCreator.createUser(); insert expectedLogOwnerUser; LoggerSettings__c currentUserSettings = Logger.getUserSettings(currentUser); currentUserSettings.DefaultLogOwner__c = expectedLogOwnerUser.Id; @@ -193,8 +193,8 @@ private class LogHandler_Tests { @IsTest static void it_should_set_owner_when_default_configured_with_username() { setupConfigurations(); - User currentUser = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); - User expectedLogOwnerUser = LoggerMockDataCreator.createUser(); + Schema.User currentUser = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User expectedLogOwnerUser = LoggerMockDataCreator.createUser(); insert expectedLogOwnerUser; LoggerSettings__c currentUserSettings = Logger.getUserSettings(currentUser); currentUserSettings.DefaultLogOwner__c = expectedLogOwnerUser.Username; @@ -215,8 +215,8 @@ private class LogHandler_Tests { @IsTest static void it_should_set_owner_when_default_configured_with_queue_id() { setupConfigurations(); - User currentUser = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); - Group expectedLogOwnerQueue = LoggerMockDataCreator.insertQueue('Some_Log_Queue', Schema.Log__c.SObjectType); + Schema.User currentUser = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.Group expectedLogOwnerQueue = LoggerMockDataCreator.insertQueue('Some_Log_Queue', Schema.Log__c.SObjectType); LoggerSettings__c currentUserSettings = Logger.getUserSettings(currentUser); currentUserSettings.DefaultLogOwner__c = expectedLogOwnerQueue.Id; insert currentUserSettings; @@ -236,8 +236,8 @@ private class LogHandler_Tests { @IsTest static void it_should_set_owner_when_default_configured_with_queue_developer_name() { setupConfigurations(); - User currentUser = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); - Group expectedLogOwnerQueue = LoggerMockDataCreator.insertQueue('Some_Log_Queue', Schema.Log__c.SObjectType); + Schema.User currentUser = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.Group expectedLogOwnerQueue = LoggerMockDataCreator.insertQueue('Some_Log_Queue', Schema.Log__c.SObjectType); LoggerSettings__c currentUserSettings = Logger.getUserSettings(currentUser); currentUserSettings.DefaultLogOwner__c = expectedLogOwnerQueue.DeveloperName; insert currentUserSettings; @@ -257,7 +257,7 @@ private class LogHandler_Tests { @IsTest static void it_should_use_current_user_as_owner_when_no_default_configured() { setupConfigurations(); - User currentUser = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User currentUser = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); LoggerSettings__c currentUserSettings = Logger.getUserSettings(currentUser); currentUserSettings.DefaultLogOwner__c = null; insert currentUserSettings; diff --git a/nebula-logger/core/tests/log-management/classes/LogManagementDataSelector_Tests.cls b/nebula-logger/core/tests/log-management/classes/LogManagementDataSelector_Tests.cls index 589e285c5..d5fdaa85b 100644 --- a/nebula-logger/core/tests/log-management/classes/LogManagementDataSelector_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogManagementDataSelector_Tests.cls @@ -10,7 +10,7 @@ private class LogManagementDataSelector_Tests { static void it_dynamically_queries_all_records_for_specified_sobject_type_and_fields() { Schema.SObjectType targetSObjectType = Schema.Organization.SObjectType; Set targetFieldNames = new Set{ Schema.Organization.Id.getDescribe().getName(), Schema.Organization.Name.getDescribe().getName() }; - List expectedResults = Database.query('SELECT ' + String.join(targetFieldNames, ', ') + ' FROM ' + targetSObjectType); + List expectedResults = Database.query('SELECT ' + String.join(targetFieldNames, ', ') + ' FROM ' + targetSObjectType); List returnedResults = LogManagementDataSelector.getInstance().getAll(targetSObjectType, targetFieldNames); @@ -22,8 +22,10 @@ private class LogManagementDataSelector_Tests { static void it_dynamically_queries_records_for_specified_sobject_type_and_fields_and_ids() { Schema.SObjectType targetSObjectType = Schema.User.SObjectType; Set targetFieldNames = new Set{ Schema.User.Id.getDescribe().getName(), Schema.User.Name.getDescribe().getName() }; - List targetIds = new List(new Map([SELECT Id FROM User LIMIT 3]).keySet()); - List expectedResults = Database.query('SELECT ' + String.join(targetFieldNames, ', ') + ' FROM ' + targetSObjectType + ' WHERE Id IN :targetIds'); + List targetIds = new List(new Map([SELECT Id FROM User LIMIT 3]).keySet()); + List expectedResults = Database.query( + 'SELECT ' + String.join(targetFieldNames, ', ') + ' FROM ' + targetSObjectType + ' WHERE Id IN :targetIds' + ); List returnedResults = LogManagementDataSelector.getInstance().getById(targetSObjectType, targetFieldNames, targetIds); @@ -163,7 +165,7 @@ private class LogManagementDataSelector_Tests { LoggerSObjectHandler.shouldExecute(false); Log__c deleteableRecord = (Log__c) LoggerMockDataCreator.createDataBuilder(Schema.Log__c.SObjectType).populateRequiredFields().getRecord(); insert deleteableRecord; - User undeleteableRecord = new User(Id = System.UserInfo.getUserId()); + Schema.User undeleteableRecord = new Schema.User(Id = System.UserInfo.getUserId()); List recordIds = new List{ deleteableRecord.Id, undeleteableRecord.Id }; List returnedResults = LogManagementDataSelector.getInstance().getDeleteableUserRecordAccess(recordIds); @@ -286,10 +288,10 @@ private class LogManagementDataSelector_Tests { @IsTest static void it_returns_profiles_for_specified_profile_ids() { - List expectedResults = [SELECT Id, Name FROM Profile LIMIT 10]; - List targetProfileIds = new List(new Map(expectedResults).keySet()); + List expectedResults = [SELECT Id, Name FROM Profile LIMIT 10]; + List targetProfileIds = new List(new Map(expectedResults).keySet()); - List returnedResults = LogManagementDataSelector.getInstance().getProfilesById(targetProfileIds); + List returnedResults = LogManagementDataSelector.getInstance().getProfilesById(targetProfileIds); expectedResults.sort(); returnedResults.sort(); @@ -299,9 +301,9 @@ private class LogManagementDataSelector_Tests { @IsTest static void it_returns_profiles_for_specified_search_term() { String searchTerm = 'Admin'; - List expectedResults = [SELECT Id, Name, UserLicense.Name FROM Profile WHERE Name LIKE :searchTerm]; + List expectedResults = [SELECT Id, Name, UserLicense.Name FROM Profile WHERE Name LIKE :searchTerm]; - List returnedResults = LogManagementDataSelector.getInstance().getProfilesByNameSearch(searchTerm); + List returnedResults = LogManagementDataSelector.getInstance().getProfilesByNameSearch(searchTerm); expectedResults.sort(); returnedResults.sort(); @@ -310,19 +312,19 @@ private class LogManagementDataSelector_Tests { @IsTest static void it_returns_queues_for_specified_developer_names() { - List queuesToInsert = new List(); - Group nonMatchingQueue = new Group(DeveloperName = 'non_matching_queue', Name = 'Non-Matching Queue', Type = 'Queue'); + List queuesToInsert = new List(); + Schema.Group nonMatchingQueue = new Schema.Group(DeveloperName = 'non_matching_queue', Name = 'Non-Matching Queue', Type = 'Queue'); queuesToInsert.add(nonMatchingQueue); List targetQueueNames = new List(); for (Integer i = 0; i < 3; i++) { - Group matchingQueue = new Group(DeveloperName = 'some_queue' + i, Name = 'Some Queue' + i, Type = 'Queue'); + Schema.Group matchingQueue = new Schema.Group(DeveloperName = 'some_queue' + i, Name = 'Some Queue' + i, Type = 'Queue'); targetQueueNames.add(matchingQueue.DeveloperName); queuesToInsert.add(matchingQueue); } insert queuesToInsert; - List expectedResults = [SELECT Id, DeveloperName FROM Group WHERE Type = 'Queue' AND DeveloperName IN :targetQueueNames]; + List expectedResults = [SELECT Id, DeveloperName FROM Group WHERE Type = 'Queue' AND DeveloperName IN :targetQueueNames]; - List returnedResults = LogManagementDataSelector.getInstance().getQueuesByDeveloperName(targetQueueNames); + List returnedResults = LogManagementDataSelector.getInstance().getQueuesByDeveloperName(targetQueueNames); System.Assert.areEqual(expectedResults, returnedResults); } @@ -374,27 +376,27 @@ private class LogManagementDataSelector_Tests { @IsTest static void it_returns_topics_for_specified_names() { - List topics = new List(); - Topic matchingTopic = new Topic(Name = 'some fake topic name'); + List topics = new List(); + Schema.Topic matchingTopic = new Schema.Topic(Name = 'some fake topic name'); topics.add(matchingTopic); - Topic nonMatchingTopic = new Topic(Name = 'another fake topic name'); + Schema.Topic nonMatchingTopic = new Schema.Topic(Name = 'another fake topic name'); topics.add(nonMatchingTopic); insert topics; Set targetTopicNames = new Set{ matchingTopic.Name }; - List expectedResults = [SELECT Id, Name FROM Topic WHERE Name IN :targetTopicNames]; + List expectedResults = [SELECT Id, Name FROM Topic WHERE Name IN :targetTopicNames]; System.Assert.areEqual(1, expectedResults.size()); - List returnedResults = LogManagementDataSelector.getInstance().getTopicsByName(targetTopicNames); + List returnedResults = LogManagementDataSelector.getInstance().getTopicsByName(targetTopicNames); System.Assert.areEqual(expectedResults, returnedResults); } @IsTest static void it_returns_users_for_user_ids() { - List expectedResults = [SELECT Id, Username FROM User LIMIT 3]; - List targetUserIds = new List(new Map(expectedResults).keySet()); + List expectedResults = [SELECT Id, Username FROM User LIMIT 3]; + List targetUserIds = new List(new Map(expectedResults).keySet()); - List returnedResults = LogManagementDataSelector.getInstance().getUsersById(targetUserIds); + List returnedResults = LogManagementDataSelector.getInstance().getUsersById(targetUserIds); expectedResults.sort(); returnedResults.sort(); @@ -405,9 +407,9 @@ private class LogManagementDataSelector_Tests { static void it_returns_empty_list_without_querying_when_specified_search_term_is_blank() { String blankSearchTerm = ' \t \n \r '; System.Assert.isTrue(String.isBlank(blankSearchTerm)); - List expectedResults = new List(); + List expectedResults = new List(); - List returnedResults = LogManagementDataSelector.getInstance().getUsersByNameSearch(blankSearchTerm); + List returnedResults = LogManagementDataSelector.getInstance().getUsersByNameSearch(blankSearchTerm); System.Assert.areEqual(expectedResults, returnedResults); System.Assert.areEqual(0, System.Limits.getQueries()); @@ -416,9 +418,13 @@ private class LogManagementDataSelector_Tests { @IsTest static void it_returns_user_for_specified_search_term() { String searchTerm = System.UserInfo.getLastName(); - List expectedResults = [SELECT Id, Name, Username, SmallPhotoUrl FROM User WHERE Name LIKE :searchTerm OR Username LIKE :searchTerm]; + List expectedResults = [ + SELECT Id, Name, Username, SmallPhotoUrl + FROM User + WHERE Name LIKE :searchTerm OR Username LIKE :searchTerm + ]; - List returnedResults = LogManagementDataSelector.getInstance().getUsersByNameSearch(searchTerm); + List returnedResults = LogManagementDataSelector.getInstance().getUsersByNameSearch(searchTerm); expectedResults.sort(); returnedResults.sort(); @@ -428,13 +434,13 @@ private class LogManagementDataSelector_Tests { @IsTest static void it_returns_users_for_user_usernames() { - List expectedResults = [SELECT Id, Username FROM User LIMIT 3]; + List expectedResults = [SELECT Id, Username FROM User LIMIT 3]; List targetUserUsernames = new List(); - for (User user : expectedResults) { + for (Schema.User user : expectedResults) { targetUserUsernames.add(user.Username); } - List returnedResults = LogManagementDataSelector.getInstance().getUsersByUsername(targetUserUsernames); + List returnedResults = LogManagementDataSelector.getInstance().getUsersByUsername(targetUserUsernames); expectedResults.sort(); returnedResults.sort(); diff --git a/nebula-logger/core/tests/log-management/classes/LoggerHomeHeaderController_Tests.cls b/nebula-logger/core/tests/log-management/classes/LoggerHomeHeaderController_Tests.cls index 899630ee7..2ce1531c1 100644 --- a/nebula-logger/core/tests/log-management/classes/LoggerHomeHeaderController_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LoggerHomeHeaderController_Tests.cls @@ -22,7 +22,7 @@ private class LoggerHomeHeaderController_Tests { LoggerHomeHeaderController.Environment returnedEnvironment = LoggerHomeHeaderController.getEnvironmentDetails(); - Organization organization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); + Schema.Organization organization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); System.Assert.areEqual(0, returnedEnvironment.loggerEnabledPluginsCount); System.Assert.isNull(returnedEnvironment.loggerEnabledPlugins); System.Assert.areEqual( @@ -57,7 +57,7 @@ private class LoggerHomeHeaderController_Tests { LoggerHomeHeaderController.Environment returnedEnvironment = LoggerHomeHeaderController.getEnvironmentDetails(); - Organization organization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); + Schema.Organization organization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); System.Assert.areEqual(0, returnedEnvironment.loggerEnabledPluginsCount); System.Assert.isNull(returnedEnvironment.loggerEnabledPlugins); System.Assert.areEqual( @@ -86,7 +86,7 @@ private class LoggerHomeHeaderController_Tests { LoggerHomeHeaderController.Environment returnedEnvironment = LoggerHomeHeaderController.getEnvironmentDetails(); - Organization organization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); + Schema.Organization organization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); System.Assert.areEqual(0, returnedEnvironment.loggerEnabledPluginsCount); System.Assert.isNull(returnedEnvironment.loggerEnabledPlugins); System.Assert.areEqual( diff --git a/nebula-logger/core/tests/log-management/classes/LoggerSObjectMetadata_Tests.cls b/nebula-logger/core/tests/log-management/classes/LoggerSObjectMetadata_Tests.cls index f95be5f01..a0165dc91 100644 --- a/nebula-logger/core/tests/log-management/classes/LoggerSObjectMetadata_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LoggerSObjectMetadata_Tests.cls @@ -7,7 +7,7 @@ * @description Test class for LoggerSObjectMetadata, used for dynamically converting SObject describe details * into `@AuraEnabled` objects that can be used in LWCs * To demonstrate that the class is standalone/would work with any SObject, these test methods - * all use the `User` SObject + * all use the `Schema.User` SObject */ @SuppressWarnings('PMD.ApexDoc, PMD.ApexUnitTestClassShouldHaveAsserts, PMD.MethodNamingConventions') @IsTest(IsParallel=true) diff --git a/nebula-logger/core/tests/log-management/classes/LoggerSettingsController_Tests.cls b/nebula-logger/core/tests/log-management/classes/LoggerSettingsController_Tests.cls index b512ed6e6..6df4db024 100644 --- a/nebula-logger/core/tests/log-management/classes/LoggerSettingsController_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LoggerSettingsController_Tests.cls @@ -202,7 +202,11 @@ private class LoggerSettingsController_Tests { @IsTest static void it_should_create_new_record_when_organization_is_a_sandbox() { - Organization mockOrganization = (Schema.Organization) LoggerMockDataCreator.setReadOnlyField(new Organization(), Schema.Organization.IsSandbox, true); + Schema.Organization mockOrganization = (Schema.Organization) LoggerMockDataCreator.setReadOnlyField( + new Schema.Organization(), + Schema.Organization.IsSandbox, + true + ); System.Assert.isTrue(mockOrganization.IsSandbox); LoggerCache.getOrganizationCache().put('Organization', mockOrganization); System.Assert.areEqual(mockOrganization, LoggerEngineDataSelector.getInstance().getCachedOrganization()); @@ -217,7 +221,11 @@ private class LoggerSettingsController_Tests { @IsTest static void it_should_create_new_record_when_organization_is_not_a_sandbox() { - Organization mockOrganization = (Schema.Organization) LoggerMockDataCreator.setReadOnlyField(new Organization(), Schema.Organization.IsSandbox, false); + Schema.Organization mockOrganization = (Schema.Organization) LoggerMockDataCreator.setReadOnlyField( + new Schema.Organization(), + Schema.Organization.IsSandbox, + false + ); System.Assert.isFalse(mockOrganization.IsSandbox); LoggerCache.getOrganizationCache().put('Organization', mockOrganization); System.Assert.areEqual(mockOrganization, LoggerEngineDataSelector.getInstance().getCachedOrganization()); @@ -307,9 +315,9 @@ private class LoggerSettingsController_Tests { @IsTest static void it_should_return_organization_record() { - Organization expectedRecord = LoggerEngineDataSelector.getInstance().getCachedOrganization(); + Schema.Organization expectedRecord = LoggerEngineDataSelector.getInstance().getCachedOrganization(); - Organization returnedRecord = LoggerSettingsController.getOrganization(); + Schema.Organization returnedRecord = LoggerSettingsController.getOrganization(); System.Assert.areEqual(expectedRecord, returnedRecord); } @@ -323,16 +331,16 @@ private class LoggerSettingsController_Tests { @IsTest static void it_should_return_profile_search_results_list_when_matches_found() { - Profile currentProfile = [SELECT Id, Name FROM Profile WHERE Id = :System.UserInfo.getProfileId()]; + Schema.Profile currentProfile = [SELECT Id, Name FROM Profile WHERE Id = :System.UserInfo.getProfileId()]; String searchTerm = '%' + currentProfile.Name.left(4) + '%'; - Map expectedResultsById = new Map([SELECT Id, Name, UserLicense.Name FROM Profile WHERE Name LIKE :searchTerm]); + Map expectedResultsById = new Map([SELECT Id, Name, UserLicense.Name FROM Profile WHERE Name LIKE :searchTerm]); List results = LoggerSettingsController.searchForSetupOwner('Profile', searchTerm); System.Assert.isFalse(results.isEmpty()); System.Assert.areEqual(expectedResultsById.size(), results.size()); for (LoggerSettingsController.SetupOwnerSearchResult result : results) { - Profile matchingProfile = expectedResultsById.get(result.recordId); + Schema.Profile matchingProfile = expectedResultsById.get(result.recordId); System.Assert.isNotNull(matchingProfile); System.Assert.areEqual(matchingProfile.Name, result.label); System.Assert.areEqual('License: ' + matchingProfile.UserLicense.Name, result.secondaryLabel); @@ -354,7 +362,7 @@ private class LoggerSettingsController_Tests { static void it_should_return_user_search_results_list_when_matches_found() { // Using lastName (required field) instead of the optional field firstName String searchTerm = '%' + System.UserInfo.getLastName() + '%'; - Map expectedResultsById = new Map( + Map expectedResultsById = new Map( [SELECT Id, Name, Username, SmallPhotoUrl FROM User WHERE Name LIKE :searchTerm OR Username LIKE :searchTerm] ); @@ -363,7 +371,7 @@ private class LoggerSettingsController_Tests { System.Assert.isFalse(results.isEmpty()); System.Assert.areEqual(expectedResultsById.size(), results.size()); for (LoggerSettingsController.SetupOwnerSearchResult result : results) { - User matchingUser = expectedResultsById.get(result.recordId); + Schema.User matchingUser = expectedResultsById.get(result.recordId); System.Assert.isNotNull(matchingUser); System.Assert.areEqual(matchingUser.Username, result.label); System.Assert.areEqual('Name: ' + matchingUser.Name, result.secondaryLabel); diff --git a/nebula-logger/core/tests/logger-engine/classes/ComponentLogger_Tests.cls b/nebula-logger/core/tests/logger-engine/classes/ComponentLogger_Tests.cls index 37c2bf12e..b2a7e0450 100644 --- a/nebula-logger/core/tests/logger-engine/classes/ComponentLogger_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/ComponentLogger_Tests.cls @@ -277,7 +277,11 @@ private class ComponentLogger_Tests { } private static ComponentLogger.ComponentLogEntry createMockComponentLogEntry() { - User currentUser = new User(FirstName = System.UserInfo.getFirstName(), Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User currentUser = new Schema.User( + FirstName = System.UserInfo.getFirstName(), + Id = System.UserInfo.getUserId(), + ProfileId = System.UserInfo.getProfileId() + ); ComponentLogger.ComponentLogEntry componentLogEntry = new ComponentLogger.ComponentLogEntry(); componentLogEntry.browserFormFactor = 'Large'; componentLogEntry.browserLanguage = 'en-US'; diff --git a/nebula-logger/core/tests/logger-engine/classes/FlowCollectionLogEntry_Tests.cls b/nebula-logger/core/tests/logger-engine/classes/FlowCollectionLogEntry_Tests.cls index de40973a9..bb310737c 100644 --- a/nebula-logger/core/tests/logger-engine/classes/FlowCollectionLogEntry_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/FlowCollectionLogEntry_Tests.cls @@ -18,7 +18,7 @@ private class FlowCollectionLogEntry_Tests { @IsTest static void it_should_save_entry_when_logging_level_met() { LoggerDataStore.setMock(LoggerMockDataStore.getEventBus()); - User currentUser = new User( + Schema.User currentUser = new Schema.User( Id = System.UserInfo.getUserId(), FirstName = System.UserInfo.getFirstName(), LastName = System.UserInfo.getLastName(), @@ -59,7 +59,7 @@ private class FlowCollectionLogEntry_Tests { @IsTest static void it_should_auto_save_entry_when_saveLog_is_true() { LoggerDataStore.setMock(LoggerMockDataStore.getEventBus()); - User currentUser = new User( + Schema.User currentUser = new Schema.User( Id = System.UserInfo.getUserId(), FirstName = System.UserInfo.getFirstName(), LastName = System.UserInfo.getLastName(), @@ -98,7 +98,7 @@ private class FlowCollectionLogEntry_Tests { static void it_should_auto_save_entry_with_save_method_when_saveMethodName_specified() { LoggerDataStore.setMock(LoggerMockDataStore.getEventBus()); LoggerDataStore.setMock(LoggerMockDataStore.getJobQueue()); - User currentUser = new User( + Schema.User currentUser = new Schema.User( Id = System.UserInfo.getUserId(), FirstName = System.UserInfo.getFirstName(), LastName = System.UserInfo.getLastName(), @@ -144,7 +144,7 @@ private class FlowCollectionLogEntry_Tests { @IsTest static void it_should_not_save_entry_when_logging_level_not_met() { LoggerDataStore.setMock(LoggerMockDataStore.getEventBus()); - User currentUser = new User( + Schema.User currentUser = new Schema.User( Id = System.UserInfo.getUserId(), FirstName = System.UserInfo.getFirstName(), LastName = System.UserInfo.getLastName(), diff --git a/nebula-logger/core/tests/logger-engine/classes/FlowRecordLogEntry_Tests.cls b/nebula-logger/core/tests/logger-engine/classes/FlowRecordLogEntry_Tests.cls index b5d114f61..b86168f1a 100644 --- a/nebula-logger/core/tests/logger-engine/classes/FlowRecordLogEntry_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/FlowRecordLogEntry_Tests.cls @@ -18,7 +18,7 @@ private class FlowRecordLogEntry_Tests { @IsTest static void it_should_save_entry_when_logging_level_met() { LoggerDataStore.setMock(LoggerMockDataStore.getEventBus()); - User currentUser = new User( + Schema.User currentUser = new Schema.User( Id = System.UserInfo.getUserId(), FirstName = System.UserInfo.getFirstName(), LastName = System.UserInfo.getLastName(), @@ -60,7 +60,7 @@ private class FlowRecordLogEntry_Tests { static void it_should_auto_save_entry_with_save_method_when_saveMethodName_specified() { LoggerDataStore.setMock(LoggerMockDataStore.getEventBus()); LoggerDataStore.setMock(LoggerMockDataStore.getJobQueue()); - User currentUser = new User( + Schema.User currentUser = new Schema.User( Id = System.UserInfo.getUserId(), FirstName = System.UserInfo.getFirstName(), LastName = System.UserInfo.getLastName(), @@ -104,7 +104,7 @@ private class FlowRecordLogEntry_Tests { @IsTest static void it_should_auto_save_entry_when_saveLog_is_true() { LoggerDataStore.setMock(LoggerMockDataStore.getEventBus()); - User currentUser = new User( + Schema.User currentUser = new Schema.User( Id = System.UserInfo.getUserId(), FirstName = System.UserInfo.getFirstName(), LastName = System.UserInfo.getLastName(), @@ -141,7 +141,7 @@ private class FlowRecordLogEntry_Tests { @IsTest static void it_should_not_save_entry_when_logging_level_not_met() { LoggerDataStore.setMock(LoggerMockDataStore.getEventBus()); - User currentUser = new User( + Schema.User currentUser = new Schema.User( Id = System.UserInfo.getUserId(), FirstName = System.UserInfo.getFirstName(), LastName = System.UserInfo.getLastName(), diff --git a/nebula-logger/core/tests/logger-engine/classes/LogEntryEventBuilder_Tests.cls b/nebula-logger/core/tests/logger-engine/classes/LogEntryEventBuilder_Tests.cls index 27499631f..25ea23fde 100644 --- a/nebula-logger/core/tests/logger-engine/classes/LogEntryEventBuilder_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/LogEntryEventBuilder_Tests.cls @@ -27,10 +27,10 @@ private class LogEntryEventBuilder_Tests { System.Assert.isNull(builder.setDatabaseResult(new List()).getLogEntryEvent()); System.Assert.isNull(builder.setDatabaseResult(new List()).getLogEntryEvent()); System.Assert.isNull(builder.setRecordId(System.UserInfo.getUserId()).getLogEntryEvent()); - System.Assert.isNull(builder.setRecordId(new User(Id = System.UserInfo.getUserId())).getLogEntryEvent()); + System.Assert.isNull(builder.setRecordId(new Schema.User(Id = System.UserInfo.getUserId())).getLogEntryEvent()); System.Assert.isNull(builder.setRecord(System.UserInfo.getUserId()).getLogEntryEvent()); - System.Assert.isNull(builder.setRecord(new User(Id = System.UserInfo.getUserId())).getLogEntryEvent()); - System.Assert.isNull(builder.setRecord(new List{ new User(Id = System.UserInfo.getUserId()) }).getLogEntryEvent()); + System.Assert.isNull(builder.setRecord(new Schema.User(Id = System.UserInfo.getUserId())).getLogEntryEvent()); + System.Assert.isNull(builder.setRecord(new List{ new Schema.User(Id = System.UserInfo.getUserId()) }).getLogEntryEvent()); System.Assert.isNull(builder.addTags(new List{ 'tag-1', 'tag-2' }).getLogEntryEvent()); System.Assert.isNull(builder.parseStackTrace(new System.DmlException().getStackTraceString()).getLogEntryEvent()); } @@ -152,7 +152,7 @@ private class LogEntryEventBuilder_Tests { .getLogEntryEvent(); System.Assert.areNotEqual(0, mockSelector.getCachedOrganizationQueryCount()); - Organization cachedOrganization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); + Schema.Organization cachedOrganization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); System.Assert.areEqual(cachedOrganization.Id, logEntryEvent.OrganizationId__c); System.Assert.areEqual(cachedOrganization.InstanceName, logEntryEvent.OrganizationInstanceName__c); System.Assert.areEqual(cachedOrganization.Name, logEntryEvent.OrganizationName__c); @@ -194,7 +194,7 @@ private class LogEntryEventBuilder_Tests { .getLogEntryEvent(); System.Assert.areNotEqual(0, mockSelector.getCachedUserQueryCount()); - User cachedUser = LoggerEngineDataSelector.getInstance().getCachedUser(); + Schema.User cachedUser = LoggerEngineDataSelector.getInstance().getCachedUser(); System.Assert.areEqual(cachedUser.Username, logEntryEvent.LoggedByUsername__c); System.Assert.areEqual(cachedUser.Profile.Name, logEntryEvent.ProfileName__c); System.Assert.areEqual(cachedUser.Profile.UserLicense.LicenseDefinitionKey, logEntryEvent.UserLicenseDefinitionKey__c); @@ -287,7 +287,7 @@ private class LogEntryEventBuilder_Tests { rule.IsEnabled__c = false; LogEntryEventBuilder.setMockDataMaskRule(rule); String message = 'Something, something, and my social is 400 11 9999 in case you want to steal my identity'; - Account account = new Account(Name = message); + Schema.Account account = new Schema.Account(Name = message); String accountJson = JSON.serializePretty(account); LogEntryEventBuilder builder = new LogEntryEventBuilder(userSettings, System.LoggingLevel.INFO, true, new Set()); @@ -307,7 +307,7 @@ private class LogEntryEventBuilder_Tests { rule.IsEnabled__c = true; LogEntryEventBuilder.setMockDataMaskRule(rule); String message = 'Something, something, and my social is 400 11 9999 in case you want to steal my identity'; - Account account = new Account(Name = message); + Schema.Account account = new Schema.Account(Name = message); String accountJson = JSON.serializePretty(account); LogEntryEventBuilder builder = new LogEntryEventBuilder(userSettings, System.LoggingLevel.INFO, true, new Set()); @@ -346,9 +346,9 @@ private class LogEntryEventBuilder_Tests { LogEntryEventBuilder.setMockDataMaskRule(rule); String sensitiveString = 'Something, something, and my social is 400 11 9999 in case you want to steal my identity'; String expectedSanitizedString = 'Something, something, and my social is XXX-XX-9999 in case you want to steal my identity'; - Account account = new Account(Name = sensitiveString); + Schema.Account account = new Schema.Account(Name = sensitiveString); String accountJson = JSON.serializePretty(account); - String expectedSanitizedAccountJson = JSON.serializePretty(new Account(Name = expectedSanitizedString)); + String expectedSanitizedAccountJson = JSON.serializePretty(new Schema.Account(Name = expectedSanitizedString)); LogEntryEventBuilder builder = new LogEntryEventBuilder(userSettings, System.LoggingLevel.INFO, true, new Set()); builder.setRecord(account); @@ -368,9 +368,9 @@ private class LogEntryEventBuilder_Tests { String sensitiveString = 'Something, something, and my social is 400 11 9999 in case you want to steal my identity'; String expectedSanitizedString = 'Something, something, and my social is XXX-XX-9999 in case you want to steal my identity'; - List accounts = new List{ new Account(Name = sensitiveString) }; + List accounts = new List{ new Schema.Account(Name = sensitiveString) }; String accountListJson = JSON.serializePretty(accounts); - String expectedSanitizedAccountListJson = JSON.serializePretty(new List{ new Account(Name = expectedSanitizedString) }); + String expectedSanitizedAccountListJson = JSON.serializePretty(new List{ new Schema.Account(Name = expectedSanitizedString) }); LogEntryEventBuilder builder = new LogEntryEventBuilder(userSettings, System.LoggingLevel.INFO, true, new Set()); builder.setRecord(accounts); @@ -766,7 +766,7 @@ private class LogEntryEventBuilder_Tests { System.Assert.isNull(builder.getLogEntryEvent().RecordSObjectType__c); System.Assert.isNull(builder.getLogEntryEvent().RecordSObjectTypeNamespace__c); - User nullUser; + Schema.User nullUser; System.Assert.isNull(nullUser); builder.setRecordId(nullUser); @@ -788,7 +788,7 @@ private class LogEntryEventBuilder_Tests { System.Assert.isNull(builder.getLogEntryEvent().RecordSObjectType__c); System.Assert.isNull(builder.getLogEntryEvent().RecordSObjectTypeNamespace__c); - User currentUser = [SELECT Id, Name, ProfileId, Profile.Name, IsActive FROM User WHERE Id = :System.UserInfo.getUserId()]; + Schema.User currentUser = [SELECT Id, Name, ProfileId, Profile.Name, IsActive FROM User WHERE Id = :System.UserInfo.getUserId()]; builder.setRecordId(currentUser); System.Assert.areEqual(1, builder.getLogEntryEvent().RecordCollectionSize__c); @@ -863,7 +863,7 @@ private class LogEntryEventBuilder_Tests { @IsTest static void it_should_skip_stripping_inaccessible_fields_for_aggregate_result() { - User standardUser = LoggerMockDataCreator.createUser(); + Schema.User standardUser = LoggerMockDataCreator.createUser(); AggregateResult mockAggregateResult = LoggerMockDataCreator.createAggregateResult(); LogEntryEventBuilder builder; @@ -878,7 +878,7 @@ private class LogEntryEventBuilder_Tests { @IsTest static void it_should_skip_stripping_inaccessible_fields_for_aggregate_results() { - User standardUser = LoggerMockDataCreator.createUser(); + Schema.User standardUser = LoggerMockDataCreator.createUser(); List mockAggregateResults = new List{ LoggerMockDataCreator.createAggregateResult() }; LogEntryEventBuilder builder; @@ -941,9 +941,9 @@ private class LogEntryEventBuilder_Tests { System.Assert.isNull(builder.getLogEntryEvent().RecordSObjectTypeNamespace__c); List users = new List(); - User nullUser; + Schema.User nullUser; users.add(nullUser); - users.add(new User(Id = System.UserInfo.getUserId())); + users.add(new Schema.User(Id = System.UserInfo.getUserId())); builder.setRecord(users); System.Assert.areEqual('List', builder.getLogEntryEvent().RecordCollectionType__c); @@ -962,14 +962,14 @@ private class LogEntryEventBuilder_Tests { System.Assert.isNull(builder.getLogEntryEvent().RecordSObjectType__c); System.Assert.isNull(builder.getLogEntryEvent().RecordSObjectTypeNamespace__c); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; builder.setRecord(users); System.Assert.areEqual('List', builder.getLogEntryEvent().RecordCollectionType__c); System.Assert.isNull(builder.getLogEntryEvent().RecordId__c); System.Assert.areEqual(JSON.serializePretty(users), builder.getLogEntryEvent().RecordJson__c); System.Assert.areEqual('Standard Object', builder.getLogEntryEvent().RecordSObjectClassification__c); - System.Assert.areEqual(User.SObjectType.getDescribe().getName(), builder.getLogEntryEvent().RecordSObjectType__c); + System.Assert.areEqual(Schema.User.SObjectType.getDescribe().getName(), builder.getLogEntryEvent().RecordSObjectType__c); } @IsTest @@ -1023,7 +1023,7 @@ private class LogEntryEventBuilder_Tests { System.Assert.isNull(builder.getLogEntryEvent().RecordSObjectType__c); System.Assert.isNull(builder.getLogEntryEvent().RecordSObjectTypeNamespace__c); - Map userIdToUser = new Map{ null => new User(Id = System.UserInfo.getUserId()) }; + Map userIdToUser = new Map{ null => new Schema.User(Id = System.UserInfo.getUserId()) }; builder.setRecord(userIdToUser); Map userIdStringToUser = new Map{ '' => userIdToUser.get(null) }; @@ -1045,10 +1045,10 @@ private class LogEntryEventBuilder_Tests { System.Assert.isNull(builder.getLogEntryEvent().RecordSObjectTypeNamespace__c); Id mockUserId = LoggerMockDataCreator.createId(Schema.User.SObjectType); - User nullUser; + Schema.User nullUser; Map userIdToUser = new Map{ mockUserId => nullUser, - System.UserInfo.getUserId() => new User(Id = System.UserInfo.getUserId(), Username = System.UserInfo.getUsername()) + System.UserInfo.getUserId() => new Schema.User(Id = System.UserInfo.getUserId(), Username = System.UserInfo.getUsername()) }; builder.setRecord(userIdToUser); @@ -1070,7 +1070,7 @@ private class LogEntryEventBuilder_Tests { System.Assert.isNull(builder.getLogEntryEvent().RecordSObjectType__c); System.Assert.isNull(builder.getLogEntryEvent().RecordSObjectTypeNamespace__c); - Map userIdToUser = new Map([SELECT Id, Name, Username, IsActive FROM User LIMIT 5]); + Map userIdToUser = new Map([SELECT Id, Name, Username, IsActive FROM User LIMIT 5]); builder.setRecord(userIdToUser); System.Assert.areEqual(userIdToUser.size(), builder.getLogEntryEvent().RecordCollectionSize__c); @@ -1078,7 +1078,7 @@ private class LogEntryEventBuilder_Tests { System.Assert.isNull(builder.getLogEntryEvent().RecordId__c); System.Assert.areEqual(JSON.serializePretty(userIdToUser), builder.getLogEntryEvent().RecordJson__c); System.Assert.areEqual('Standard Object', builder.getLogEntryEvent().RecordSObjectClassification__c); - System.Assert.areEqual(User.SObjectType.getDescribe().getName(), builder.getLogEntryEvent().RecordSObjectType__c); + System.Assert.areEqual(Schema.User.SObjectType.getDescribe().getName(), builder.getLogEntryEvent().RecordSObjectType__c); } @IsTest @@ -1391,9 +1391,9 @@ private class LogEntryEventBuilder_Tests { static void it_should_set_user_fields_when_anonymous_mode_disabled() { LoggerParameter.setMock(new LoggerParameter__mdt(DeveloperName = 'QueryOrganizationDataSynchronously', Value__c = String.valueOf(true))); LoggerParameter.setMock(new LoggerParameter__mdt(DeveloperName = 'QueryUserDataSynchronously', Value__c = String.valueOf(true))); - Organization organization = LoggerMockDataCreator.getOrganization(); + Schema.Organization organization = LoggerMockDataCreator.getOrganization(); String organizationEnvironmentType = LoggerMockDataCreator.getOrganizationEnvironmentType(); - User user = LoggerMockDataCreator.getUser(); + Schema.User user = LoggerMockDataCreator.getUser(); LogEntryEventBuilder builder = new LogEntryEventBuilder(getUserSettings(), System.LoggingLevel.INFO, true, new Set()); @@ -1541,7 +1541,7 @@ private class LogEntryEventBuilder_Tests { return cachedAuthSessionQueryCount; } - public override Organization getCachedOrganization() { + public override Schema.Organization getCachedOrganization() { this.cachedOrganizationQueryCount++; return super.getCachedOrganization(); } @@ -1550,7 +1550,7 @@ private class LogEntryEventBuilder_Tests { return cachedOrganizationQueryCount; } - public override User getCachedUser() { + public override Schema.User getCachedUser() { this.cachedUserQueryCount++; return super.getCachedUser(); } diff --git a/nebula-logger/core/tests/logger-engine/classes/LogMessage_Tests.cls b/nebula-logger/core/tests/logger-engine/classes/LogMessage_Tests.cls index 994174987..adfc9fbb7 100644 --- a/nebula-logger/core/tests/logger-engine/classes/LogMessage_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/LogMessage_Tests.cls @@ -69,7 +69,7 @@ private class LogMessage_Tests { String unformattedMessage = 'my string with 1 input: {0} and then {1} and finally {2}'; Datetime argument1 = System.now(); Date argument2 = System.today(); - User argument3 = new User(Id = System.UserInfo.getUserId()); + Schema.User argument3 = new Schema.User(Id = System.UserInfo.getUserId()); String expectedMessage = String.format(unformattedMessage, new List{ argument1, argument2, argument3 }); String returnedMessage = new LogMessage(unformattedMessage, argument1, argument2, argument3).getMessage(); diff --git a/nebula-logger/core/tests/logger-engine/classes/LoggerDataStore_Tests.cls b/nebula-logger/core/tests/logger-engine/classes/LoggerDataStore_Tests.cls index 8c5194b99..1ea251f50 100644 --- a/nebula-logger/core/tests/logger-engine/classes/LoggerDataStore_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/LoggerDataStore_Tests.cls @@ -4,7 +4,7 @@ //------------------------------------------------------------------------------------------------// // TODO switch to using standard object(s) available in all orgs (instead of Log__c) so this can be split off as a separate repo -// Possible objects to use: User, Group (Queue) and QueueSObject (none support undelete though), and not sure if it's possible +// Possible objects to use: Schema.User, Schema.Group (Queue) and QueueSObject (none support undelete though), and not sure if it's possible // to test platform events/EventBus using only standard objects @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions') @IsTest(IsParallel=true) @@ -543,7 +543,7 @@ private class LoggerDataStore_Tests { LoggerDataStore.setMock(mockDatabaseInstance); System.Assert.areEqual(mockDatabaseInstance, LoggerDataStore.getDatabase()); - LoggerDataStore.getDatabase().updateRecord(new User(Id = System.UserInfo.getUserId())); + LoggerDataStore.getDatabase().updateRecord(new Schema.User(Id = System.UserInfo.getUserId())); System.Assert.areEqual(1, mockDatabaseInstance.callCount); } @@ -555,7 +555,7 @@ private class LoggerDataStore_Tests { LoggerDataStore.setMock(mockEventBusInstance); System.Assert.areEqual(mockEventBusInstance, LoggerDataStore.getEventBus()); - LoggerDataStore.getEventBus().publishRecord(new User()); // Not an actual platform event, but for mocking/test purposes, User is fine + LoggerDataStore.getEventBus().publishRecord(new Schema.User()); // Not an actual platform event, but for mocking/test purposes, Schema.User is fine System.Assert.areEqual(1, mockEventBusInstance.callCount); } diff --git a/nebula-logger/core/tests/logger-engine/classes/LoggerEngineDataSelector_Tests.cls b/nebula-logger/core/tests/logger-engine/classes/LoggerEngineDataSelector_Tests.cls index a059ed2c2..0e27ee8a7 100644 --- a/nebula-logger/core/tests/logger-engine/classes/LoggerEngineDataSelector_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/LoggerEngineDataSelector_Tests.cls @@ -18,7 +18,7 @@ private class LoggerEngineDataSelector_Tests { @IsTest static void it_returns_cached_auth_session_proxy() { - List sessions = [ + List sessions = [ SELECT Id, LoginType, @@ -90,7 +90,7 @@ private class LoggerEngineDataSelector_Tests { @IsTest static void it_returns_cached_organization() { - Organization expectedOrganization = [ + Schema.Organization expectedOrganization = [ SELECT Id, CreatedById, @@ -110,7 +110,7 @@ private class LoggerEngineDataSelector_Tests { System.Assert.areEqual(mockSelector, LoggerEngineDataSelector.getInstance()); System.Assert.areEqual(0, mockSelector.getCachedOrganizationQueryCount()); - Organization returnedOrganization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); + Schema.Organization returnedOrganization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); System.Assert.areEqual(1, mockSelector.getCachedOrganizationQueryCount()); LoggerEngineDataSelector.getInstance().getCachedOrganization(); @@ -125,7 +125,7 @@ private class LoggerEngineDataSelector_Tests { System.Assert.areEqual(0, mockSelector.getCachedOrganizationQueryCount()); LoggerParameter.setMock(new LoggerParameter__mdt(DeveloperName = 'QueryOrganizationData', Value__c = String.valueOf(false))); - Organization returnedOrganization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); + Schema.Organization returnedOrganization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); System.Assert.areEqual(0, mockSelector.getCachedOrganizationQueryCount()); System.Assert.isNull(returnedOrganization); @@ -150,14 +150,14 @@ private class LoggerEngineDataSelector_Tests { @IsTest static void it_returns_cached_user() { - User expectedUser = [ + Schema.User expectedUser = [ SELECT Id, Profile.Name, Profile.UserLicenseId, Profile.UserLicense.LicenseDefinitionKey, Profile.UserLicense.Name, Username, UserRole.Name FROM User WHERE Id = :System.UserInfo.getUserId() ]; System.Assert.areEqual(1, System.Limits.getQueries()); - User returnedUser = LoggerEngineDataSelector.getInstance().getCachedUser(); + Schema.User returnedUser = LoggerEngineDataSelector.getInstance().getCachedUser(); System.Assert.areEqual(2, System.Limits.getQueries()); LoggerEngineDataSelector.getInstance().getCachedUser(); @@ -170,7 +170,7 @@ private class LoggerEngineDataSelector_Tests { LoggerParameter.setMock(new LoggerParameter__mdt(DeveloperName = 'QueryUserData', Value__c = String.valueOf(false))); System.Assert.isFalse(LoggerParameter.QUERY_USER_DATA); - User returnedUser = LoggerEngineDataSelector.getInstance().getCachedUser(); + Schema.User returnedUser = LoggerEngineDataSelector.getInstance().getCachedUser(); System.Assert.areEqual(0, System.Limits.getQueries()); System.Assert.isNull(returnedUser); @@ -193,9 +193,9 @@ private class LoggerEngineDataSelector_Tests { return authSessionQueryCount; } - public override Organization getCachedOrganization() { + public override Schema.Organization getCachedOrganization() { Integer originalQueryCount = System.Limits.getQueries(); - Organization result = super.getCachedOrganization(); + Schema.Organization result = super.getCachedOrganization(); if (System.Limits.getQueries() != originalQueryCount) { organizationQueryCount = System.Limits.getQueries() - originalQueryCount; } diff --git a/nebula-logger/core/tests/logger-engine/classes/LoggerSObjectHandler_Tests.cls b/nebula-logger/core/tests/logger-engine/classes/LoggerSObjectHandler_Tests.cls index 9c1c4b5a3..8b7303f48 100644 --- a/nebula-logger/core/tests/logger-engine/classes/LoggerSObjectHandler_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/LoggerSObjectHandler_Tests.cls @@ -6,7 +6,7 @@ /** * @description Test class for LoggerSObjectHandler, the trigger-handler framework used by Nebula Logger. * To demonstrate that the framework is standalone/would work with any SObject, these test methods - * all use mock implementations of the handler, using the `User` SObject + * all use mock implementations of the handler, using the `Schema.User` SObject */ @SuppressWarnings('PMD.ApexDoc, PMD.ApexAssertionsShouldIncludeMessage, PMD.MethodNamingConventions') @IsTest(IsParallel=true) @@ -74,7 +74,7 @@ private class LoggerSObjectHandler_Tests { LoggerTriggerableContext customContext = new LoggerTriggerableContext( Schema.User.SObjectType, TriggerOperation.BEFORE_INSERT, - new List{ new User(Id = System.UserInfo.getUserId(), Email = System.UserInfo.getUserEmail()) } + new List{ new Schema.User(Id = System.UserInfo.getUserId(), Email = System.UserInfo.getUserEmail()) } ); System.Assert.areNotEqual(originalContext, customContext); @@ -86,9 +86,9 @@ private class LoggerSObjectHandler_Tests { @IsTest static void it_should_not_run_when_disabled_via_logger_parameter() { - User mockUser = (User) LoggerMockDataCreator.createUser(); + Schema.User mockUser = (Schema.User) LoggerMockDataCreator.createUser(); mockUser.Id = LoggerMockDataCreator.createId(Schema.User.SObjectType); - List records = new List{ mockUser }; + List records = new List{ mockUser }; MockSObjectHandler mockHandler = new MockSObjectHandler(Schema.User.SObjectType); mockHandler.handlerConfiguration = new LoggerSObjectHandler__mdt(IsEnabled__c = false); mockHandler.triggerOperationType = TriggerOperation.BEFORE_INSERT; @@ -103,9 +103,9 @@ private class LoggerSObjectHandler_Tests { @IsTest static void it_should_not_run_when_disabled_via_private_method() { - User mockUser = (User) LoggerMockDataCreator.createUser(); + Schema.User mockUser = (Schema.User) LoggerMockDataCreator.createUser(); mockUser.Id = LoggerMockDataCreator.createId(Schema.User.SObjectType); - List records = new List{ mockUser }; + List records = new List{ mockUser }; MockSObjectHandler mockHandler = new MockSObjectHandler(Schema.User.SObjectType); mockHandler.handlerConfiguration = new LoggerSObjectHandler__mdt(IsEnabled__c = true); mockHandler.triggerOperationType = TriggerOperation.BEFORE_INSERT; @@ -121,9 +121,9 @@ private class LoggerSObjectHandler_Tests { @IsTest static void it_should_run_before_insert_method() { - User mockUser = (User) LoggerMockDataCreator.createUser(); + Schema.User mockUser = (Schema.User) LoggerMockDataCreator.createUser(); mockUser.Id = LoggerMockDataCreator.createId(Schema.User.SObjectType); - List records = new List{ mockUser }; + List records = new List{ mockUser }; MockSObjectHandler mockHandler = new MockSObjectHandler(Schema.User.SObjectType); mockHandler.triggerOperationType = TriggerOperation.BEFORE_INSERT; mockHandler.triggerNew = records; @@ -141,9 +141,9 @@ private class LoggerSObjectHandler_Tests { @IsTest static void it_should_run_before_update_method() { - User mockUser = (User) LoggerMockDataCreator.createUser(); + Schema.User mockUser = (Schema.User) LoggerMockDataCreator.createUser(); mockUser.Id = LoggerMockDataCreator.createId(Schema.User.SObjectType); - List records = new List{ mockUser }; + List records = new List{ mockUser }; MockSObjectHandler mockHandler = new MockSObjectHandler(Schema.User.SObjectType); mockHandler.triggerOperationType = TriggerOperation.BEFORE_UPDATE; mockHandler.triggerNew = null; @@ -161,9 +161,9 @@ private class LoggerSObjectHandler_Tests { @IsTest static void it_should_run_before_delete_method() { - User mockUser = (User) LoggerMockDataCreator.createUser(); + Schema.User mockUser = (Schema.User) LoggerMockDataCreator.createUser(); mockUser.Id = LoggerMockDataCreator.createId(Schema.User.SObjectType); - List records = new List{ mockUser }; + List records = new List{ mockUser }; MockSObjectHandler mockHandler = new MockSObjectHandler(Schema.User.SObjectType); mockHandler.triggerOperationType = TriggerOperation.BEFORE_DELETE; mockHandler.triggerNew = null; @@ -183,9 +183,9 @@ private class LoggerSObjectHandler_Tests { static void it_should_run_after_insert_methods() { // To handle AFTER_INSERT on LogEntryEvent__e, LoggerSObjectHandler has 2 methods - one with // a list of SObject records (triggerNew), and another with a map of SObject records (triggerNewMap) - User mockUser = (User) LoggerMockDataCreator.createUser(); + Schema.User mockUser = (Schema.User) LoggerMockDataCreator.createUser(); mockUser.Id = LoggerMockDataCreator.createId(Schema.User.SObjectType); - List records = new List{ mockUser }; + List records = new List{ mockUser }; MockSObjectHandler mockHandler = new MockSObjectHandler(Schema.User.SObjectType); mockHandler.triggerOperationType = TriggerOperation.AFTER_INSERT; mockHandler.triggerNew = records; @@ -203,9 +203,9 @@ private class LoggerSObjectHandler_Tests { @IsTest static void it_should_run_after_update_method() { - User mockUser = (User) LoggerMockDataCreator.createUser(); + Schema.User mockUser = (Schema.User) LoggerMockDataCreator.createUser(); mockUser.Id = LoggerMockDataCreator.createId(Schema.User.SObjectType); - List records = new List{ mockUser }; + List records = new List{ mockUser }; MockSObjectHandler mockHandler = new MockSObjectHandler(Schema.User.SObjectType); mockHandler.triggerOperationType = TriggerOperation.AFTER_UPDATE; mockHandler.triggerNew = null; @@ -223,9 +223,9 @@ private class LoggerSObjectHandler_Tests { @IsTest static void it_should_run_after_delete_method() { - User mockUser = (User) LoggerMockDataCreator.createUser(); + Schema.User mockUser = (Schema.User) LoggerMockDataCreator.createUser(); mockUser.Id = LoggerMockDataCreator.createId(Schema.User.SObjectType); - List records = new List{ mockUser }; + List records = new List{ mockUser }; MockSObjectHandler mockHandler = new MockSObjectHandler(Schema.User.SObjectType); mockHandler.triggerOperationType = TriggerOperation.AFTER_DELETE; mockHandler.triggerNew = null; @@ -243,9 +243,9 @@ private class LoggerSObjectHandler_Tests { @IsTest static void it_should_run_after_undelete_method() { - User mockUser = (User) LoggerMockDataCreator.createUser(); + Schema.User mockUser = (Schema.User) LoggerMockDataCreator.createUser(); mockUser.Id = LoggerMockDataCreator.createId(Schema.User.SObjectType); - List records = new List{ mockUser }; + List records = new List{ mockUser }; MockSObjectHandler mockHandler = new MockSObjectHandler(Schema.User.SObjectType); mockHandler.triggerOperationType = TriggerOperation.AFTER_UNDELETE; mockHandler.triggerNew = null; @@ -263,9 +263,9 @@ private class LoggerSObjectHandler_Tests { @IsTest static void it_should_gracefully_skip_non_existent_apex_plugin() { - User mockUser = (User) LoggerMockDataCreator.createUser(); + Schema.User mockUser = (Schema.User) LoggerMockDataCreator.createUser(); mockUser.Id = LoggerMockDataCreator.createId(Schema.User.SObjectType); - List records = new List{ mockUser }; + List records = new List{ mockUser }; MockSObjectHandler mockHandler = new MockSObjectHandler(Schema.User.SObjectType); mockHandler.triggerOperationType = TriggerOperation.BEFORE_INSERT; mockHandler.triggerNew = records; @@ -287,9 +287,9 @@ private class LoggerSObjectHandler_Tests { @IsTest static void it_should_execute_apex_plugin() { - User mockUser = (User) LoggerMockDataCreator.createUser(); + Schema.User mockUser = (Schema.User) LoggerMockDataCreator.createUser(); mockUser.Id = LoggerMockDataCreator.createId(Schema.User.SObjectType); - List records = new List{ mockUser }; + List records = new List{ mockUser }; MockSObjectHandler mockHandler = new MockSObjectHandler(Schema.User.SObjectType); mockHandler.triggerOperationType = TriggerOperation.BEFORE_INSERT; mockHandler.triggerNew = records; @@ -314,9 +314,9 @@ private class LoggerSObjectHandler_Tests { @IsTest static void it_should_gracefully_skip_non_existent_flow_plugin() { - User mockUser = (User) LoggerMockDataCreator.createUser(); + Schema.User mockUser = (Schema.User) LoggerMockDataCreator.createUser(); mockUser.Id = LoggerMockDataCreator.createId(Schema.User.SObjectType); - List records = new List{ mockUser }; + List records = new List{ mockUser }; MockSObjectHandler mockHandler = new MockSObjectHandler(Schema.User.SObjectType); mockHandler.triggerOperationType = TriggerOperation.BEFORE_INSERT; mockHandler.triggerNew = records; diff --git a/nebula-logger/core/tests/logger-engine/classes/LoggerSObjectProxy_Tests.cls b/nebula-logger/core/tests/logger-engine/classes/LoggerSObjectProxy_Tests.cls index def37df9b..817200dfb 100644 --- a/nebula-logger/core/tests/logger-engine/classes/LoggerSObjectProxy_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/LoggerSObjectProxy_Tests.cls @@ -10,7 +10,7 @@ private class LoggerSObjectProxy_Tests { @IsTest static void it_converts_auth_session_record_to_proxy() { - List authSessionRecords = [ + List authSessionRecords = [ SELECT Id, LoginHistory.Application, @@ -28,11 +28,11 @@ private class LoggerSObjectProxy_Tests { LIMIT 1 ]; if (authSessionRecords.isEmpty()) { - // Since the AuthSession object cannot be mocked, the test can only run as an integration test - // No need to fail the test if there isn't a AuthSession record available via querying + // Since the Schema.AuthSession object cannot be mocked, the test can only run as an integration test + // No need to fail the test if there isn't a Schema.AuthSession record available via querying return; } - AuthSession authSessionRecord = authSessionRecords.get(0); + Schema.AuthSession authSessionRecord = authSessionRecords.get(0); LoggerSObjectProxy.AuthSession authSessionProxy = new LoggerSObjectProxy.AuthSession(authSessionRecord); @@ -52,7 +52,7 @@ private class LoggerSObjectProxy_Tests { @IsTest static void it_converts_login_history_record_to_proxy() { - List loginHistoryRecords = [ + List loginHistoryRecords = [ SELECT Application, Browser, Platform, UserId FROM LoginHistory LIMIT 1 @@ -62,7 +62,7 @@ private class LoggerSObjectProxy_Tests { // No need to fail the test if there isn't a LoginHistory record available via querying return; } - LoginHistory loginHistoryRecord = loginHistoryRecords.get(0); + Schema.LoginHistory loginHistoryRecord = loginHistoryRecords.get(0); LoggerSObjectProxy.LoginHistory loginHistoryProxy = new LoggerSObjectProxy.LoginHistory(loginHistoryRecord); diff --git a/nebula-logger/core/tests/logger-engine/classes/LoggerTriggerableContext_Tests.cls b/nebula-logger/core/tests/logger-engine/classes/LoggerTriggerableContext_Tests.cls index 45c00d829..9e5fc7443 100644 --- a/nebula-logger/core/tests/logger-engine/classes/LoggerTriggerableContext_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/LoggerTriggerableContext_Tests.cls @@ -6,7 +6,7 @@ /** * @description Test class for LoggerTriggerableContext, part of the trigger-handler framework used by Nebula Logger. * To demonstrate that the framework is standalone/would work with any SObject, these test methods - * all use mock records for the User SObject + * all use mock records for the Schema.User SObject */ @SuppressWarnings('PMD.MethodNamingConventions') @IsTest(IsParallel=true) @@ -19,9 +19,9 @@ private class LoggerTriggerableContext_Tests { static void it_constructs_instance_when_before_insert_operation() { Schema.SObjectType sobjectType = Schema.User.SObjectType; TriggerOperation triggerOperationType = TriggerOperation.BEFORE_INSERT; - List newUsers = new List(); + List newUsers = new List(); for (Integer i = 0; i < 3; i++) { - newUsers.add((User) LoggerMockDataCreator.createUser()); + newUsers.add((Schema.User) LoggerMockDataCreator.createUser()); } LoggerTriggerableContext context = new LoggerTriggerableContext(sobjectType, triggerOperationType, newUsers, null, null); @@ -43,14 +43,14 @@ private class LoggerTriggerableContext_Tests { static void it_constructs_instance_when_before_update_operation() { Schema.SObjectType sobjectType = Schema.User.SObjectType; TriggerOperation triggerOperationType = TriggerOperation.BEFORE_UPDATE; - List updatedUsers = new List(); + List updatedUsers = new List(); for (Integer i = 0; i < 3; i++) { - User user = (User) LoggerMockDataCreator.createUser(); + Schema.User user = (Schema.User) LoggerMockDataCreator.createUser(); user.Id = LoggerMockDataCreator.createId(Schema.User.SObjectType); updatedUsers.add(user); } - Map newUsersMap = new Map(updatedUsers.clone()); - Map oldUsersMap = new Map(updatedUsers.clone()); + Map newUsersMap = new Map(updatedUsers.clone()); + Map oldUsersMap = new Map(updatedUsers.clone()); LoggerTriggerableContext context = new LoggerTriggerableContext(sobjectType, triggerOperationType, updatedUsers, newUsersMap, oldUsersMap); @@ -62,7 +62,7 @@ private class LoggerTriggerableContext_Tests { System.Assert.areEqual(oldUsersMap, context.triggerOldMap); System.Assert.areEqual(updatedUsers.size(), context.triggerRecords.size()); for (Integer i = 0; i < updatedUsers.size(); i++) { - User user = updatedUsers.get(i); + Schema.User user = updatedUsers.get(i); System.Assert.areEqual(user, context.triggerRecords.get(i).triggerRecordNew); System.Assert.areEqual(oldUsersMap.get(user.Id), context.triggerRecords.get(i).triggerRecordOld); } @@ -72,9 +72,9 @@ private class LoggerTriggerableContext_Tests { static void it_constructs_instance_when_before_delete_operation() { Schema.SObjectType sobjectType = Schema.User.SObjectType; TriggerOperation triggerOperationType = TriggerOperation.BEFORE_DELETE; - Map deletedLogsMap = new Map(); + Map deletedLogsMap = new Map(); for (Integer i = 0; i < 3; i++) { - User user = (User) LoggerMockDataCreator.createDataBuilder(sobjectType).populateMockId().populateRequiredFields().getRecord(); + Schema.User user = (Schema.User) LoggerMockDataCreator.createDataBuilder(sobjectType).populateMockId().populateRequiredFields().getRecord(); user.Id = LoggerMockDataCreator.createId(Schema.User.SObjectType); deletedLogsMap.put(user.Id, user); } @@ -89,7 +89,7 @@ private class LoggerTriggerableContext_Tests { System.Assert.areEqual(deletedLogsMap, context.triggerOldMap); System.Assert.areEqual(deletedLogsMap.size(), context.triggerRecords.size()); for (Integer i = 0; i < deletedLogsMap.size(); i++) { - User deletedLog = deletedLogsMap.values().get(i); + Schema.User deletedLog = deletedLogsMap.values().get(i); System.Assert.isNull(context.triggerRecords.get(i).triggerRecordNew); System.Assert.areEqual(deletedLog, context.triggerRecords.get(i).triggerRecordOld); } diff --git a/nebula-logger/core/tests/logger-engine/classes/Logger_Tests.cls b/nebula-logger/core/tests/logger-engine/classes/Logger_Tests.cls index d9782f28e..6fc293e3f 100644 --- a/nebula-logger/core/tests/logger-engine/classes/Logger_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/Logger_Tests.cls @@ -27,7 +27,7 @@ private class Logger_Tests { @IsTest static void it_should_return_organization_api_version() { - String userJson = JSON.serialize(new User(Id = System.UserInfo.getUserId())); + String userJson = JSON.serialize(new Schema.User(Id = System.UserInfo.getUserId())); String expectedApiVersion = userJson.substringAfter('/data/').substringBefore('/sobjects/User'); String returnedApiVersion = Logger.getOrganizationApiVersion(); @@ -953,8 +953,8 @@ private class Logger_Tests { static void it_should_save_accurate_timestamp_when_logging_user_has_different_time_zone() { // TODO Move this test to LogEntryEventBuilder_Tests String automatedProcessUsername = 'autoproc@' + System.UserInfo.getOrganizationId(); - User automatedProcessUser = [SELECT Id, TimeZoneSidKey FROM User WHERE Username = :automatedProcessUsername AND Profile.Name = NULL]; - User currentUser = new User(Id = System.UserInfo.getUserId()); + Schema.User automatedProcessUser = [SELECT Id, TimeZoneSidKey FROM User WHERE Username = :automatedProcessUsername AND Profile.Name = NULL]; + Schema.User currentUser = new Schema.User(Id = System.UserInfo.getUserId()); // Make sure that the test user has a different time zone from the automated process user if (automatedProcessUser.TimeZoneSidKey == currentUser.TimeZoneSidKey) { switch on automatedProcessUser.TimeZoneSidKey { @@ -1545,7 +1545,7 @@ private class Logger_Tests { System.Assert.areEqual(0, Logger.getBufferSize()); System.Assert.areEqual(0, LoggerMockDataStore.getEventBus().getPublishedPlatformEvents().size()); LogMessage logMessage = getLogMessage(); - User record = new User(Id = System.UserInfo.getUserId()); + Schema.User record = new Schema.User(Id = System.UserInfo.getUserId()); System.Exception apexException = new System.DmlException('oops, some DML broke'); System.Exception thrownException; @@ -1573,7 +1573,7 @@ private class Logger_Tests { System.Assert.areEqual(0, Logger.getBufferSize()); System.Assert.areEqual(0, LoggerMockDataStore.getEventBus().getPublishedPlatformEvents().size()); LogMessage logMessage = getLogMessage(); - List records = new List{ new User(Id = System.UserInfo.getUserId()) }; + List records = new List{ new Schema.User(Id = System.UserInfo.getUserId()) }; System.Exception apexException = new System.DmlException('oops, some DML broke'); System.Exception thrownException; @@ -1655,7 +1655,7 @@ private class Logger_Tests { System.Assert.areEqual(0, Logger.getBufferSize()); System.Assert.areEqual(0, LoggerMockDataStore.getEventBus().getPublishedPlatformEvents().size()); String message = 'Something broke 😥'; - User record = new User(Id = System.UserInfo.getUserId()); + Schema.User record = new Schema.User(Id = System.UserInfo.getUserId()); System.Exception apexException = new System.DmlException('oops, some DML broke'); System.Exception thrownException; @@ -1683,7 +1683,7 @@ private class Logger_Tests { System.Assert.areEqual(0, Logger.getBufferSize()); System.Assert.areEqual(0, LoggerMockDataStore.getEventBus().getPublishedPlatformEvents().size()); String message = 'Something broke 😥'; - List records = new List{ new User(Id = System.UserInfo.getUserId()) }; + List records = new List{ new Schema.User(Id = System.UserInfo.getUserId()) }; System.Exception apexException = new System.DmlException('oops, some DML broke'); System.Exception thrownException; @@ -2209,7 +2209,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.error(getLogMessage(), users, getException()); System.Test.stopTest(); @@ -2232,7 +2232,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.error(getLogMessage(), users); System.Test.stopTest(); @@ -2773,7 +2773,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.error(getMessage(), users, getException()); System.Test.stopTest(); @@ -2796,7 +2796,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.error(getMessage(), users); System.Test.stopTest(); @@ -3240,7 +3240,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.warn(getLogMessage(), users, getException()); System.Test.stopTest(); @@ -3263,7 +3263,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.warn(getLogMessage(), users); System.Test.stopTest(); @@ -3708,7 +3708,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.warn(getMessage(), users, getException()); System.Test.stopTest(); @@ -3731,7 +3731,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.warn(getMessage(), users); System.Test.stopTest(); @@ -4062,7 +4062,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.info(getLogMessage(), users); System.Test.stopTest(); @@ -4393,7 +4393,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.info(getMessage(), users); System.Test.stopTest(); @@ -4724,7 +4724,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.debug(getLogMessage(), users); System.Test.stopTest(); @@ -5055,7 +5055,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.debug(getMessage(), users); System.Test.stopTest(); @@ -5386,7 +5386,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.fine(getLogMessage(), users); System.Test.stopTest(); @@ -5717,7 +5717,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.fine(getMessage(), users); System.Test.stopTest(); @@ -6048,7 +6048,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.finer(getLogMessage(), users); System.Test.stopTest(); @@ -6379,7 +6379,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.finer(getMessage(), users); System.Test.stopTest(); @@ -6710,7 +6710,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.finest(getLogMessage(), users); System.Test.stopTest(); @@ -7041,7 +7041,7 @@ private class Logger_Tests { System.Test.startTest(); - List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; + List users = [SELECT Id, Name, Username, IsActive FROM User LIMIT 5]; LogEntryEventBuilder entryBuilder = Logger.finest(getMessage(), users); System.Test.stopTest(); @@ -7942,7 +7942,7 @@ private class Logger_Tests { LogEntryEvent__e logEntryEvent = (LogEntryEvent__e) LoggerMockDataStore.getEventBus().getPublishedPlatformEvents().get(0); System.Assert.areEqual('Callout to api.status.salesforce.com failed', logEntryEvent.Message__c); System.Assert.areEqual('System.CalloutException', logEntryEvent.ExceptionType__c); - Organization organization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); + Schema.Organization organization = LoggerEngineDataSelector.getInstance().getCachedOrganization(); String expectedExceptionMessage = 'Callout failed for https://api.status.salesforce.com/v1/instances/' + organization.InstanceName + @@ -7979,7 +7979,7 @@ private class Logger_Tests { } static SObject getRecord() { - return new User( + return new Schema.User( Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId(), Username = System.UserInfo.getUsername(), diff --git a/nebula-logger/extra-tests/classes/NebulaLogger_E2E_Tests.cls b/nebula-logger/extra-tests/classes/NebulaLogger_E2E_Tests.cls index 987498553..098d712b9 100644 --- a/nebula-logger/extra-tests/classes/NebulaLogger_E2E_Tests.cls +++ b/nebula-logger/extra-tests/classes/NebulaLogger_E2E_Tests.cls @@ -152,8 +152,8 @@ private class NebulaLogger_E2E_Tests { // Serializing any SObject w/ an ID will include the API version // So, use System.UserInfo.getUserId() to create the current user's record without querying // Then parse the JSON to get the API version - // Expected JSON: {"attributes":{"type":"User","url":"/services/data/v53.0/sobjects/User/005J000000AugnYIAR"} - String userJson = JSON.serialize(new User(Id = System.UserInfo.getUserId())); + // Expected JSON: {"attributes":{"type":"Schema.User","url":"/services/data/v53.0/sobjects/Schema.User/005J000000AugnYIAR"} + String userJson = JSON.serialize(new Schema.User(Id = System.UserInfo.getUserId())); return userJson.substringAfter('/data/').substringBefore('/sobjects/User'); } diff --git a/nebula-logger/extra-tests/classes/AccessType.cls b/nebula-logger/extra-tests/classes/name-shadowing/AccessType.cls similarity index 100% rename from nebula-logger/extra-tests/classes/AccessType.cls rename to nebula-logger/extra-tests/classes/name-shadowing/AccessType.cls diff --git a/nebula-logger/extra-tests/classes/AccessType.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/AccessType.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/AccessType.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/AccessType.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/name-shadowing/Account.cls b/nebula-logger/extra-tests/classes/name-shadowing/Account.cls new file mode 100644 index 000000000..6f2a4c029 --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/Account.cls @@ -0,0 +1,10 @@ +//------------------------------------------------------------------------------------------------// +// This file is part of the Nebula Logger project, released under the MIT License. // +// See LICENSE file or go to https://github.com/jongpie/NebulaLogger for full license details. // +//------------------------------------------------------------------------------------------------// + +// This class intentionally does nothing - it's here to ensure that any references +// in Nebula Logger's codebase use `Schema.Account` instead of just `Account` +@SuppressWarnings('PMD.ApexDoc, PMD.EmptyStatementBlock') +public without sharing class Account { +} diff --git a/nebula-logger/extra-tests/classes/Assert.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/Account.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/Assert.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/Account.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/Assert.cls b/nebula-logger/extra-tests/classes/name-shadowing/Assert.cls similarity index 100% rename from nebula-logger/extra-tests/classes/Assert.cls rename to nebula-logger/extra-tests/classes/name-shadowing/Assert.cls diff --git a/nebula-logger/extra-tests/classes/AuraHandledException.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/Assert.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/AuraHandledException.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/Assert.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/AuraHandledException.cls b/nebula-logger/extra-tests/classes/name-shadowing/AuraHandledException.cls similarity index 100% rename from nebula-logger/extra-tests/classes/AuraHandledException.cls rename to nebula-logger/extra-tests/classes/name-shadowing/AuraHandledException.cls diff --git a/nebula-logger/extra-tests/classes/CalloutException.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/AuraHandledException.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/CalloutException.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/AuraHandledException.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/name-shadowing/AuthSession.cls b/nebula-logger/extra-tests/classes/name-shadowing/AuthSession.cls new file mode 100644 index 000000000..882d5aa67 --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/AuthSession.cls @@ -0,0 +1,10 @@ +//------------------------------------------------------------------------------------------------// +// This file is part of the Nebula Logger project, released under the MIT License. // +// See LICENSE file or go to https://github.com/jongpie/NebulaLogger for full license details. // +//------------------------------------------------------------------------------------------------// + +// This class intentionally does nothing - it's here to ensure that any references +// in Nebula Logger's codebase use `Schema.AuthSession` instead of just `AuthSession` +@SuppressWarnings('PMD.ApexDoc, PMD.EmptyStatementBlock') +public without sharing class AuthSession { +} diff --git a/nebula-logger/extra-tests/classes/DmlException.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/AuthSession.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/DmlException.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/AuthSession.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/CalloutException.cls b/nebula-logger/extra-tests/classes/name-shadowing/CalloutException.cls similarity index 100% rename from nebula-logger/extra-tests/classes/CalloutException.cls rename to nebula-logger/extra-tests/classes/name-shadowing/CalloutException.cls diff --git a/nebula-logger/extra-tests/classes/FeatureManagement.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/CalloutException.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/FeatureManagement.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/CalloutException.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/DmlException.cls b/nebula-logger/extra-tests/classes/name-shadowing/DmlException.cls similarity index 100% rename from nebula-logger/extra-tests/classes/DmlException.cls rename to nebula-logger/extra-tests/classes/name-shadowing/DmlException.cls diff --git a/nebula-logger/extra-tests/classes/FieldSet.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/DmlException.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/FieldSet.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/DmlException.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/FeatureManagement.cls b/nebula-logger/extra-tests/classes/name-shadowing/FeatureManagement.cls similarity index 100% rename from nebula-logger/extra-tests/classes/FeatureManagement.cls rename to nebula-logger/extra-tests/classes/name-shadowing/FeatureManagement.cls diff --git a/nebula-logger/extra-tests/classes/FieldSetMember.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/FeatureManagement.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/FieldSetMember.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/FeatureManagement.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/FieldSet.cls b/nebula-logger/extra-tests/classes/name-shadowing/FieldSet.cls similarity index 100% rename from nebula-logger/extra-tests/classes/FieldSet.cls rename to nebula-logger/extra-tests/classes/name-shadowing/FieldSet.cls diff --git a/nebula-logger/extra-tests/classes/Http.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/FieldSet.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/Http.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/FieldSet.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/FieldSetMember.cls b/nebula-logger/extra-tests/classes/name-shadowing/FieldSetMember.cls similarity index 100% rename from nebula-logger/extra-tests/classes/FieldSetMember.cls rename to nebula-logger/extra-tests/classes/name-shadowing/FieldSetMember.cls diff --git a/nebula-logger/extra-tests/classes/HttpCalloutMock.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/FieldSetMember.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/HttpCalloutMock.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/FieldSetMember.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/Http.cls b/nebula-logger/extra-tests/classes/name-shadowing/Http.cls similarity index 100% rename from nebula-logger/extra-tests/classes/Http.cls rename to nebula-logger/extra-tests/classes/name-shadowing/Http.cls diff --git a/nebula-logger/extra-tests/classes/HttpRequest.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/Http.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/HttpRequest.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/Http.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/HttpCalloutMock.cls b/nebula-logger/extra-tests/classes/name-shadowing/HttpCalloutMock.cls similarity index 100% rename from nebula-logger/extra-tests/classes/HttpCalloutMock.cls rename to nebula-logger/extra-tests/classes/name-shadowing/HttpCalloutMock.cls diff --git a/nebula-logger/extra-tests/classes/HttpResponse.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/HttpCalloutMock.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/HttpResponse.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/HttpCalloutMock.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/HttpRequest.cls b/nebula-logger/extra-tests/classes/name-shadowing/HttpRequest.cls similarity index 100% rename from nebula-logger/extra-tests/classes/HttpRequest.cls rename to nebula-logger/extra-tests/classes/name-shadowing/HttpRequest.cls diff --git a/nebula-logger/extra-tests/classes/IllegalArgumentException.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/HttpRequest.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/IllegalArgumentException.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/HttpRequest.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/HttpResponse.cls b/nebula-logger/extra-tests/classes/name-shadowing/HttpResponse.cls similarity index 100% rename from nebula-logger/extra-tests/classes/HttpResponse.cls rename to nebula-logger/extra-tests/classes/name-shadowing/HttpResponse.cls diff --git a/nebula-logger/extra-tests/classes/Limits.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/HttpResponse.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/Limits.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/HttpResponse.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/IllegalArgumentException.cls b/nebula-logger/extra-tests/classes/name-shadowing/IllegalArgumentException.cls similarity index 100% rename from nebula-logger/extra-tests/classes/IllegalArgumentException.cls rename to nebula-logger/extra-tests/classes/name-shadowing/IllegalArgumentException.cls diff --git a/nebula-logger/extra-tests/classes/LoggingLevel.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/IllegalArgumentException.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/LoggingLevel.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/IllegalArgumentException.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/Limits.cls b/nebula-logger/extra-tests/classes/name-shadowing/Limits.cls similarity index 100% rename from nebula-logger/extra-tests/classes/Limits.cls rename to nebula-logger/extra-tests/classes/name-shadowing/Limits.cls diff --git a/nebula-logger/extra-tests/classes/Network.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/Limits.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/Network.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/Limits.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/LoggingLevel.cls b/nebula-logger/extra-tests/classes/name-shadowing/LoggingLevel.cls similarity index 100% rename from nebula-logger/extra-tests/classes/LoggingLevel.cls rename to nebula-logger/extra-tests/classes/name-shadowing/LoggingLevel.cls diff --git a/nebula-logger/extra-tests/classes/SObjectAccessDecision.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/LoggingLevel.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/SObjectAccessDecision.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/LoggingLevel.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/name-shadowing/LoginHistory.cls b/nebula-logger/extra-tests/classes/name-shadowing/LoginHistory.cls new file mode 100644 index 000000000..f3bf37779 --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/LoginHistory.cls @@ -0,0 +1,10 @@ +//------------------------------------------------------------------------------------------------// +// This file is part of the Nebula Logger project, released under the MIT License. // +// See LICENSE file or go to https://github.com/jongpie/NebulaLogger for full license details. // +//------------------------------------------------------------------------------------------------// + +// This class intentionally does nothing - it's here to ensure that any references +// in Nebula Logger's codebase use `Schema.LoginHistory` instead of just `LoginHistory` +@SuppressWarnings('PMD.ApexDoc, PMD.EmptyStatementBlock') +public without sharing class LoginHistory { +} diff --git a/nebula-logger/extra-tests/classes/SObjectField.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/LoginHistory.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/SObjectField.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/LoginHistory.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/Network.cls b/nebula-logger/extra-tests/classes/name-shadowing/Network.cls similarity index 100% rename from nebula-logger/extra-tests/classes/Network.cls rename to nebula-logger/extra-tests/classes/name-shadowing/Network.cls diff --git a/nebula-logger/extra-tests/classes/SObjectType.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/Network.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/SObjectType.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/Network.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/name-shadowing/Organization.cls b/nebula-logger/extra-tests/classes/name-shadowing/Organization.cls new file mode 100644 index 000000000..1e2da9e82 --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/Organization.cls @@ -0,0 +1,10 @@ +//------------------------------------------------------------------------------------------------// +// This file is part of the Nebula Logger project, released under the MIT License. // +// See LICENSE file or go to https://github.com/jongpie/NebulaLogger for full license details. // +//------------------------------------------------------------------------------------------------// + +// This class intentionally does nothing - it's here to ensure that any references +// in Nebula Logger's codebase use `Schema.Organization` instead of just `Organization` +@SuppressWarnings('PMD.ApexDoc, PMD.EmptyStatementBlock') +public without sharing class Organization { +} diff --git a/nebula-logger/extra-tests/classes/Security.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/Organization.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/Security.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/Organization.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/name-shadowing/Profile.cls b/nebula-logger/extra-tests/classes/name-shadowing/Profile.cls new file mode 100644 index 000000000..38282da6d --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/Profile.cls @@ -0,0 +1,10 @@ +//------------------------------------------------------------------------------------------------// +// This file is part of the Nebula Logger project, released under the MIT License. // +// See LICENSE file or go to https://github.com/jongpie/NebulaLogger for full license details. // +//------------------------------------------------------------------------------------------------// + +// This class intentionally does nothing - it's here to ensure that any references +// in Nebula Logger's codebase use `Schema.Profile` instead of just `Schema.Profile` +@SuppressWarnings('PMD.ApexDoc, PMD.EmptyStatementBlock') +public without sharing class Profile { +} diff --git a/nebula-logger/extra-tests/classes/Test.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/Profile.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/Test.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/Profile.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/SObjectAccessDecision.cls b/nebula-logger/extra-tests/classes/name-shadowing/SObjectAccessDecision.cls similarity index 100% rename from nebula-logger/extra-tests/classes/SObjectAccessDecision.cls rename to nebula-logger/extra-tests/classes/name-shadowing/SObjectAccessDecision.cls diff --git a/nebula-logger/extra-tests/classes/Type.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/SObjectAccessDecision.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/Type.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/SObjectAccessDecision.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/SObjectField.cls b/nebula-logger/extra-tests/classes/name-shadowing/SObjectField.cls similarity index 100% rename from nebula-logger/extra-tests/classes/SObjectField.cls rename to nebula-logger/extra-tests/classes/name-shadowing/SObjectField.cls diff --git a/nebula-logger/extra-tests/classes/UserInfo.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/SObjectField.cls-meta.xml similarity index 100% rename from nebula-logger/extra-tests/classes/UserInfo.cls-meta.xml rename to nebula-logger/extra-tests/classes/name-shadowing/SObjectField.cls-meta.xml diff --git a/nebula-logger/extra-tests/classes/SObjectType.cls b/nebula-logger/extra-tests/classes/name-shadowing/SObjectType.cls similarity index 100% rename from nebula-logger/extra-tests/classes/SObjectType.cls rename to nebula-logger/extra-tests/classes/name-shadowing/SObjectType.cls diff --git a/nebula-logger/extra-tests/classes/name-shadowing/SObjectType.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/SObjectType.cls-meta.xml new file mode 100644 index 000000000..c14e405d4 --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/SObjectType.cls-meta.xml @@ -0,0 +1,5 @@ + + + 59.0 + Active + diff --git a/nebula-logger/extra-tests/classes/Security.cls b/nebula-logger/extra-tests/classes/name-shadowing/Security.cls similarity index 100% rename from nebula-logger/extra-tests/classes/Security.cls rename to nebula-logger/extra-tests/classes/name-shadowing/Security.cls diff --git a/nebula-logger/extra-tests/classes/name-shadowing/Security.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/Security.cls-meta.xml new file mode 100644 index 000000000..c14e405d4 --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/Security.cls-meta.xml @@ -0,0 +1,5 @@ + + + 59.0 + Active + diff --git a/nebula-logger/extra-tests/classes/Test.cls b/nebula-logger/extra-tests/classes/name-shadowing/Test.cls similarity index 100% rename from nebula-logger/extra-tests/classes/Test.cls rename to nebula-logger/extra-tests/classes/name-shadowing/Test.cls diff --git a/nebula-logger/extra-tests/classes/name-shadowing/Test.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/Test.cls-meta.xml new file mode 100644 index 000000000..c14e405d4 --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/Test.cls-meta.xml @@ -0,0 +1,5 @@ + + + 59.0 + Active + diff --git a/nebula-logger/extra-tests/classes/name-shadowing/Topic.cls b/nebula-logger/extra-tests/classes/name-shadowing/Topic.cls new file mode 100644 index 000000000..5194d00f9 --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/Topic.cls @@ -0,0 +1,10 @@ +//------------------------------------------------------------------------------------------------// +// This file is part of the Nebula Logger project, released under the MIT License. // +// See LICENSE file or go to https://github.com/jongpie/NebulaLogger for full license details. // +//------------------------------------------------------------------------------------------------// + +// This class intentionally does nothing - it's here to ensure that any references +// in Nebula Logger's codebase use `Schema.Topic` instead of just `Schema.Topic` +@SuppressWarnings('PMD.ApexDoc, PMD.EmptyStatementBlock') +public without sharing class Topic { +} diff --git a/nebula-logger/extra-tests/classes/name-shadowing/Topic.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/Topic.cls-meta.xml new file mode 100644 index 000000000..c14e405d4 --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/Topic.cls-meta.xml @@ -0,0 +1,5 @@ + + + 59.0 + Active + diff --git a/nebula-logger/extra-tests/classes/name-shadowing/TopicAssignment.cls b/nebula-logger/extra-tests/classes/name-shadowing/TopicAssignment.cls new file mode 100644 index 000000000..4ae2a0f95 --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/TopicAssignment.cls @@ -0,0 +1,10 @@ +//------------------------------------------------------------------------------------------------// +// This file is part of the Nebula Logger project, released under the MIT License. // +// See LICENSE file or go to https://github.com/jongpie/NebulaLogger for full license details. // +//------------------------------------------------------------------------------------------------// + +// This class intentionally does nothing - it's here to ensure that any references +// in Nebula Logger's codebase use `Schema.TopicAssignment` instead of just `Schema.TopicAssignment` +@SuppressWarnings('PMD.ApexDoc, PMD.EmptyStatementBlock') +public without sharing class TopicAssignment { +} diff --git a/nebula-logger/extra-tests/classes/name-shadowing/TopicAssignment.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/TopicAssignment.cls-meta.xml new file mode 100644 index 000000000..c14e405d4 --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/TopicAssignment.cls-meta.xml @@ -0,0 +1,5 @@ + + + 59.0 + Active + diff --git a/nebula-logger/extra-tests/classes/Type.cls b/nebula-logger/extra-tests/classes/name-shadowing/Type.cls similarity index 100% rename from nebula-logger/extra-tests/classes/Type.cls rename to nebula-logger/extra-tests/classes/name-shadowing/Type.cls diff --git a/nebula-logger/extra-tests/classes/name-shadowing/Type.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/Type.cls-meta.xml new file mode 100644 index 000000000..c14e405d4 --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/Type.cls-meta.xml @@ -0,0 +1,5 @@ + + + 59.0 + Active + diff --git a/nebula-logger/extra-tests/classes/name-shadowing/User.cls b/nebula-logger/extra-tests/classes/name-shadowing/User.cls new file mode 100644 index 000000000..69071efc7 --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/User.cls @@ -0,0 +1,10 @@ +//------------------------------------------------------------------------------------------------// +// This file is part of the Nebula Logger project, released under the MIT License. // +// See LICENSE file or go to https://github.com/jongpie/NebulaLogger for full license details. // +//------------------------------------------------------------------------------------------------// + +// This class intentionally does nothing - it's here to ensure that any references +// in Nebula Logger's codebase use `Schema.User` instead of just `User` +@SuppressWarnings('PMD.ApexDoc, PMD.EmptyStatementBlock') +public without sharing class User { +} diff --git a/nebula-logger/extra-tests/classes/name-shadowing/User.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/User.cls-meta.xml new file mode 100644 index 000000000..c14e405d4 --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/User.cls-meta.xml @@ -0,0 +1,5 @@ + + + 59.0 + Active + diff --git a/nebula-logger/extra-tests/classes/UserInfo.cls b/nebula-logger/extra-tests/classes/name-shadowing/UserInfo.cls similarity index 100% rename from nebula-logger/extra-tests/classes/UserInfo.cls rename to nebula-logger/extra-tests/classes/name-shadowing/UserInfo.cls diff --git a/nebula-logger/extra-tests/classes/name-shadowing/UserInfo.cls-meta.xml b/nebula-logger/extra-tests/classes/name-shadowing/UserInfo.cls-meta.xml new file mode 100644 index 000000000..c14e405d4 --- /dev/null +++ b/nebula-logger/extra-tests/classes/name-shadowing/UserInfo.cls-meta.xml @@ -0,0 +1,5 @@ + + + 59.0 + Active + diff --git a/nebula-logger/extra-tests/tests/LogBatchPurger_Tests_Database.cls b/nebula-logger/extra-tests/tests/LogBatchPurger_Tests_Database.cls index ae3a33e86..e6c3409f3 100644 --- a/nebula-logger/extra-tests/tests/LogBatchPurger_Tests_Database.cls +++ b/nebula-logger/extra-tests/tests/LogBatchPurger_Tests_Database.cls @@ -7,7 +7,7 @@ @IsTest(IsParallel=false) private class LogBatchPurger_Tests_Database { private static final Integer NUMBER_OF_LOG_ENTRIES = 10; - private static final Profile STANDARD_USER_PROFILE = [SELECT Id FROM Profile WHERE Name IN ('Standard User', 'Usuario estándar')]; + private static final Schema.Profile STANDARD_USER_PROFILE = [SELECT Id FROM Profile WHERE Name IN ('Standard User', 'Usuario estándar')]; @TestSetup static void setupData() { @@ -43,7 +43,7 @@ private class LogBatchPurger_Tests_Database { static void it_should_throw_exception_when_user_does_not_have_delete_access() { Integer originalCountOfLogEntries = [SELECT COUNT() FROM LogEntry__c]; - User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); + Schema.User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); System.runAs(standardUser) { System.Assert.isFalse(Schema.Log__c.SObjectType.getDescribe().isDeletable()); diff --git a/nebula-logger/extra-tests/tests/LogEntryEventBuilder_Tests_Network.cls b/nebula-logger/extra-tests/tests/LogEntryEventBuilder_Tests_Network.cls index 5e0ced750..c1e06b20c 100644 --- a/nebula-logger/extra-tests/tests/LogEntryEventBuilder_Tests_Network.cls +++ b/nebula-logger/extra-tests/tests/LogEntryEventBuilder_Tests_Network.cls @@ -20,7 +20,7 @@ private class LogEntryEventBuilder_Tests_Network { SObject networkRecord = getExperienceCloudNetwork(); System.Assert.isNotNull(networkRecord.Id); LogEntryEventBuilder.networkId = networkRecord.Id; - User experienceSiteUser = setupExperienceSiteUser(); + Schema.User experienceSiteUser = setupExperienceSiteUser(); LogEntryEvent__e logEntryEvent; System.runAs(experienceSiteUser) { @@ -47,7 +47,7 @@ private class LogEntryEventBuilder_Tests_Network { SObject networkRecord = getExperienceCloudNetwork(); System.Assert.isNotNull(networkRecord.Id); LogEntryEventBuilder.networkId = networkRecord.Id; - User experienceSiteUser = setupExperienceSiteUser(); + Schema.User experienceSiteUser = setupExperienceSiteUser(); LogEntryEvent__e logEntryEvent; System.runAs(experienceSiteUser) { @@ -71,14 +71,14 @@ private class LogEntryEventBuilder_Tests_Network { return userSettings; } - static User setupExperienceSiteUser() { + static Schema.User setupExperienceSiteUser() { UserRole userRole = new UserRole(DeveloperName = 'LoggerTestRole', Name = 'Logger Test Role'); insert userRole; - User currentUser = new User(Id = System.UserInfo.getUserId(), UserRoleId = userRole.Id); + Schema.User currentUser = new Schema.User(Id = System.UserInfo.getUserId(), UserRoleId = userRole.Id); update currentUser; - User experienceSiteUser; + Schema.User experienceSiteUser; System.runAs(currentUser) { - Account account = new Account(Name = 'Test Account', OwnerId = currentUser.Id); + Schema.Account account = new Schema.Account(Name = 'Test Account', OwnerId = currentUser.Id); insert account; Contact contact = new Contact(AccountId = account.Id, LastName = 'testcontact'); insert contact; diff --git a/nebula-logger/extra-tests/tests/LogEntryEventBuilder_Tests_Security.cls b/nebula-logger/extra-tests/tests/LogEntryEventBuilder_Tests_Security.cls index b4f6d825b..bb252bd28 100644 --- a/nebula-logger/extra-tests/tests/LogEntryEventBuilder_Tests_Security.cls +++ b/nebula-logger/extra-tests/tests/LogEntryEventBuilder_Tests_Security.cls @@ -6,11 +6,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions, PMD.NcssMethodCount') @IsTest(IsParallel=false) private class LogEntryEventBuilder_Tests_Security { - private static final Profile STANDARD_USER_PROFILE = [SELECT Id FROM Profile WHERE Name IN ('Standard User', 'Usuario estándar')]; + private static final Schema.Profile STANDARD_USER_PROFILE = [SELECT Id FROM Profile WHERE Name IN ('Standard User', 'Usuario estándar')]; @IsTest static void it_should_strip_inaccessible_fields_for_single_record_when_enabled() { - User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); + Schema.User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); AccountBrand mockAccountBrand = (AccountBrand) LoggerMockDataCreator.createDataBuilder(Schema.AccountBrand.SObjectType) .populateMockId() .populateRequiredFields() @@ -50,7 +50,7 @@ private class LogEntryEventBuilder_Tests_Security { @IsTest static void it_should_strip_inaccessible_fields_for_record_list_when_enabled() { - User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); + Schema.User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); List mockAccountBrands = new List(); List strippedAccountBrands = new List(); for (Integer i = 0; i < 5; i++) { @@ -89,7 +89,7 @@ private class LogEntryEventBuilder_Tests_Security { @IsTest static void it_should_strip_inaccessible_fields_for_record_map_when_enabled() { - User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); + Schema.User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); Map mockIdToAccountBrand = new Map(); Map mockIdStringToStrippedAccountBrand = new Map(); for (Integer i = 0; i < 5; i++) { diff --git a/nebula-logger/extra-tests/tests/LoggerCache_Tests_PlatformCache.cls b/nebula-logger/extra-tests/tests/LoggerCache_Tests_PlatformCache.cls index 66f7d37f0..bc697e43e 100644 --- a/nebula-logger/extra-tests/tests/LoggerCache_Tests_PlatformCache.cls +++ b/nebula-logger/extra-tests/tests/LoggerCache_Tests_PlatformCache.cls @@ -102,7 +102,7 @@ private class LoggerCache_Tests_PlatformCache { @IsTest static void it_adds_new_key_to_organization_and_transaction_cache() { String mockKey = 'SomeKey'; - User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User mockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); System.Assert.isFalse(LoggerCache.getOrganizationCache().contains(mockKey)); System.Assert.isFalse(LoggerCache.getTransactionCache().contains(mockKey)); @@ -119,7 +119,7 @@ private class LoggerCache_Tests_PlatformCache { @IsTest static void it_adds_new_key_with_null_value_to_organization_and_transaction_cache() { String mockKey = 'SomeKey'; - User mockValue = null; + Schema.User mockValue = null; System.Assert.isFalse(LoggerCache.getOrganizationCache().contains(mockKey)); System.Assert.isFalse(LoggerCache.getTransactionCache().contains(mockKey)); @@ -136,13 +136,13 @@ private class LoggerCache_Tests_PlatformCache { @IsTest static void it_updates_value_for_existing_key_in_organization_and_transaction_cache() { String mockKey = 'SomeKey'; - User oldMockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User oldMockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); LoggerCache.getOrganizationCache().put(mockKey, oldMockValue); System.Assert.isTrue(LoggerCache.getOrganizationCache().contains(mockKey)); System.Assert.areEqual(oldMockValue, LoggerCache.getOrganizationCache().get(mockKey)); System.Assert.isTrue(LoggerCache.getTransactionCache().contains(mockKey)); System.Assert.areEqual(oldMockValue, LoggerCache.getTransactionCache().get(mockKey)); - Account newMockValue = new Account(Name = 'Some fake account'); + Schema.Account newMockValue = new Schema.Account(Name = 'Some fake account'); LoggerCache.getOrganizationCache().put(mockKey, newMockValue); @@ -157,7 +157,7 @@ private class LoggerCache_Tests_PlatformCache { @IsTest static void it_removes_value_for_existing_key_in_organization_and_transaction_cache() { String mockKey = 'SomeKey'; - User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User mockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); System.Assert.isFalse(LoggerCache.getOrganizationCache().contains(mockKey)); System.Assert.isFalse(LoggerCache.getTransactionCache().contains(mockKey)); LoggerCache.getOrganizationCache().put(mockKey, mockValue); @@ -178,7 +178,7 @@ private class LoggerCache_Tests_PlatformCache { @IsTest static void it_adds_new_key_to_session_and_transaction_cache() { String mockKey = 'SomeKey'; - User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User mockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); System.Assert.isFalse(LoggerCache.getSessionCache().contains(mockKey)); System.Assert.isFalse(LoggerCache.getTransactionCache().contains(mockKey)); @@ -199,7 +199,7 @@ private class LoggerCache_Tests_PlatformCache { @IsTest static void it_adds_new_key_with_null_value_to_session_and_transaction_cache() { String mockKey = 'SomeKey'; - User mockValue = null; + Schema.User mockValue = null; System.Assert.isFalse(LoggerCache.getSessionCache().contains(mockKey)); System.Assert.isFalse(LoggerCache.getTransactionCache().contains(mockKey)); @@ -220,13 +220,13 @@ private class LoggerCache_Tests_PlatformCache { @IsTest static void it_updates_value_for_existing_key_in_session_and_transaction_cache() { String mockKey = 'SomeKey'; - User oldMockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User oldMockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); LoggerCache.getSessionCache().put(mockKey, oldMockValue); System.Assert.isTrue(LoggerCache.getSessionCache().contains(mockKey)); System.Assert.areEqual(oldMockValue, LoggerCache.getSessionCache().get(mockKey)); System.Assert.isTrue(LoggerCache.getTransactionCache().contains(mockKey)); System.Assert.areEqual(oldMockValue, LoggerCache.getTransactionCache().get(mockKey)); - Account newMockValue = new Account(Name = 'Some fake account'); + Schema.Account newMockValue = new Schema.Account(Name = 'Some fake account'); LoggerCache.getSessionCache().put(mockKey, newMockValue); @@ -245,7 +245,7 @@ private class LoggerCache_Tests_PlatformCache { @IsTest static void it_removes_value_for_existing_key_in_session_and_transaction_cache() { String mockKey = 'SomeKey'; - User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); + Schema.User mockValue = new Schema.User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); System.Assert.isFalse(LoggerCache.getSessionCache().contains(mockKey)); System.Assert.isFalse(LoggerCache.getTransactionCache().contains(mockKey)); LoggerCache.getSessionCache().put(mockKey, mockValue); diff --git a/nebula-logger/extra-tests/tests/LoggerSettingsController_Tests_Security.cls b/nebula-logger/extra-tests/tests/LoggerSettingsController_Tests_Security.cls index c599b98c0..20ee87c0f 100644 --- a/nebula-logger/extra-tests/tests/LoggerSettingsController_Tests_Security.cls +++ b/nebula-logger/extra-tests/tests/LoggerSettingsController_Tests_Security.cls @@ -7,11 +7,11 @@ @IsTest(IsParallel=false) private class LoggerSettingsController_Tests_Security { private static final String CAN_MODIFY_LOGGER_SETTINGS_PERMISSION_NAME = 'CanModifyLoggerSettings'; - private static final Profile STANDARD_USER_PROFILE = [SELECT Id FROM Profile WHERE Name IN ('Standard User', 'Usuario estándar')]; + private static final Schema.Profile STANDARD_USER_PROFILE = [SELECT Id FROM Profile WHERE Name IN ('Standard User', 'Usuario estándar')]; @IsTest static void it_should_permit_user_to_modify_logger_settings_when_custom_permission_is_assigned() { - User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); + Schema.User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); insert standardUser; PermissionSet permissionSet = new PermissionSet(Name = 'CustomPermissionEnabled', Label = 'Custom Permisison Enabled'); insert permissionSet; @@ -34,7 +34,7 @@ private class LoggerSettingsController_Tests_Security { @IsTest static void it_should_permit_user_to_modify_logger_settings_when_loggerAdmin_permission_set_is_assigned() { - User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); + Schema.User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); insert standardUser; LoggerTestConfigurator.assignAdminPermissionSet(standardUser.Id); @@ -46,7 +46,7 @@ private class LoggerSettingsController_Tests_Security { @IsTest static void it_should_not_permit_user_to_modify_logger_settings_when_loggerLogViewer_permission_set_is_assigned() { - User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); + Schema.User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); insert standardUser; LoggerTestConfigurator.assignLogViewerPermissionSet(standardUser.Id); @@ -58,7 +58,7 @@ private class LoggerSettingsController_Tests_Security { @IsTest static void it_should_not_permit_user_to_modify_logger_settings_when_loggerEndUser_permission_set_is_assigned() { - User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); + Schema.User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); insert standardUser; LoggerTestConfigurator.assignEndUserPermissionSet(standardUser.Id); @@ -70,7 +70,7 @@ private class LoggerSettingsController_Tests_Security { @IsTest static void it_should_not_permit_user_to_modify_logger_settings_when_loggerLogCreator_permission_set_is_assigned() { - User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); + Schema.User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); insert standardUser; LoggerTestConfigurator.assignLogCreatorPermissionSet(standardUser.Id); @@ -82,7 +82,7 @@ private class LoggerSettingsController_Tests_Security { @IsTest static void it_should_not_permit_user_to_modify_logger_settings_when_custom_permission_is_not_assigned() { - User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); + Schema.User standardUser = LoggerMockDataCreator.createUser(STANDARD_USER_PROFILE.Id); System.runAs(standardUser) { System.Assert.isFalse(LoggerSettingsController.canUserModifyLoggerSettings()); } diff --git a/nebula-logger/extra-tests/tests/Logger_Tests_Network.cls b/nebula-logger/extra-tests/tests/Logger_Tests_Network.cls index e493dfa49..c3be91327 100644 --- a/nebula-logger/extra-tests/tests/Logger_Tests_Network.cls +++ b/nebula-logger/extra-tests/tests/Logger_Tests_Network.cls @@ -17,22 +17,26 @@ private class Logger_Tests_Network { return; } - List matchingProfiles = [SELECT Id, UserLicense.Name FROM Profile WHERE Name = :EXPERIENCE_CLOUD_GUEST_PROFILE_NAME]; + List matchingProfiles = [SELECT Id, UserLicense.Name FROM Profile WHERE Name = :EXPERIENCE_CLOUD_GUEST_PROFILE_NAME]; if (matchingProfiles.isEmpty()) { return; } - Profile loggerSiteProfile = matchingProfiles.get(0); + Schema.Profile loggerSiteProfile = matchingProfiles.get(0); System.Assert.areEqual('Guest User License', loggerSiteProfile.UserLicense.Name, 'User license did not match Guest User License.'); // Even if Experience Cloud is enabled, the expected test site might not exist, so exit early if the guest user cannot be found - List guestUsers = [SELECT Id FROM User WHERE Profile.Name = :EXPERIENCE_CLOUD_GUEST_PROFILE_NAME AND Profile.UserType = :GUEST_USER_TYPE]; + List guestUsers = [ + SELECT Id + FROM User + WHERE Profile.Name = :EXPERIENCE_CLOUD_GUEST_PROFILE_NAME AND Profile.UserType = :GUEST_USER_TYPE + ]; if (guestUsers.isEmpty()) { return; } - User guestUser = guestUsers.get(0); + Schema.User guestUser = guestUsers.get(0); LoggerTestConfigurator.assignLogCreatorPermissionSet(guestUser.Id); } @@ -49,12 +53,16 @@ private class Logger_Tests_Network { System.Test.startTest(); // Even if Experience Cloud is enabled, the expected test site might not exist, so exit early if the guest user cannot be found - List guestUsers = [SELECT Id FROM User WHERE Profile.Name = :EXPERIENCE_CLOUD_GUEST_PROFILE_NAME AND Profile.UserType = :GUEST_USER_TYPE]; + List guestUsers = [ + SELECT Id + FROM User + WHERE Profile.Name = :EXPERIENCE_CLOUD_GUEST_PROFILE_NAME AND Profile.UserType = :GUEST_USER_TYPE + ]; if (guestUsers.isEmpty()) { return; } - User guestUser = guestUsers.get(0); + Schema.User guestUser = guestUsers.get(0); try { log.OwnerId = guestUser.Id; update log; @@ -74,7 +82,7 @@ private class Logger_Tests_Network { } // Even if Experience Cloud is enabled, the expected test site might not exist, so exit early if the guest user cannot be found - List guestUsers = [ + List guestUsers = [ SELECT Id, Profile.UserType FROM User WHERE Profile.Name = :EXPERIENCE_CLOUD_GUEST_PROFILE_NAME AND Profile.UserType = :GUEST_USER_TYPE @@ -83,7 +91,7 @@ private class Logger_Tests_Network { return; } - User guestUser = guestUsers.get(0); + Schema.User guestUser = guestUsers.get(0); String message = 'testing logging as a guest user'; System.runAs(guestUser) { diff --git a/nebula-logger/plugins/async-failure-additions/plugin/classes/LogFlowExecutionErrorEventHandler.cls b/nebula-logger/plugins/async-failure-additions/plugin/classes/LogFlowExecutionErrorEventHandler.cls index b19df69e1..84b6c3681 100644 --- a/nebula-logger/plugins/async-failure-additions/plugin/classes/LogFlowExecutionErrorEventHandler.cls +++ b/nebula-logger/plugins/async-failure-additions/plugin/classes/LogFlowExecutionErrorEventHandler.cls @@ -53,8 +53,8 @@ public without sharing class LogFlowExecutionErrorEventHandler { @SuppressWarnings('PMD.ApexCrudViolation') private static void overrideUserInfo(Map> usernameToBuilders) { - Map usernameToUser = new Map(); - for (User user : [ + Map usernameToUser = new Map(); + for (Schema.User user : [ SELECT Id, ProfileId, @@ -74,11 +74,11 @@ public without sharing class LogFlowExecutionErrorEventHandler { } for (String username : usernameToBuilders.keySet()) { List builders = usernameToBuilders.get(username); - User loggingUser = usernameToUser.get(username); + Schema.User loggingUser = usernameToUser.get(username); TimeZone tz = Timezone.getTimeZone(loggingUser.TimeZoneSidKey); for (LogEntryEventBuilder builder : builders) { LogEntryEvent__e logEntryEvent = builder.getLogEntryEvent(); - // override User-level fields + // override Schema.User-level fields logEntryEvent.LoggedById__c = loggingUser.Id; logEntryEvent.LoggedByUsername__c = loggingUser.Username; logEntryEvent.ProfileName__c = loggingUser.Profile.Name; diff --git a/nebula-logger/plugins/async-failure-additions/plugin/classes/LogFlowExecutionErrorEventHandler_Tests.cls b/nebula-logger/plugins/async-failure-additions/plugin/classes/LogFlowExecutionErrorEventHandler_Tests.cls index 4d60ae5e9..b49a20b46 100644 --- a/nebula-logger/plugins/async-failure-additions/plugin/classes/LogFlowExecutionErrorEventHandler_Tests.cls +++ b/nebula-logger/plugins/async-failure-additions/plugin/classes/LogFlowExecutionErrorEventHandler_Tests.cls @@ -26,7 +26,7 @@ private class LogFlowExecutionErrorEventHandler_Tests { flowExecutionErrorEvent.FlowVersionNumber = 1; flowExecutionErrorEvent.Username = System.UserInfo.getUserName(); - System.runAs(new User(Id = [SELECT Id FROM User WHERE Alias = 'autoproc'].Id)) { + System.runAs(new Schema.User(Id = [SELECT Id FROM User WHERE Alias = 'autoproc'].Id)) { System.Test.startTest(); LogFlowExecutionErrorEventHandler.logErrors(new List{ flowExecutionErrorEvent }); System.Test.stopTest(); @@ -76,7 +76,7 @@ private class LogFlowExecutionErrorEventHandler_Tests { System.Assert.areEqual(flowExecutionErrorEvent.EventDate, entry.Timestamp__c, 'Should take timestamp from flow error event'); // Log__c related asserts - User currentUser = [ + Schema.User currentUser = [ SELECT Id, ProfileId, diff --git a/nebula-logger/plugins/big-object-archiving/plugin/classes/LogEntryArchivePlugin.cls b/nebula-logger/plugins/big-object-archiving/plugin/classes/LogEntryArchivePlugin.cls index b90153d64..d5fc92a55 100644 --- a/nebula-logger/plugins/big-object-archiving/plugin/classes/LogEntryArchivePlugin.cls +++ b/nebula-logger/plugins/big-object-archiving/plugin/classes/LogEntryArchivePlugin.cls @@ -183,7 +183,7 @@ public without sharing class LogEntryArchivePlugin implements LoggerPlugin.Batch // as 'BIG_OBJECT' set as their storage location for platform events (DefaultPlatformEventStorageLocation__c) List logEntryEventsToSave = new List(); for (LogEntryEvent__e logEntryEvent : (List) input.triggerNew) { - User loggingUser = new User(Id = logEntryEvent.LoggedById__c, ProfileId = logEntryEvent.ProfileId__c); + Schema.User loggingUser = new Schema.User(Id = logEntryEvent.LoggedById__c, ProfileId = logEntryEvent.ProfileId__c); LoggerSettings__c loggingUserSettings = Logger.getUserSettings(loggingUser); if (loggingUserSettings.DefaultPlatformEventStorageLocation__c == BIG_OBJECT_STORAGE_LOCATION) { logEntryEventsToSave.add(logEntryEvent); diff --git a/nebula-logger/recipes/classes/Account_Batch_Logger_Example.cls b/nebula-logger/recipes/classes/Account_Batch_Logger_Example.cls index e84adfda3..aecc3189c 100644 --- a/nebula-logger/recipes/classes/Account_Batch_Logger_Example.cls +++ b/nebula-logger/recipes/classes/Account_Batch_Logger_Example.cls @@ -29,12 +29,12 @@ public with sharing class Account_Batch_Logger_Example implements Database.Batch * @param batchableContext The current batch job context. * @param scope The list of accounts for the particular batch job. */ - public void execute(Database.BatchableContext batchableContext, List scope) { + public void execute(Database.BatchableContext batchableContext, List scope) { // One-time call (per transaction) to set the parent log Logger.fine('this.originalTransactionId==' + this.originalTransactionId); Logger.setParentLogTransactionId(this.originalTransactionId); - for (Account account : scope) { + for (Schema.Account account : scope) { // TODO add your batch job's logic // Then log the result diff --git a/nebula-logger/recipes/triggers/Account_Trigger_Logger_Example.trigger b/nebula-logger/recipes/triggers/Account_Trigger_Logger_Example.trigger index d6aa2c399..cd8eb8758 100644 --- a/nebula-logger/recipes/triggers/Account_Trigger_Logger_Example.trigger +++ b/nebula-logger/recipes/triggers/Account_Trigger_Logger_Example.trigger @@ -4,14 +4,14 @@ */ trigger Account_Trigger_Logger_Example on Account(before insert, before update, before delete, after insert, after update, after delete, after undelete) { // Get the trigger's list of records - List triggerRecords = Trigger.new != null ? Trigger.new : Trigger.old; + List triggerRecords = Trigger.new != null ? Trigger.new : Trigger.old; // Log using an instance of LogMessage for more complex strings String messageTemplate = 'Example log entry from Account trigger, processing {0} records'; LogMessage logMessage = new LogMessage(messageTemplate, triggerRecords.size()); Logger.fine(logMessage, triggerRecords); - for (Account account : triggerRecords) { + for (Schema.Account account : triggerRecords) { // Log a string for simpler log entries Logger.fine('Here\'s an entry for a specific Account record', account); } diff --git a/package.json b/package.json index 737ad3948..5df0ddbd8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nebula-logger", - "version": "4.12.4", + "version": "4.12.5", "description": "The most robust logger for Salesforce. Works with Apex, Lightning Components, Flow, Process Builder & Integrations. Designed for Salesforce admins, developers & architects.", "author": "Jonathan Gillespie", "license": "MIT", diff --git a/sfdx-project.json b/sfdx-project.json index 017068bf3..838a7ffa3 100644 --- a/sfdx-project.json +++ b/sfdx-project.json @@ -13,9 +13,9 @@ "package": "Nebula Logger - Core", "path": "./nebula-logger/core", "definitionFile": "./config/scratch-orgs/base-scratch-def.json", - "versionNumber": "4.12.4.NEXT", - "versionName": "Bugfix Child Log__c Records Not Properly Linked to Parent Log__c Records", - "versionDescription": "Fixed some scenarios where a Log__c record would have a value in ParentLogTransactionId__c but a null value in ParentLog__c", + "versionNumber": "4.12.5.NEXT", + "versionName": "Bugfix for Name-Shadowing Issues with Schema Namespace", + "versionDescription": "Switched to using fully-qualified Apex class references to several classes in the Schema namespace, like Schema.User, to avoid collision issues in orgs that use name-shadowing classes", "releaseNotesUrl": "https://github.com/jongpie/NebulaLogger/releases", "unpackagedMetadata": { "path": "./nebula-logger/extra-tests" @@ -165,6 +165,7 @@ "Nebula Logger - Core@4.12.2-automatically-select-default-field-set-in-relatedlogentries-lwc": "04t5Y000001Mk55QAC", "Nebula Logger - Core@4.12.3-bugfix-for-userinfo.getsessionid()-exception": "04t5Y000001Mk5AQAS", "Nebula Logger - Core@4.12.4-bugfix-child-log__c-records-not-properly-linked-to-parent-log__c-records": "04t5Y000001Mk5KQAS", + "Nebula Logger - Core@4.12.5-bugfix-for-name-shadowing-issues-with-schema-namespace": "04t5Y000001Mk5PQAS", "Nebula Logger - Core Plugin - Async Failure Additions": "0Ho5Y000000blO4SAI", "Nebula Logger - Core Plugin - Async Failure Additions@1.0.0": "04t5Y0000015lhiQAA", "Nebula Logger - Core Plugin - Async Failure Additions@1.0.1": "04t5Y0000015lhsQAA",