From 3d87c3f24171d33df68d2adb0ceb090c20811168 Mon Sep 17 00:00:00 2001 From: Jonathan Gillespie Date: Fri, 1 Nov 2024 11:22:16 -0400 Subject: [PATCH] Updated all SObjectType and SObjectField usages of getDescribe().getName() to toString() - it's easier to read, and based on some benchmarking @jamessimone did, it's faster too --- .../classes/LoggerBatchableContext.cls | 2 +- .../classes/LoggerTriggerableContext.cls | 2 +- .../classes/LogEntryHandler.cls | 6 +- .../classes/LogManagementDataSelector.cls | 14 ++--- .../classes/RelatedLogEntriesController.cls | 2 +- .../classes/FlowCollectionLogEntry.cls | 2 +- .../classes/LogEntryEventBuilder.cls | 14 ++--- .../classes/LoggerFieldMapper_Tests.cls | 58 +++++++++---------- .../utilities/LoggerMockDataCreator.cls | 4 +- .../classes/LogEntryEventHandler_Tests.cls | 10 ++-- .../LogManagementDataSelector_Tests.cls | 11 ++-- .../classes/LoggerBatchableContext_Tests.cls | 2 +- .../classes/LoggerSObjectMetadata_Tests.cls | 4 +- .../utilities/LoggerTestConfigurator.cls | 2 +- .../classes/ComponentLogger_Tests.cls | 4 +- .../classes/LogEntryEventBuilder_Tests.cls | 14 ++--- .../classes/LoggerSObjectHandler_Tests.cls | 4 +- .../LoggerTriggerableContext_Tests.cls | 6 +- .../logger-engine/classes/Logger_Tests.cls | 6 +- .../utilities/LoggerMockDataStore.cls | 2 +- .../classes/NebulaLogger_E2E_Tests.cls | 2 +- ...gEntryEventHandler_Tests_FieldMappings.cls | 24 ++++---- .../plugin/classes/LogEntryArchivePlugin.cls | 14 ++--- .../classes/LogRetentionRulesPlugin.cls | 6 +- .../slack/classes/SlackLoggerPlugin.cls | 4 +- .../slack/classes/SlackLoggerPlugin_Tests.cls | 6 +- 26 files changed, 108 insertions(+), 117 deletions(-) diff --git a/nebula-logger/core/main/configuration/classes/LoggerBatchableContext.cls b/nebula-logger/core/main/configuration/classes/LoggerBatchableContext.cls index d3ab3b40e..a46f257bf 100644 --- a/nebula-logger/core/main/configuration/classes/LoggerBatchableContext.cls +++ b/nebula-logger/core/main/configuration/classes/LoggerBatchableContext.cls @@ -25,6 +25,6 @@ public without sharing class LoggerBatchableContext { public LoggerBatchableContext(Database.BatchableContext batchableContext, Schema.SObjectType sobjectType) { this.batchableContext = batchableContext; this.sobjectType = sobjectType; - this.sobjectTypeName = sobjectType?.getDescribe().getName(); + this.sobjectTypeName = sobjectType?.toString(); } } diff --git a/nebula-logger/core/main/configuration/classes/LoggerTriggerableContext.cls b/nebula-logger/core/main/configuration/classes/LoggerTriggerableContext.cls index cb9058dbb..35ddf7881 100644 --- a/nebula-logger/core/main/configuration/classes/LoggerTriggerableContext.cls +++ b/nebula-logger/core/main/configuration/classes/LoggerTriggerableContext.cls @@ -49,7 +49,7 @@ public without sharing class LoggerTriggerableContext { private void setupAdditionalProperties() { // Additional invocable variables for Flow Builders (and Apex Developers too, if they want to use them) - this.sobjectTypeName = this.sobjectType.getDescribe().getName(); + this.sobjectTypeName = this.sobjectType.toString(); this.triggerOperationTypeName = this.triggerOperationType?.name(); this.triggerRecords = new List(); if (this.triggerNew != null) { diff --git a/nebula-logger/core/main/log-management/classes/LogEntryHandler.cls b/nebula-logger/core/main/log-management/classes/LogEntryHandler.cls index 412bc1c68..17c184c9a 100644 --- a/nebula-logger/core/main/log-management/classes/LogEntryHandler.cls +++ b/nebula-logger/core/main/log-management/classes/LogEntryHandler.cls @@ -46,7 +46,7 @@ public without sharing class LogEntryHandler extends LoggerSObjectHandler { } private void setApexClassFields() { - String apexClassSObjectTypeName = Schema.ApexClass.SObjectType.getDescribe().getName(); + String apexClassSObjectTypeName = Schema.ApexClass.SObjectType.toString(); Set apexClassNames = new Set(); Set apexClassLogEntries = new Set(); for (LogEntry__c logEntry : this.logEntries) { @@ -84,7 +84,7 @@ public without sharing class LogEntryHandler extends LoggerSObjectHandler { } private void setApexTriggerFields() { - String apexTriggerSObjectTypeName = Schema.ApexTrigger.SObjectType.getDescribe().getName(); + String apexTriggerSObjectTypeName = Schema.ApexTrigger.SObjectType.toString(); Set apexTriggerNames = new Set(); Set apexTriggerLogEntries = new Set(); for (LogEntry__c logEntry : this.logEntries) { @@ -371,7 +371,7 @@ public without sharing class LogEntryHandler extends LoggerSObjectHandler { // Use username instead of name for user if (sobjectType == Schema.User.SObjectType) { - String userFieldName = Schema.User.Username.getDescribe().getName(); + String userFieldName = Schema.User.Username.toString(); SOBJECT_TYPE_TO_DISPLAY_FIELD_NAME.put(Schema.User.SObjectType, userFieldName); return userFieldName; } diff --git a/nebula-logger/core/main/log-management/classes/LogManagementDataSelector.cls b/nebula-logger/core/main/log-management/classes/LogManagementDataSelector.cls index f21da0bba..3658d64e6 100644 --- a/nebula-logger/core/main/log-management/classes/LogManagementDataSelector.cls +++ b/nebula-logger/core/main/log-management/classes/LogManagementDataSelector.cls @@ -214,7 +214,7 @@ public without sharing virtual class LogManagementDataSelector { List logFieldNames = new List(Schema.Log__c.SObjectType.getDescribe().fields.getMap().keySet()); logFieldNames.addAll(new List{ 'Owner.Name', 'Owner.Type' }); - List textReplacements = new List{ String.join(logFieldNames, ','), Schema.Log__c.SObjectType.getDescribe().getName() }; + List textReplacements = new List{ String.join(logFieldNames, ','), Schema.Log__c.SObjectType.toString() }; String query = String.format(queryTemplate, textReplacements); return (Log__c) System.Database.query(String.escapeSingleQuotes(query)); @@ -229,7 +229,7 @@ public without sharing virtual class LogManagementDataSelector { String queryTemplate = 'SELECT {0} FROM {1} WHERE Id = :logEntryId'; List logEntryFieldNames = new List(Schema.LogEntry__c.SObjectType.getDescribe().fields.getMap().keySet()); - List textReplacements = new List{ String.join(logEntryFieldNames, ','), Schema.LogEntry__c.SObjectType.getDescribe().getName() }; + List textReplacements = new List{ String.join(logEntryFieldNames, ','), Schema.LogEntry__c.SObjectType.toString() }; String query = String.format(queryTemplate, textReplacements); return (LogEntry__c) System.Database.query(String.escapeSingleQuotes(query)); @@ -246,9 +246,9 @@ public without sharing virtual class LogManagementDataSelector { List logEntryFieldNames = new List(Schema.LogEntry__c.SObjectType.getDescribe().fields.getMap().keySet()); List textReplacements = new List{ String.join(logEntryFieldNames, ', '), - Schema.LogEntry__c.SObjectType.getDescribe().getName(), - Schema.LogEntry__c.Log__c.getDescribe().getName(), - Schema.LogEntry__c.TransactionEntryNumber__c.getDescribe().getName() + Schema.LogEntry__c.SObjectType.toString(), + Schema.LogEntry__c.Log__c.toString(), + Schema.LogEntry__c.TransactionEntryNumber__c.toString() }; String query = String.format(queryTemplate, textReplacements); @@ -357,8 +357,8 @@ public without sharing virtual class LogManagementDataSelector { public virtual List getRecordLogEntries(Id recordId, String fieldsClause, String orderByClause, Integer rowLimit) { List queryTextReplacements = new List{ fieldsClause, - Schema.LogEntry__c.SObjectType.getDescribe().getName(), - Schema.LogEntry__c.RecordId__c.getDescribe().getName(), + Schema.LogEntry__c.SObjectType.toString(), + Schema.LogEntry__c.RecordId__c.toString(), orderByClause, rowLimit }; diff --git a/nebula-logger/core/main/log-management/classes/RelatedLogEntriesController.cls b/nebula-logger/core/main/log-management/classes/RelatedLogEntriesController.cls index f84bd90f9..8472835ed 100644 --- a/nebula-logger/core/main/log-management/classes/RelatedLogEntriesController.cls +++ b/nebula-logger/core/main/log-management/classes/RelatedLogEntriesController.cls @@ -111,7 +111,7 @@ public with sharing class RelatedLogEntriesController { // Use username instead of name for user if (lookupSObjectType == Schema.User.SObjectType) { - return relationshipName + '.' + Schema.User.Username.getDescribe().getName(); + return relationshipName + '.' + Schema.User.Username.toString(); } // There are several commonly used names for the display field name - typically, Name, but check for others diff --git a/nebula-logger/core/main/logger-engine/classes/FlowCollectionLogEntry.cls b/nebula-logger/core/main/logger-engine/classes/FlowCollectionLogEntry.cls index 963d7f704..467fae7b4 100644 --- a/nebula-logger/core/main/logger-engine/classes/FlowCollectionLogEntry.cls +++ b/nebula-logger/core/main/logger-engine/classes/FlowCollectionLogEntry.cls @@ -105,7 +105,7 @@ global inherited sharing class FlowCollectionLogEntry { ); LogEntryEventBuilder builder = shadowLogEntry.addToLoggerBuffer()?.setRecord(flowCollectionLogEntry.records); if (builder.shouldSave() && flowCollectionLogEntry.records?.size() > 0) { - builder.getLogEntryEvent().RecordSObjectType__c = flowCollectionLogEntry.records.get(0).getSObjectType().getDescribe().getName(); + builder.getLogEntryEvent().RecordSObjectType__c = flowCollectionLogEntry.records.get(0).getSObjectType().toString(); } shadowLogEntries.add(shadowLogEntry); diff --git a/nebula-logger/core/main/logger-engine/classes/LogEntryEventBuilder.cls b/nebula-logger/core/main/logger-engine/classes/LogEntryEventBuilder.cls index d93a099c3..49526c638 100644 --- a/nebula-logger/core/main/logger-engine/classes/LogEntryEventBuilder.cls +++ b/nebula-logger/core/main/logger-engine/classes/LogEntryEventBuilder.cls @@ -342,7 +342,7 @@ global with sharing class LogEntryEventBuilder { try { Schema.SObjectType sobjectType = recordId?.getSObjectType(); this.logEntryEvent.RecordSObjectClassification__c = getSObjectClassification(sobjectType); - this.logEntryEvent.RecordSObjectType__c = sobjectType.getDescribe().getName(); + this.logEntryEvent.RecordSObjectType__c = sobjectType.toString(); } catch (System.SObjectException sobjectException) { // Some SObject Types are considered template objects, such as CaseComment, AccountHistory, // ContactHistory, etc, so calling Id.getSObjectType() does not work for some types of record IDs @@ -382,7 +382,7 @@ global with sharing class LogEntryEventBuilder { this.logEntryEvent.RecordJson__c = cleanedRecordJson; this.logEntryEvent.RecordJsonMasked__c = recordJsonMasked; this.logEntryEvent.RecordSObjectClassification__c = getSObjectClassification(record.getSObjectType()); - this.logEntryEvent.RecordSObjectType__c = record.getSObjectType().getDescribe().getName(); + this.logEntryEvent.RecordSObjectType__c = record.getSObjectType().toString(); this.logEntryEvent.RecordSObjectTypeNamespace__c = getSObjectTypeNamespace(record.getSObjectType()); } @@ -418,7 +418,7 @@ global with sharing class LogEntryEventBuilder { this.logEntryEvent.RecordJson__c = cleanedRecordJson; this.logEntryEvent.RecordJsonMasked__c = recordJsonMasked; this.logEntryEvent.RecordSObjectClassification__c = getSObjectClassification(sobjectType); - this.logEntryEvent.RecordSObjectType__c = sobjectType.getDescribe().getName(); + this.logEntryEvent.RecordSObjectType__c = sobjectType.toString(); this.logEntryEvent.RecordSObjectTypeNamespace__c = getSObjectTypeNamespace(sobjectType); } @@ -455,7 +455,7 @@ global with sharing class LogEntryEventBuilder { this.logEntryEvent.RecordJson__c = cleanedRecordJson; this.logEntryEvent.RecordJsonMasked__c = recordJsonMasked; this.logEntryEvent.RecordSObjectClassification__c = getSObjectClassification(sobjectType); - this.logEntryEvent.RecordSObjectType__c = sobjectType.getDescribe().getName(); + this.logEntryEvent.RecordSObjectType__c = sobjectType.toString(); this.logEntryEvent.RecordSObjectTypeNamespace__c = getSObjectTypeNamespace(sobjectType); } @@ -880,7 +880,7 @@ global with sharing class LogEntryEventBuilder { OriginType__c = 'Apex', TriggerIsExecuting__c = Trigger.isExecuting, TriggerOperationType__c = Trigger.operationType?.name(), - TriggerSObjectType__c = Trigger.new?.getSObjectType().getDescribe().getName() + TriggerSObjectType__c = Trigger.new?.getSObjectType().toString() ); if (LoggerParameter.STORE_TRANSACTION_LIMITS) { @@ -1100,7 +1100,7 @@ global with sharing class LogEntryEventBuilder { } private static String getSObjectClassification(Schema.SObjectType sobjectType) { - String sobjectName = sobjectType.getDescribe().getName(); + String sobjectName = sobjectType.toString(); // Check the map to see if we've already determined the classification for this SObject type if (CACHED_SOBJECT_NAME_TO_CLASSIFICATION.containsKey(sobjectName)) { @@ -1158,7 +1158,7 @@ global with sharing class LogEntryEventBuilder { } private static String getSObjectTypeNamespace(Schema.SObjectType sobjectType) { - String sobjectFullName = sobjectType.getDescribe().getName(); + String sobjectFullName = sobjectType.toString(); String sobjectLocalName = sobjectType.getDescribe().getLocalName(); // Remove the trailing '__' if present diff --git a/nebula-logger/core/tests/configuration/classes/LoggerFieldMapper_Tests.cls b/nebula-logger/core/tests/configuration/classes/LoggerFieldMapper_Tests.cls index c88e87112..1e1482ad1 100644 --- a/nebula-logger/core/tests/configuration/classes/LoggerFieldMapper_Tests.cls +++ b/nebula-logger/core/tests/configuration/classes/LoggerFieldMapper_Tests.cls @@ -27,10 +27,10 @@ private class LoggerFieldMapper_Tests { new LoggerFieldMapping__mdt( DeveloperName = 'SomeDevName', IsEnabled__c = true, - SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.getDescribe().getName(), - SourceField__c = Schema.LogEntryEvent__e.Message__c.getDescribe().getName(), - TargetSObjectType__c = Schema.LogEntry__c.SObjectType.getDescribe().getName(), - TargetField__c = Schema.LogEntry__c.Message__c.getDescribe().getName() + SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.toString(), + SourceField__c = Schema.LogEntryEvent__e.Message__c.toString(), + TargetSObjectType__c = Schema.LogEntry__c.SObjectType.toString(), + TargetField__c = Schema.LogEntry__c.Message__c.toString() ) ); LogEntryEvent__e logEntryEvent = new LogEntryEvent__e(Message__c = 'Some value'); @@ -38,10 +38,7 @@ private class LoggerFieldMapper_Tests { LoggerFieldMapper.mapFieldValues(logEntryEvent, logEntry); - System.Assert.isTrue( - logEntry.getPopulatedFieldsAsMap().containsKey(Schema.LogEntry__c.Message__c.getDescribe().getName()), - System.JSON.serialize(logEntry) - ); + System.Assert.isTrue(logEntry.getPopulatedFieldsAsMap().containsKey(Schema.LogEntry__c.Message__c.toString()), System.JSON.serialize(logEntry)); System.Assert.areEqual(logEntryEvent.Message__c, logEntry.Message__c); } @@ -51,10 +48,10 @@ private class LoggerFieldMapper_Tests { new LoggerFieldMapping__mdt( DeveloperName = 'SomeDevName', IsEnabled__c = true, - SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.getDescribe().getName(), - SourceField__c = Schema.LogEntryEvent__e.Message__c.getDescribe().getName(), - TargetSObjectType__c = Schema.LogEntry__c.SObjectType.getDescribe().getName(), - TargetField__c = Schema.LogEntry__c.Message__c.getDescribe().getName() + SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.toString(), + SourceField__c = Schema.LogEntryEvent__e.Message__c.toString(), + TargetSObjectType__c = Schema.LogEntry__c.SObjectType.toString(), + TargetField__c = Schema.LogEntry__c.Message__c.toString() ) ); Integer messageMaxLength = Schema.LogEntryEvent__e.Message__c.getDescribe().getLength(); @@ -63,10 +60,7 @@ private class LoggerFieldMapper_Tests { LoggerFieldMapper.mapFieldValues(logEntryEvent, logEntry); - System.Assert.isTrue( - logEntry.getPopulatedFieldsAsMap().containsKey(Schema.LogEntry__c.Message__c.getDescribe().getName()), - System.JSON.serialize(logEntry) - ); + System.Assert.isTrue(logEntry.getPopulatedFieldsAsMap().containsKey(Schema.LogEntry__c.Message__c.toString()), System.JSON.serialize(logEntry)); System.Assert.areEqual( logEntryEvent.Message__c.left(messageMaxLength), logEntry.Message__c, @@ -80,10 +74,10 @@ private class LoggerFieldMapper_Tests { new LoggerFieldMapping__mdt( DeveloperName = 'SomeDevName', IsEnabled__c = true, - SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.getDescribe().getName(), - SourceField__c = Schema.LogEntryEvent__e.TransactionId__c.getDescribe().getName(), - TargetSObjectType__c = Schema.Log__c.SObjectType.getDescribe().getName(), - TargetField__c = Schema.Log__c.TransactionId__c.getDescribe().getName() + SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.toString(), + SourceField__c = Schema.LogEntryEvent__e.TransactionId__c.toString(), + TargetSObjectType__c = Schema.Log__c.SObjectType.toString(), + TargetField__c = Schema.Log__c.TransactionId__c.toString() ) ); LogEntryEvent__e logEntryEvent = new LogEntryEvent__e(Message__c = 'Some value'); @@ -100,30 +94,30 @@ private class LoggerFieldMapper_Tests { new LoggerFieldMapping__mdt( DeveloperName = '🥳 Some Valid Mapping', IsEnabled__c = true, - SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.getDescribe().getName(), - SourceField__c = Schema.LogEntryEvent__e.EntryScenario__c.getDescribe().getName(), - TargetSObjectType__c = Schema.LogEntry__c.SObjectType.getDescribe().getName(), - TargetField__c = Schema.LogEntry__c.EntryScenario__c.getDescribe().getName() + SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.toString(), + SourceField__c = Schema.LogEntryEvent__e.EntryScenario__c.toString(), + TargetSObjectType__c = Schema.LogEntry__c.SObjectType.toString(), + TargetField__c = Schema.LogEntry__c.EntryScenario__c.toString() ) ); LoggerFieldMapper.setMock( new LoggerFieldMapping__mdt( DeveloperName = '😭 An Incompatible Mapping (mapping a String to a Datetime)', IsEnabled__c = true, - SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.getDescribe().getName(), - SourceField__c = Schema.LogEntryEvent__e.Message__c.getDescribe().getName(), - TargetSObjectType__c = Schema.LogEntry__c.SObjectType.getDescribe().getName(), - TargetField__c = Schema.LogEntry__c.Timestamp__c.getDescribe().getName() + SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.toString(), + SourceField__c = Schema.LogEntryEvent__e.Message__c.toString(), + TargetSObjectType__c = Schema.LogEntry__c.SObjectType.toString(), + TargetField__c = Schema.LogEntry__c.Timestamp__c.toString() ) ); LoggerFieldMapper.setMock( new LoggerFieldMapping__mdt( DeveloperName = '😀 Another Valid Mapping', IsEnabled__c = true, - SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.getDescribe().getName(), - SourceField__c = Schema.LogEntryEvent__e.TransactionEntryNumber__c.getDescribe().getName(), - TargetSObjectType__c = Schema.LogEntry__c.SObjectType.getDescribe().getName(), - TargetField__c = Schema.LogEntry__c.TransactionEntryNumber__c.getDescribe().getName() + SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.toString(), + SourceField__c = Schema.LogEntryEvent__e.TransactionEntryNumber__c.toString(), + TargetSObjectType__c = Schema.LogEntry__c.SObjectType.toString(), + TargetField__c = Schema.LogEntry__c.TransactionEntryNumber__c.toString() ) ); LogEntryEvent__e logEntryEvent = new LogEntryEvent__e( diff --git a/nebula-logger/core/tests/configuration/utilities/LoggerMockDataCreator.cls b/nebula-logger/core/tests/configuration/utilities/LoggerMockDataCreator.cls index 72419c376..e9cfa7865 100644 --- a/nebula-logger/core/tests/configuration/utilities/LoggerMockDataCreator.cls +++ b/nebula-logger/core/tests/configuration/utilities/LoggerMockDataCreator.cls @@ -387,7 +387,7 @@ public class LoggerMockDataCreator { // To avoid a MIXED_DML_OPERATION exception, use System.runs() for inserting the QueueSObject record System.runAs(new Schema.User(Id = System.UserInfo.getUserId())) { - QueueSObject queueSObject = new QueueSObject(QueueId = queue.Id, SObjectType = sobjectType.getDescribe().getName()); + QueueSObject queueSObject = new QueueSObject(QueueId = queue.Id, SObjectType = sobjectType.toString()); insert queueSObject; } @@ -419,7 +419,7 @@ public class LoggerMockDataCreator { // Loop through the deserialized record map and put the field & value // Since it's a map, if the field already exists on the SObject, it's updated (or added if it wasn't there already) for (Schema.SObjectField sobjectField : changesToFields.keySet()) { - String fieldName = sobjectField.getDescribe().getName(); + String fieldName = sobjectField.toString(); deserializedRecordMap.put(fieldName, changesToFields.get(sobjectField)); } 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 43afa2e1c..5647ea9d3 100644 --- a/nebula-logger/core/tests/log-management/classes/LogEntryEventHandler_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogEntryEventHandler_Tests.cls @@ -879,7 +879,7 @@ private class LogEntryEventHandler_Tests { String configuredTagName = 'CMDT Tag'; LoggerTestConfigurator.setMock( new LogEntryTagRule__mdt( - SObjectField__c = Schema.LogEntry__c.Message__c.getDescribe().getName(), + SObjectField__c = Schema.LogEntry__c.Message__c.toString(), ComparisonType__c = 'CONTAINS', ComparisonValue__c = 'some value', Tags__c = configuredTagName @@ -918,7 +918,7 @@ private class LogEntryEventHandler_Tests { String configuredTagName = 'CMDT Tag'; LoggerTestConfigurator.setMock( new LogEntryTagRule__mdt( - SObjectField__c = Schema.LogEntry__c.Message__c.getDescribe().getName(), + SObjectField__c = Schema.LogEntry__c.Message__c.toString(), ComparisonType__c = 'CONTAINS', ComparisonValue__c = logEntryEvent.Message__c.substring(1, 4), Tags__c = configuredTagName @@ -958,7 +958,7 @@ private class LogEntryEventHandler_Tests { String configuredTagName = 'CMDT Tag'; LoggerTestConfigurator.setMock( new LogEntryTagRule__mdt( - SObjectField__c = Schema.LogEntry__c.Message__c.getDescribe().getName(), + SObjectField__c = Schema.LogEntry__c.Message__c.toString(), ComparisonType__c = 'EQUALS', ComparisonValue__c = logEntryEvent.Message__c, Tags__c = configuredTagName @@ -1000,7 +1000,7 @@ private class LogEntryEventHandler_Tests { String configuredTagName = 'CMDT Tag'; LoggerTestConfigurator.setMock( new LogEntryTagRule__mdt( - SObjectField__c = Schema.LogEntry__c.Message__c.getDescribe().getName(), + SObjectField__c = Schema.LogEntry__c.Message__c.toString(), ComparisonType__c = 'MATCHES_REGEX', ComparisonValue__c = zipCodeRegEx, Tags__c = configuredTagName @@ -1041,7 +1041,7 @@ private class LogEntryEventHandler_Tests { String configuredTagName = 'CMDT Tag'; LoggerTestConfigurator.setMock( new LogEntryTagRule__mdt( - SObjectField__c = Schema.LogEntry__c.Message__c.getDescribe().getName(), + SObjectField__c = Schema.LogEntry__c.Message__c.toString(), ComparisonType__c = 'STARTS_WITH', ComparisonValue__c = logEntryEvent.Message__c.left(3), Tags__c = configuredTagName 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 b0252745a..4d35cc77d 100644 --- a/nebula-logger/core/tests/log-management/classes/LogManagementDataSelector_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogManagementDataSelector_Tests.cls @@ -11,7 +11,7 @@ private class LogManagementDataSelector_Tests { @IsTest 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() }; + Set targetFieldNames = new Set{ Schema.Organization.Id.toString(), Schema.Organization.Name.toString() }; List expectedResults = System.Database.query('SELECT ' + String.join(targetFieldNames, ', ') + ' FROM ' + targetSObjectType); List returnedResults = LogManagementDataSelector.getInstance().getAll(targetSObjectType, targetFieldNames); @@ -23,7 +23,7 @@ private class LogManagementDataSelector_Tests { @IsTest 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() }; + Set targetFieldNames = new Set{ Schema.User.Id.toString(), Schema.User.Name.toString() }; List targetIds = new List(new Map([SELECT Id FROM User LIMIT 3]).keySet()); List expectedResults = System.Database.query( 'SELECT ' + String.join(targetFieldNames, ', ') + ' FROM ' + targetSObjectType + ' WHERE Id IN :targetIds' @@ -469,11 +469,8 @@ private class LogManagementDataSelector_Tests { matchingLogEntry.RecordId__c = targetRecordId; logEntries.add(matchingLogEntry); insert logEntries; - String fieldsClause = String.join( - new List{ Schema.LogEntry__c.Id.getDescribe().getName(), Schema.LogEntry__c.Timestamp__c.getDescribe().getName() }, - ', ' - ); - String orderByClause = Schema.LogEntry__c.Timestamp__c.getDescribe().getName(); + String fieldsClause = String.join(new List{ Schema.LogEntry__c.Id.toString(), Schema.LogEntry__c.Timestamp__c.toString() }, ', '); + String orderByClause = Schema.LogEntry__c.Timestamp__c.toString(); Integer rowLimit = 3; List returnedResults = LogManagementDataSelector.getInstance().getRecordLogEntries(targetRecordId, fieldsClause, orderByClause, rowLimit); diff --git a/nebula-logger/core/tests/log-management/classes/LoggerBatchableContext_Tests.cls b/nebula-logger/core/tests/log-management/classes/LoggerBatchableContext_Tests.cls index 40719e7c1..ffc7d5d6b 100644 --- a/nebula-logger/core/tests/log-management/classes/LoggerBatchableContext_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LoggerBatchableContext_Tests.cls @@ -15,7 +15,7 @@ private class LoggerBatchableContext_Tests { System.Assert.areEqual(mockBatchableContext, context.batchableContext); System.Assert.areEqual(sobjectType, context.sobjectType); - System.Assert.areEqual(sobjectType.getDescribe().getName(), context.sobjectTypeName); + System.Assert.areEqual(sobjectType.toString(), context.sobjectTypeName); } @IsTest 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 9a7ffdaff..f864fb8e2 100644 --- a/nebula-logger/core/tests/log-management/classes/LoggerSObjectMetadata_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LoggerSObjectMetadata_Tests.cls @@ -15,7 +15,7 @@ private class LoggerSObjectMetadata_Tests { @IsTest static void it_should_return_schema_for_specified_sobject_api_name() { Schema.SObjectType userSObjectType = Schema.User.SObjectType; - String userSObjectApiName = userSObjectType.getDescribe().getName(); + String userSObjectApiName = userSObjectType.toString(); // TODO Add `Schema.` prefix if the string API name doesn't include `.` (unqualified) LoggerSObjectMetadata.SObjectSchema sobjectSchema = LoggerSObjectMetadata.getSchemaForName(userSObjectApiName); validateSObjectDetails(userSObjectType, sobjectSchema); @@ -33,7 +33,7 @@ private class LoggerSObjectMetadata_Tests { System.Assert.areEqual(sobjectType.getDescribe().getLabel(), sobjectSchema.label); System.Assert.areEqual(sobjectType.getDescribe().getLabelPlural(), sobjectSchema.labelPlural); System.Assert.areEqual(sobjectType.getDescribe().getLocalName(), sobjectSchema.localApiName); - System.Assert.areEqual(sobjectType.getDescribe().getName(), sobjectSchema.apiName); + System.Assert.areEqual(sobjectType.toString(), sobjectSchema.apiName); System.Assert.areEqual(sobjectType.getDescribe().fields.getMap().size(), sobjectSchema.fields.size()); // Field details diff --git a/nebula-logger/core/tests/log-management/utilities/LoggerTestConfigurator.cls b/nebula-logger/core/tests/log-management/utilities/LoggerTestConfigurator.cls index 2a6f983f2..ff7c5eeaf 100644 --- a/nebula-logger/core/tests/log-management/utilities/LoggerTestConfigurator.cls +++ b/nebula-logger/core/tests/log-management/utilities/LoggerTestConfigurator.cls @@ -139,7 +139,7 @@ public without sharing class LoggerTestConfigurator { new LoggerSObjectHandler__mdt( IsEnabled__c = isEnabled, SObjectHandlerApexClass__c = sobjectTypeToDefaultHandlerApexClass.get(sobjectType).getName(), - SObjectType__c = sobjectType.getDescribe().getName() + SObjectType__c = sobjectType.toString() ) ); } 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 bea499996..ce6f9bb55 100644 --- a/nebula-logger/core/tests/logger-engine/classes/ComponentLogger_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/ComponentLogger_Tests.cls @@ -127,8 +127,8 @@ private class ComponentLogger_Tests { // Realistically, people shouldn't/wouldn't set fields like HttpRequestBody__c or HttpRequestMethod__c... // But to avoid adding an extra field just for test purposes, we'll use some existing fields componentLogEntry.fieldToValue = new Map{ - Schema.LogEntryEvent__e.HttpRequestBody__c.getDescribe().getName() => 'some value', - Schema.LogEntryEvent__e.HttpRequestMethod__c.getDescribe().getName() => 'another value' + Schema.LogEntryEvent__e.HttpRequestBody__c.toString() => 'some value', + Schema.LogEntryEvent__e.HttpRequestMethod__c.toString() => 'another value' }; System.Assert.areEqual(0, Logger.saveLogCallCount); System.Assert.areEqual(0, LoggerMockDataStore.getEventBus().getPublishCallCount()); 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 4878d6669..466b324ee 100644 --- a/nebula-logger/core/tests/logger-engine/classes/LogEntryEventBuilder_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/LogEntryEventBuilder_Tests.cls @@ -902,7 +902,7 @@ private class LogEntryEventBuilder_Tests { System.Assert.areEqual(mockLogId, builder.getLogEntryEvent().RecordId__c); System.Assert.isNull(builder.getLogEntryEvent().RecordJson__c); System.Assert.areEqual('Custom Object', builder.getLogEntryEvent().RecordSObjectClassification__c); - System.Assert.areEqual(Log__c.SObjectType.getDescribe().getName(), builder.getLogEntryEvent().RecordSObjectType__c); + System.Assert.areEqual(Log__c.SObjectType.toString(), builder.getLogEntryEvent().RecordSObjectType__c); } @IsTest @@ -922,7 +922,7 @@ private class LogEntryEventBuilder_Tests { System.Assert.areEqual(status.Id, builder.getLogEntryEvent().RecordId__c); System.Assert.isNull(builder.getLogEntryEvent().RecordJson__c); System.Assert.areEqual('Custom Metadata Type Object', builder.getLogEntryEvent().RecordSObjectClassification__c); - System.Assert.areEqual(LogStatus__mdt.SObjectType.getDescribe().getName(), builder.getLogEntryEvent().RecordSObjectType__c); + System.Assert.areEqual(LogStatus__mdt.SObjectType.toString(), builder.getLogEntryEvent().RecordSObjectType__c); } @IsTest @@ -985,7 +985,7 @@ private class LogEntryEventBuilder_Tests { System.Assert.areEqual(log.Id, builder.getLogEntryEvent().RecordId__c); System.Assert.areEqual(System.JSON.serializePretty(log), builder.getLogEntryEvent().RecordJson__c); System.Assert.areEqual('Custom Object', builder.getLogEntryEvent().RecordSObjectClassification__c); - System.Assert.areEqual(Log__c.SObjectType.getDescribe().getName(), builder.getLogEntryEvent().RecordSObjectType__c); + System.Assert.areEqual(Log__c.SObjectType.toString(), builder.getLogEntryEvent().RecordSObjectType__c); } @IsTest @@ -1005,7 +1005,7 @@ private class LogEntryEventBuilder_Tests { System.Assert.areEqual(status.Id, builder.getLogEntryEvent().RecordId__c); System.Assert.areEqual(System.JSON.serializePretty(status), builder.getLogEntryEvent().RecordJson__c); System.Assert.areEqual('Custom Metadata Type Object', builder.getLogEntryEvent().RecordSObjectClassification__c); - System.Assert.areEqual(LogStatus__mdt.SObjectType.getDescribe().getName(), builder.getLogEntryEvent().RecordSObjectType__c); + System.Assert.areEqual(LogStatus__mdt.SObjectType.toString(), builder.getLogEntryEvent().RecordSObjectType__c); } @IsTest @@ -1026,7 +1026,7 @@ private class LogEntryEventBuilder_Tests { System.Assert.isNull(builder.getLogEntryEvent().RecordId__c); System.Assert.areEqual(System.JSON.serializePretty(platformEvent), builder.getLogEntryEvent().RecordJson__c); System.Assert.areEqual('Platform Event Object', builder.getLogEntryEvent().RecordSObjectClassification__c); - System.Assert.areEqual(LogEntryEvent__e.SObjectType.getDescribe().getName(), builder.getLogEntryEvent().RecordSObjectType__c); + System.Assert.areEqual(LogEntryEvent__e.SObjectType.toString(), builder.getLogEntryEvent().RecordSObjectType__c); } @IsTest @@ -1137,7 +1137,7 @@ private class LogEntryEventBuilder_Tests { System.Assert.isNull(builder.getLogEntryEvent().RecordId__c); System.Assert.areEqual(System.JSON.serializePretty(users), builder.getLogEntryEvent().RecordJson__c); System.Assert.areEqual('Standard Object', builder.getLogEntryEvent().RecordSObjectClassification__c); - System.Assert.areEqual(Schema.User.SObjectType.getDescribe().getName(), builder.getLogEntryEvent().RecordSObjectType__c); + System.Assert.areEqual(Schema.User.SObjectType.toString(), builder.getLogEntryEvent().RecordSObjectType__c); } @IsTest @@ -1246,7 +1246,7 @@ private class LogEntryEventBuilder_Tests { System.Assert.isNull(builder.getLogEntryEvent().RecordId__c); System.Assert.areEqual(System.JSON.serializePretty(userIdToUser), builder.getLogEntryEvent().RecordJson__c); System.Assert.areEqual('Standard Object', builder.getLogEntryEvent().RecordSObjectClassification__c); - System.Assert.areEqual(Schema.User.SObjectType.getDescribe().getName(), builder.getLogEntryEvent().RecordSObjectType__c); + System.Assert.areEqual(Schema.User.SObjectType.toString(), builder.getLogEntryEvent().RecordSObjectType__c); } @IsTest 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 e0dc127ab..1d37f6a6f 100644 --- a/nebula-logger/core/tests/logger-engine/classes/LoggerSObjectHandler_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/LoggerSObjectHandler_Tests.cls @@ -20,7 +20,7 @@ private class LoggerSObjectHandler_Tests { new LoggerSObjectHandler__mdt( IsEnabled__c = true, SObjectHandlerApexClass__c = MockSObjectHandler.class.getName(), - SObjectType__c = sobjectType.getDescribe().getName() + SObjectType__c = sobjectType.toString() ) ); @@ -40,7 +40,7 @@ private class LoggerSObjectHandler_Tests { new LoggerSObjectHandler__mdt( IsEnabled__c = true, SObjectHandlerApexClass__c = MockSObjectHandler.class.getName(), - SObjectTypeOverride__c = sobjectType.getDescribe().getName() + SObjectTypeOverride__c = sobjectType.toString() ) ); 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 e53c720c0..3e04c8f10 100644 --- a/nebula-logger/core/tests/logger-engine/classes/LoggerTriggerableContext_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/LoggerTriggerableContext_Tests.cls @@ -27,7 +27,7 @@ private class LoggerTriggerableContext_Tests { LoggerTriggerableContext context = new LoggerTriggerableContext(sobjectType, triggerOperationType, newUsers, null, null); System.Assert.areEqual(sobjectType, context.sobjectType); - System.Assert.areEqual(sobjectType.getDescribe().getName(), context.sobjectTypeName); + System.Assert.areEqual(sobjectType.toString(), context.sobjectTypeName); System.Assert.areEqual(triggerOperationType, context.triggerOperationType); System.Assert.areEqual(newUsers, context.triggerNew); System.Assert.isNull(context.triggerNewMap); @@ -55,7 +55,7 @@ private class LoggerTriggerableContext_Tests { LoggerTriggerableContext context = new LoggerTriggerableContext(sobjectType, triggerOperationType, updatedUsers, newUsersMap, oldUsersMap); System.Assert.areEqual(sobjectType, context.sobjectType); - System.Assert.areEqual(sobjectType.getDescribe().getName(), context.sobjectTypeName); + System.Assert.areEqual(sobjectType.toString(), context.sobjectTypeName); System.Assert.areEqual(triggerOperationType, context.triggerOperationType); System.Assert.areEqual(updatedUsers, context.triggerNew); System.Assert.areEqual(newUsersMap, context.triggerNewMap); @@ -82,7 +82,7 @@ private class LoggerTriggerableContext_Tests { LoggerTriggerableContext context = new LoggerTriggerableContext(sobjectType, triggerOperationType, null, null, deletedLogsMap); System.Assert.areEqual(sobjectType, context.sobjectType); - System.Assert.areEqual(sobjectType.getDescribe().getName(), context.sobjectTypeName); + System.Assert.areEqual(sobjectType.toString(), context.sobjectTypeName); System.Assert.areEqual(triggerOperationType, context.triggerOperationType); System.Assert.isNull(context.triggerNew); System.Assert.isNull(context.triggerNewMap); 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 1c44d10f3..04fac5a9d 100644 --- a/nebula-logger/core/tests/logger-engine/classes/Logger_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/Logger_Tests.cls @@ -1817,7 +1817,7 @@ private class Logger_Tests { DeveloperName = 'Mock_Log_Entry_Event_Config', IsEnabled__c = true, SObjectHandlerApexClass__c = MockSObjectHandler.class.getName(), - SObjectType__c = Schema.LogEntryEvent__e.SObjectType.getDescribe().getName() + SObjectType__c = Schema.LogEntryEvent__e.SObjectType.toString() ) ); Logger.getUserSettings().DefaultSaveMethod__c = Logger.SaveMethod.SYNCHRONOUS_DML.name(); @@ -1871,7 +1871,7 @@ private class Logger_Tests { DeveloperName = 'Mock_Log_Entry_Event_Config', IsEnabled__c = true, SObjectHandlerApexClass__c = MockSObjectHandler.class.getName(), - SObjectType__c = Schema.LogEntryEvent__e.SObjectType.getDescribe().getName() + SObjectType__c = Schema.LogEntryEvent__e.SObjectType.toString() ) ); List logEntryEvents = new List(); @@ -1924,7 +1924,7 @@ private class Logger_Tests { DeveloperName = 'Mock_Log_Entry_Event_Config', IsEnabled__c = true, SObjectHandlerApexClass__c = MockSObjectHandler.class.getName(), - SObjectType__c = Schema.LogEntryEvent__e.SObjectType.getDescribe().getName() + SObjectType__c = Schema.LogEntryEvent__e.SObjectType.toString() ) ); List logEntryEvents = new List(); diff --git a/nebula-logger/core/tests/logger-engine/utilities/LoggerMockDataStore.cls b/nebula-logger/core/tests/logger-engine/utilities/LoggerMockDataStore.cls index 70eb581f9..0d0b31d21 100644 --- a/nebula-logger/core/tests/logger-engine/utilities/LoggerMockDataStore.cls +++ b/nebula-logger/core/tests/logger-engine/utilities/LoggerMockDataStore.cls @@ -207,7 +207,7 @@ public without sharing class LoggerMockDataStore { continue; } - Boolean recordHasField = record.getPopulatedFieldsAsMap().containsKey(requiredField.getDescribe().getName()); + Boolean recordHasField = record.getPopulatedFieldsAsMap().containsKey(requiredField.toString()); Boolean recordHasFieldValue = record.get(requiredField) != null; if (recordHasField == false || recordHasFieldValue == false) { SObjectException ex = new SObjectException(); diff --git a/nebula-logger/extra-tests/classes/NebulaLogger_E2E_Tests.cls b/nebula-logger/extra-tests/classes/NebulaLogger_E2E_Tests.cls index b15e3a6b1..860dbee94 100644 --- a/nebula-logger/extra-tests/classes/NebulaLogger_E2E_Tests.cls +++ b/nebula-logger/extra-tests/classes/NebulaLogger_E2E_Tests.cls @@ -164,7 +164,7 @@ private class NebulaLogger_E2E_Tests { // Loop through the deserialized record map and put the field & value // Since it's a map, if the field already exists on the SObject, it's updated (or added if it wasn't there already) for (Schema.SObjectField sobjectField : changesToFields.keySet()) { - String fieldName = sobjectField.getDescribe().getName(); + String fieldName = sobjectField.toString(); deserializedRecordMap.put(fieldName, changesToFields.get(sobjectField)); } diff --git a/nebula-logger/extra-tests/tests/LogEntryEventHandler_Tests_FieldMappings.cls b/nebula-logger/extra-tests/tests/LogEntryEventHandler_Tests_FieldMappings.cls index 7f79fae96..b3f6a791c 100644 --- a/nebula-logger/extra-tests/tests/LogEntryEventHandler_Tests_FieldMappings.cls +++ b/nebula-logger/extra-tests/tests/LogEntryEventHandler_Tests_FieldMappings.cls @@ -16,30 +16,30 @@ private class LogEntryEventHandler_Tests_FieldMappings { new LoggerFieldMapping__mdt( DeveloperName = 'LoggerScenarioFieldMapping', IsEnabled__c = true, - SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.getDescribe().getName(), - SourceField__c = Schema.LogEntryEvent__e.SomeLoggerScenarioField__c.getDescribe().getName(), - TargetSObjectType__c = Schema.LoggerScenario__c.SObjectType.getDescribe().getName(), - TargetField__c = Schema.LoggerScenario__c.SomeLoggerScenarioField__c.getDescribe().getName() + SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.toString(), + SourceField__c = Schema.LogEntryEvent__e.SomeLoggerScenarioField__c.toString(), + TargetSObjectType__c = Schema.LoggerScenario__c.SObjectType.toString(), + TargetField__c = Schema.LoggerScenario__c.SomeLoggerScenarioField__c.toString() ) ); LoggerFieldMapper.setMock( new LoggerFieldMapping__mdt( DeveloperName = 'LogFieldMapping', IsEnabled__c = true, - SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.getDescribe().getName(), - SourceField__c = Schema.LogEntryEvent__e.SomeLogField__c.getDescribe().getName(), - TargetSObjectType__c = Schema.Log__c.SObjectType.getDescribe().getName(), - TargetField__c = Schema.Log__c.SomeLogField__c.getDescribe().getName() + SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.toString(), + SourceField__c = Schema.LogEntryEvent__e.SomeLogField__c.toString(), + TargetSObjectType__c = Schema.Log__c.SObjectType.toString(), + TargetField__c = Schema.Log__c.SomeLogField__c.toString() ) ); LoggerFieldMapper.setMock( new LoggerFieldMapping__mdt( DeveloperName = 'LogEntryFieldMapping', IsEnabled__c = true, - SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.getDescribe().getName(), - SourceField__c = Schema.LogEntryEvent__e.SomeLogEntryField__c.getDescribe().getName(), - TargetSObjectType__c = Schema.LogEntry__c.SObjectType.getDescribe().getName(), - TargetField__c = Schema.LogEntry__c.SomeLogEntryField__c.getDescribe().getName() + SourceSObjectType__c = Schema.LogEntryEvent__e.SObjectType.toString(), + SourceField__c = Schema.LogEntryEvent__e.SomeLogEntryField__c.toString(), + TargetSObjectType__c = Schema.LogEntry__c.SObjectType.toString(), + TargetField__c = Schema.LogEntry__c.SomeLogEntryField__c.toString() ) ); LogEntryEvent__e logEntryEvent = createLogEntryEvent(); 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 7bc08b3ed..d80cd2306 100644 --- a/nebula-logger/plugins/big-object-archiving/plugin/classes/LogEntryArchivePlugin.cls +++ b/nebula-logger/plugins/big-object-archiving/plugin/classes/LogEntryArchivePlugin.cls @@ -118,7 +118,7 @@ public without sharing class LogEntryArchivePlugin implements LoggerPlugin.Batch } private List requeryLogEntriesToArchive(List logEntries) { - String logLookupRelationshipName = Schema.LogEntry__c.Log__c.getDescribe().getName().removeEnd('__c') + '__r'; + String logLookupRelationshipName = Schema.LogEntry__c.Log__c.toString().removeEnd('__c') + '__r'; List logFieldsToQuery = new List(); for (String fieldName : Schema.Log__c.SObjectType.getDescribe().fields.getMap().keySet()) { logFieldsToQuery.add(logLookupRelationshipName + '.' + fieldName); @@ -134,16 +134,16 @@ public without sharing class LogEntryArchivePlugin implements LoggerPlugin.Batch List logEntryFieldsToQuery = new List(Schema.LogEntry__c.SObjectType.getDescribe().fields.getMap().keySet()); logEntryFieldsToQuery.addAll(logFieldsToQuery); - String tagLookupRelationshipName = Schema.LogEntryTag__c.Tag__c.getDescribe().getName().removeEnd('__c') + '__r'; - String tagNameField = tagLookupRelationshipName + '.' + Schema.LoggerTag__c.Name.getDescribe().getName(); + String tagLookupRelationshipName = Schema.LogEntryTag__c.Tag__c.toString().removeEnd('__c') + '__r'; + String tagNameField = tagLookupRelationshipName + '.' + Schema.LoggerTag__c.Name.toString(); - String logPurgeActionParentFieldName = logLookupRelationshipName + '.' + Schema.Log__c.LogPurgeAction__c.getDescribe().getName(); + String logPurgeActionParentFieldName = logLookupRelationshipName + '.' + Schema.Log__c.LogPurgeAction__c.toString(); String queryTemplate = 'SELECT {0}, (SELECT {1} FROM {2}) FROM {3} WHERE Id IN :logEntries AND {4} = :BIG_OBJECT_LOG_PURGE_ACTION'; List queryInputs = new List{ String.join(logEntryFieldsToQuery, ', '), tagNameField, 'LogEntryTags__r', // TODO replace with strongly-typed reference or namespace-safe string - Schema.LogEntry__c.SObjectType.getDescribe().getName(), + Schema.LogEntry__c.SObjectType.toString(), logPurgeActionParentFieldName }; String query = String.escapeSingleQuotes(String.format(queryTemplate, queryInputs)); @@ -156,9 +156,9 @@ public without sharing class LogEntryArchivePlugin implements LoggerPlugin.Batch for (Integer i = 0; i < parentFieldChainPieces.size(); i++) { Schema.SObjectField field = parentFieldChainPieces.get(i); if (i != lastIndex) { - parentFieldPath += field.getDescribe().getName().removeEnd('__c') + '__r.'; + parentFieldPath += field.toString().removeEnd('__c') + '__r.'; } else { - parentFieldPath += field.getDescribe().getName(); + parentFieldPath += field.toString(); } } return parentFieldPath; diff --git a/nebula-logger/plugins/log-retention-rules/plugin/classes/LogRetentionRulesPlugin.cls b/nebula-logger/plugins/log-retention-rules/plugin/classes/LogRetentionRulesPlugin.cls index fc40b7d23..00d782d8f 100644 --- a/nebula-logger/plugins/log-retention-rules/plugin/classes/LogRetentionRulesPlugin.cls +++ b/nebula-logger/plugins/log-retention-rules/plugin/classes/LogRetentionRulesPlugin.cls @@ -43,15 +43,15 @@ public without sharing class LogRetentionRulesPlugin implements LoggerPlugin.Tri List logFieldNames = new List(Schema.Log__c.SObjectType.getDescribe().fields.getMap().keySet()); logFieldNames.addAll(new List{ 'Owner.Name', 'Owner.Type' }); for (String logFieldName : logFieldNames) { - String logRelationshipPrefix = Schema.LogEntry__c.Log__c.getDescribe().getName().substringBeforeLast('__c') + '__r'; + String logRelationshipPrefix = Schema.LogEntry__c.Log__c.toString().substringBeforeLast('__c') + '__r'; logEntryFieldNames.add(logRelationshipPrefix + '.' + logFieldName); } String queryTemplate = 'SELECT {0} FROM {1} WHERE {2} IN :logEntries'; List queryInputs = new List{ String.join(logEntryFieldNames, ','), - Schema.LogEntry__c.SObjectType.getDescribe().getName(), - Schema.LogEntry__c.Id.getDescribe().getName() + Schema.LogEntry__c.SObjectType.toString(), + Schema.LogEntry__c.Id.toString() }; String logEntryQuery = String.escapeSingleQuotes(String.format(queryTemplate, queryInputs)); return (List) System.Database.query(logEntryQuery); diff --git a/nebula-logger/plugins/slack/plugin/slack/classes/SlackLoggerPlugin.cls b/nebula-logger/plugins/slack/plugin/slack/classes/SlackLoggerPlugin.cls index d96f89255..50a596e76 100644 --- a/nebula-logger/plugins/slack/plugin/slack/classes/SlackLoggerPlugin.cls +++ b/nebula-logger/plugins/slack/plugin/slack/classes/SlackLoggerPlugin.cls @@ -162,7 +162,7 @@ public without sharing class SlackLoggerPlugin implements LoggerPlugin.Triggerab '\nLIMIT 1' + '\n)'; List fieldNames = new List{ - Schema.Log__c.Name.getDescribe().getName(), + Schema.Log__c.Name.toString(), logEntryChildQuery, 'LoggedBy__r.Username', 'TYPEOF Owner WHEN User THEN Username ELSE Name END' @@ -245,7 +245,7 @@ public without sharing class SlackLoggerPlugin implements LoggerPlugin.Triggerab private List createRecordNotificationFields(List fields, SObject record) { List notificationFields = new List(); for (Schema.SObjectField field : fields) { - FieldDto notificationField = this.createRecordNotificationField(field.getDescribe().getName(), field, record); + FieldDto notificationField = this.createRecordNotificationField(field.toString(), field, record); if (notificationField != null) { notificationFields.add(notificationField); } diff --git a/nebula-logger/plugins/slack/plugin/slack/classes/SlackLoggerPlugin_Tests.cls b/nebula-logger/plugins/slack/plugin/slack/classes/SlackLoggerPlugin_Tests.cls index d078b5829..c28694aaf 100644 --- a/nebula-logger/plugins/slack/plugin/slack/classes/SlackLoggerPlugin_Tests.cls +++ b/nebula-logger/plugins/slack/plugin/slack/classes/SlackLoggerPlugin_Tests.cls @@ -279,9 +279,9 @@ private class SlackLoggerPlugin_Tests { @SuppressWarnings('PMD.UnusedLocalVariable') private static List queryLogs(System.LoggingLevel notificationLoggingLevel) { List fieldNames = new List{ - Schema.Log__c.MaxLogEntryLoggingLevelOrdinal__c.getDescribe().getName(), - Schema.Log__c.SendSlackNotification__c.getDescribe().getName(), - Schema.Log__c.SlackNotificationDate__c.getDescribe().getName() + Schema.Log__c.MaxLogEntryLoggingLevelOrdinal__c.toString(), + Schema.Log__c.SendSlackNotification__c.toString(), + Schema.Log__c.SlackNotificationDate__c.toString() }; for (Schema.FieldSetMember fieldSetMember : Schema.SObjectType.Log__c.fieldSets.getMap().get(SlackLoggerPlugin.FIELD_SET_NAME).getFields()) { fieldNames.add(fieldSetMember.getFieldPath());