diff --git a/nebula-logger/core/main/configuration/classes/LoggerConfigurationDataSelector.cls b/nebula-logger/core/main/configuration/classes/LoggerConfigurationDataSelector.cls index 85ef27332..e243d09cb 100644 --- a/nebula-logger/core/main/configuration/classes/LoggerConfigurationDataSelector.cls +++ b/nebula-logger/core/main/configuration/classes/LoggerConfigurationDataSelector.cls @@ -9,7 +9,7 @@ */ // TODO Add Apex docs @SuppressWarnings('PMD.ApexDoc, PMD.ApexCRUDViolation') -public without sharing virtual class LoggerConfigurationDataSelector { +public without sharing class LoggerConfigurationDataSelector { private static final LoggerConfigurationDataSelector INSTANCE = new LoggerConfigurationDataSelector(); @TestVisible @@ -43,7 +43,7 @@ public without sharing virtual class LoggerConfigurationDataSelector { } // TODO decide if LoggerSettings__c should be here (I don't think so) - public virtual List getLogEntryDataMaskRules() { + public List getLogEntryDataMaskRules() { return mockLogEntryDataMaskRules ?? LogEntryDataMaskRule__mdt.getAll().values().deepClone(); } @@ -52,7 +52,7 @@ public without sharing virtual class LoggerConfigurationDataSelector { * including the field `SObjectField__r.QualifiedApiName` that cannot be accessed via `LogEntryTagRule__mdt.getAll()` * @return The cached `List` records */ - public virtual List getLogEntryTagRules() { + public List getLogEntryTagRules() { List rules = [ SELECT Id, SObjectField__r.QualifiedApiName, ComparisonType__c, ComparisonValue__c, Tags__c FROM LogEntryTagRule__mdt @@ -64,39 +64,54 @@ public without sharing virtual class LoggerConfigurationDataSelector { } for (LogEntryTagRule__mdt rule : rules) { - rule.SObjectField__c = rule.SObjectField__r.QualifiedApiName; + rule.SObjectField__c = rule.SObjectField__r.QualifiedApiName ?? rule.SObjectField__c; } return rules; } - public virtual List getLoggerFieldMappings() { - return mockLoggerFieldMappings ?? - [ - SELECT - DeveloperName, - IsEnabled__c, - SourceSObjectType__r.QualifiedApiName, - SourceField__r.QualifiedApiName, - TargetSObjectType__r.QualifiedApiName, - TargetField__r.QualifiedApiName - FROM LoggerFieldMapping__mdt - WHERE IsEnabled__c = TRUE - ]; + public List getLoggerFieldMappings() { + List fieldMappings = [ + SELECT + DeveloperName, + IsEnabled__c, + SourceSObjectType__r.QualifiedApiName, + SourceField__r.QualifiedApiName, + TargetSObjectType__r.QualifiedApiName, + TargetField__r.QualifiedApiName + FROM LoggerFieldMapping__mdt + WHERE IsEnabled__c = TRUE + ]; + + if (mockLoggerFieldMappings != null) { + fieldMappings = mockLoggerFieldMappings; + } + + for (LoggerFieldMapping__mdt fieldMapping : fieldMappings) { + fieldMapping.SourceSObjectType__c = fieldMapping.SourceSObjectType__r.QualifiedApiName ?? fieldMapping.SourceSObjectType__c; + fieldMapping.SourceField__c = fieldMapping.SourceField__r.QualifiedApiName ?? fieldMapping.SourceField__c; + fieldMapping.TargetSObjectType__c = fieldMapping.TargetSObjectType__r.QualifiedApiName ?? fieldMapping.TargetSObjectType__c; + fieldMapping.TargetField__c = fieldMapping.TargetField__r.QualifiedApiName ?? fieldMapping.TargetField__c; + } + + return fieldMappings; } - public virtual Map getLoggerParameters() { + public Map getLoggerParameters() { return mockLoggerParameters ?? LoggerParameter__mdt.getAll().deepClone(); } - public virtual List getLoggerPlugins() { + public List getLoggerPlugins() { return mockLoggerPlugins ?? LoggerPlugin__mdt.getAll().values().deepClone(); } - public virtual List getLoggerScenarioRules() { + public List getLoggerScenarioRules() { return mockLoggerScenarioRules ?? LoggerScenarioRule__mdt.getAll().values().deepClone(); } - public virtual List getLoggerSObjectHandlers() { + public List getLoggerSObjectHandlers() { + // TODO eventually update this method to handle mapping relationship fields to lookup fields, + // Example: handler.SObjectType__c = handler.SObjectType__r.QualifiedApiName; + // Right now, this is handled in LoggerSObjectHandler return mockLoggerSObjectHandlers ?? [ SELECT IsEnabled__c, SObjectHandlerApexClass__c, SObjectType__r.QualifiedApiName, SObjectTypeOverride__c @@ -105,7 +120,7 @@ public without sharing virtual class LoggerConfigurationDataSelector { ]; } - public virtual List getLogStatuses() { + public List getLogStatuses() { return mockLogStatuses ?? LogStatus__mdt.getAll().values().deepClone(); } diff --git a/nebula-logger/core/main/configuration/classes/LoggerFieldMapper.cls b/nebula-logger/core/main/configuration/classes/LoggerFieldMapper.cls index e7c2d754c..b95754f92 100644 --- a/nebula-logger/core/main/configuration/classes/LoggerFieldMapper.cls +++ b/nebula-logger/core/main/configuration/classes/LoggerFieldMapper.cls @@ -76,10 +76,6 @@ public without sharing class LoggerFieldMapper { private static Map>> loadRecords() { Map>> sourceSObjectTypeToTargetFieldMappings = new Map>>(); for (LoggerFieldMapping__mdt fieldMapping : LoggerConfigurationDataSelector.getInstance().getLoggerFieldMappings()) { - fieldMapping.SourceSObjectType__c = fieldMapping.SourceSObjectType__c ?? fieldMapping.SourceSObjectType__r.QualifiedApiName; - fieldMapping.SourceField__c = fieldMapping.SourceField__c ?? fieldMapping.SourceField__r.QualifiedApiName; - fieldMapping.TargetSObjectType__c = fieldMapping.TargetSObjectType__c ?? fieldMapping.TargetSObjectType__r.QualifiedApiName; - fieldMapping.TargetField__c = fieldMapping.TargetField__c ?? fieldMapping.TargetField__r.QualifiedApiName; addFieldMapping(fieldMapping, sourceSObjectTypeToTargetFieldMappings); } diff --git a/nebula-logger/core/main/logger-engine/classes/Logger.cls b/nebula-logger/core/main/logger-engine/classes/Logger.cls index a95882434..986059733 100644 --- a/nebula-logger/core/main/logger-engine/classes/Logger.cls +++ b/nebula-logger/core/main/logger-engine/classes/Logger.cls @@ -129,6 +129,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 - Request ID: ' + REQUEST_ID); System.debug(System.LoggingLevel.INFO, 'Nebula Logger - Organization API Version: ' + getOrganizationApiVersion()); setScenario(getUserSettings().DefaultScenario__c); } diff --git a/nebula-logger/core/tests/configuration/classes/LoggerConfigurationDataSelector_Tests.cls b/nebula-logger/core/tests/configuration/classes/LoggerConfigurationDataSelector_Tests.cls index eceff701f..4c9b23892 100644 --- a/nebula-logger/core/tests/configuration/classes/LoggerConfigurationDataSelector_Tests.cls +++ b/nebula-logger/core/tests/configuration/classes/LoggerConfigurationDataSelector_Tests.cls @@ -87,6 +87,12 @@ private class LoggerConfigurationDataSelector_Tests { FROM LoggerFieldMapping__mdt WHERE IsEnabled__c = TRUE ]; + for (LoggerFieldMapping__mdt fieldMapping : expectedValues) { + fieldMapping.SourceSObjectType__c = fieldMapping.SourceSObjectType__r.QualifiedApiName ?? fieldMapping.SourceSObjectType__c; + fieldMapping.SourceField__c = fieldMapping.SourceField__r.QualifiedApiName ?? fieldMapping.SourceField__c; + fieldMapping.TargetSObjectType__c = fieldMapping.TargetSObjectType__r.QualifiedApiName ?? fieldMapping.TargetSObjectType__c; + fieldMapping.TargetField__c = fieldMapping.TargetField__r.QualifiedApiName ?? fieldMapping.TargetField__c; + } List returnedValues = LoggerConfigurationDataSelector.getInstance().getLoggerFieldMappings(); @@ -201,7 +207,4 @@ private class LoggerConfigurationDataSelector_Tests { System.Assert.areEqual(LoggerConfigurationDataSelector.mockLogStatuses, returnedValues); } - - private class MockLoggerConfigurationDataSelector extends LoggerConfigurationDataSelector { - } } 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 8b9c111f3..ac22259c3 100644 --- a/nebula-logger/core/tests/log-management/classes/LogBatchPurgeController_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogBatchPurgeController_Tests.cls @@ -10,6 +10,11 @@ private class LogBatchPurgeController_Tests { private static final String CAN_EXECUTE_LOG_BATCH_PURGER_PERMISSION = 'CanExecuteLogBatchPurger'; private static final Schema.Profile STANDARD_USER_PROFILE = [SELECT Id FROM Profile WHERE Name IN ('Standard User', 'Usuario estándar', '標準ユーザー')]; + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_should_return_logPurgeAction_options() { List fakeLogPurgeActions = new List{ 'A_FAKE_PURGE_ACTION', 'ANOTHER_ONE', 'SOME_OTHER_PURGE_ACTION' }; diff --git a/nebula-logger/core/tests/log-management/classes/LogBatchPurgeScheduler_Tests.cls b/nebula-logger/core/tests/log-management/classes/LogBatchPurgeScheduler_Tests.cls index b16def365..cf1e75e14 100644 --- a/nebula-logger/core/tests/log-management/classes/LogBatchPurgeScheduler_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogBatchPurgeScheduler_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions, PMD.NcssMethodCount') @IsTest(IsParallel=true) private class LogBatchPurgeScheduler_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_implements_system_schedulable_interface() { Object scheduler = new LogBatchPurgeScheduler(); diff --git a/nebula-logger/core/tests/log-management/classes/LogBatchPurger_Tests.cls b/nebula-logger/core/tests/log-management/classes/LogBatchPurger_Tests.cls index 8c73a75ef..b54a85576 100644 --- a/nebula-logger/core/tests/log-management/classes/LogBatchPurger_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogBatchPurger_Tests.cls @@ -15,6 +15,11 @@ private class LogBatchPurger_Tests { private static LoggerBatchableContext batchInput; private static List pluginRecords; + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @TestSetup static void setupData() { LoggerSObjectHandler.shouldExecute(false); diff --git a/nebula-logger/core/tests/log-management/classes/LogEntryEventStreamController_Tests.cls b/nebula-logger/core/tests/log-management/classes/LogEntryEventStreamController_Tests.cls index 299f7fb85..ac242fdd2 100644 --- a/nebula-logger/core/tests/log-management/classes/LogEntryEventStreamController_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogEntryEventStreamController_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions, PMD.NcssMethodCount') @IsTest private class LogEntryEventStreamController_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_should_return_is_enabled_parameter() { Boolean mockValue = false; diff --git a/nebula-logger/core/tests/log-management/classes/LogEntryFieldSetPicklist_Tests.cls b/nebula-logger/core/tests/log-management/classes/LogEntryFieldSetPicklist_Tests.cls index eb1547d65..9e5cc6b04 100644 --- a/nebula-logger/core/tests/log-management/classes/LogEntryFieldSetPicklist_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogEntryFieldSetPicklist_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.MethodNamingConventions') @IsTest(IsParallel=true) private class LogEntryFieldSetPicklist_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_should_return_null_for_default_value_when_empty_value_is_configured() { String emptyFieldSetName = ''; 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 86f4be35b..dd24d66f7 100644 --- a/nebula-logger/core/tests/log-management/classes/LogEntryHandler_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogEntryHandler_Tests.cls @@ -8,6 +8,11 @@ private class LogEntryHandler_Tests { private static final Boolean IS_OMNISTUDIO_ENABLED = System.Type.forName('Schema.OmniProcess') != null; + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @TestSetup static void setupData() { LoggerSObjectHandler.shouldExecute(false); diff --git a/nebula-logger/core/tests/log-management/classes/LogEntryMetadataViewerController_Tests.cls b/nebula-logger/core/tests/log-management/classes/LogEntryMetadataViewerController_Tests.cls index 48923532d..fe7b7768d 100644 --- a/nebula-logger/core/tests/log-management/classes/LogEntryMetadataViewerController_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogEntryMetadataViewerController_Tests.cls @@ -6,6 +6,8 @@ private class LogEntryMetadataViewerController_Tests { private static final String SOURCE_METADATA_ORIGIN = 'Origin'; static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); LogManagementDataSelector.setMock(MOCK_SELECTOR); } diff --git a/nebula-logger/core/tests/log-management/classes/LogEntryTagHandler_Tests.cls b/nebula-logger/core/tests/log-management/classes/LogEntryTagHandler_Tests.cls index 8be4f1961..3a474e393 100644 --- a/nebula-logger/core/tests/log-management/classes/LogEntryTagHandler_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogEntryTagHandler_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions, PMD.NcssMethodCount') @IsTest(IsParallel=true) private class LogEntryTagHandler_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @TestSetup static void setupData() { LoggerSObjectHandler.shouldExecute(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 b69566f72..0ea69c040 100644 --- a/nebula-logger/core/tests/log-management/classes/LogHandler_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogHandler_Tests.cls @@ -13,6 +13,11 @@ private class LogHandler_Tests { private static final String FIRST_STATUS = Schema.Log__c.Status__c.getDescribe().getPicklistValues().get(0).getValue(); private static final String SECOND_STATUS = Schema.Log__c.Status__c.getDescribe().getPicklistValues().get(1).getValue(); + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_should_return_the_log_sobjectType() { System.Assert.areEqual(Schema.Log__c.SObjectType, new LogHandler().getSObjectType()); 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 95cfa4e32..435553e31 100644 --- a/nebula-logger/core/tests/log-management/classes/LogManagementDataSelector_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogManagementDataSelector_Tests.cls @@ -9,6 +9,11 @@ private class LogManagementDataSelector_Tests { @TestVisible private static final Boolean IS_OMNISTUDIO_ENABLED = System.Type.forName('Schema.OmniProcess') != null; + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_dynamically_queries_all_records_for_specified_sobject_type_and_fields() { Schema.SObjectType targetSObjectType = Schema.Organization.SObjectType; diff --git a/nebula-logger/core/tests/log-management/classes/LogMassDeleteExtension_Tests.cls b/nebula-logger/core/tests/log-management/classes/LogMassDeleteExtension_Tests.cls index c555f19a7..12d845a51 100644 --- a/nebula-logger/core/tests/log-management/classes/LogMassDeleteExtension_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogMassDeleteExtension_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions, PMD.NcssMethodCount') @IsTest(IsParallel=false) private class LogMassDeleteExtension_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @TestSetup static void setupData() { LoggerSObjectHandler.shouldExecute(false); diff --git a/nebula-logger/core/tests/log-management/classes/LogViewerController_Tests.cls b/nebula-logger/core/tests/log-management/classes/LogViewerController_Tests.cls index 327b903ff..af97ae2dc 100644 --- a/nebula-logger/core/tests/log-management/classes/LogViewerController_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LogViewerController_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.MethodNamingConventions') @IsTest(IsParallel=true) private class LogViewerController_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @TestSetup static void setupData() { LoggerSObjectHandler.shouldExecute(false); 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..34c0c5c29 100644 --- a/nebula-logger/core/tests/log-management/classes/LoggerBatchableContext_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LoggerBatchableContext_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.MethodNamingConventions') @IsTest(IsParallel=true) private class LoggerBatchableContext_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_constructs_instance_when_both_parameters_provided() { Database.BatchableContext mockBatchableContext = new LoggerMockDataCreator.MockBatchableContext(); diff --git a/nebula-logger/core/tests/log-management/classes/LoggerEmailSender_Tests.cls b/nebula-logger/core/tests/log-management/classes/LoggerEmailSender_Tests.cls index 86ae4a959..90e123eb6 100644 --- a/nebula-logger/core/tests/log-management/classes/LoggerEmailSender_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LoggerEmailSender_Tests.cls @@ -21,6 +21,11 @@ private class LoggerEmailSender_Tests { set; } + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_should_indicate_email_deliverability_is_based_on_email_deliverability_when_org_limits_not_exceeded() { System.OrgLimit singleEmailOrgLimit = OrgLimits.getMap().get('SingleEmail'); 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 7ebdff91c..23c04a984 100644 --- a/nebula-logger/core/tests/log-management/classes/LoggerHomeHeaderController_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LoggerHomeHeaderController_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.MethodNamingConventions') @IsTest(IsParallel=true) private class LoggerHomeHeaderController_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest public static void it_returns_environment_details_when_status_api_callout_is_enabled() { LoggerParameter.setMock(new LoggerParameter__mdt(DeveloperName = 'CallStatusApi', Value__c = System.JSON.serialize(true))); 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..419098b14 100644 --- a/nebula-logger/core/tests/log-management/classes/LoggerSObjectMetadata_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LoggerSObjectMetadata_Tests.cls @@ -12,6 +12,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.ApexUnitTestClassShouldHaveAsserts, PMD.MethodNamingConventions') @IsTest(IsParallel=true) private class LoggerSObjectMetadata_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_should_return_schema_for_specified_sobject_api_name() { Schema.SObjectType userSObjectType = Schema.User.SObjectType; diff --git a/nebula-logger/core/tests/log-management/classes/LoggerScenarioHandler_Tests.cls b/nebula-logger/core/tests/log-management/classes/LoggerScenarioHandler_Tests.cls index 00ff95eec..4c4620128 100644 --- a/nebula-logger/core/tests/log-management/classes/LoggerScenarioHandler_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LoggerScenarioHandler_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions, PMD.NcssMethodCount') @IsTest(IsParallel=true) private class LoggerScenarioHandler_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_should_return_the_loggerScenario_sobjectType() { System.Assert.areEqual(Schema.LoggerScenario__c.SObjectType, new LoggerScenarioHandler().getSObjectType()); 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 250f72484..bad234bbf 100644 --- a/nebula-logger/core/tests/log-management/classes/LoggerSettingsController_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LoggerSettingsController_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions') @IsTest(IsParallel=false) private class LoggerSettingsController_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_should_return_loggingLevel_picklist_options() { Integer expectedLoggingLevelSize = System.LoggingLevel.values().size() - 1; // LoggingLEVEL.NONE and System.LoggingLevel.INTERNAL are ignored, '--NONE--' is automatically included diff --git a/nebula-logger/core/tests/log-management/classes/LoggerTagHandler_Tests.cls b/nebula-logger/core/tests/log-management/classes/LoggerTagHandler_Tests.cls index 9afe014f0..202862fe6 100644 --- a/nebula-logger/core/tests/log-management/classes/LoggerTagHandler_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/LoggerTagHandler_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions, PMD.NcssMethodCount') @IsTest(IsParallel=true) private class LoggerTagHandler_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_should_return_the_loggerTag_sobjectType() { System.Assert.areEqual(Schema.LoggerTag__c.SObjectType, new LoggerTagHandler().getSObjectType()); diff --git a/nebula-logger/core/tests/log-management/classes/RelatedLogEntriesController_Tests.cls b/nebula-logger/core/tests/log-management/classes/RelatedLogEntriesController_Tests.cls index c106b2c77..418cdb5c2 100644 --- a/nebula-logger/core/tests/log-management/classes/RelatedLogEntriesController_Tests.cls +++ b/nebula-logger/core/tests/log-management/classes/RelatedLogEntriesController_Tests.cls @@ -9,6 +9,11 @@ private class RelatedLogEntriesController_Tests { private static final Integer TOTAL_LOG_ENTRIES = 10; private static final Integer TOTAL_RELATED_LOG_ENTRIES = 7; + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + static String getFieldSetName() { Schema.FieldSet fieldSet = Schema.SObjectType.LogEntry__c.fieldSets.getMap().values().get(0); String fieldSetNamespacePrefix = String.isBlank(fieldSet.getNameSpace()) ? '' : fieldSet.getNameSpace() + '__'; diff --git a/nebula-logger/core/tests/logger-engine/classes/CallableLogger_Tests.cls b/nebula-logger/core/tests/logger-engine/classes/CallableLogger_Tests.cls index 715d8d739..0177afa18 100644 --- a/nebula-logger/core/tests/logger-engine/classes/CallableLogger_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/CallableLogger_Tests.cls @@ -12,6 +12,8 @@ private class CallableLogger_Tests { private static final String TEST_OMNI_PROCESS_ID = '0jNDL000000Cbac2AC'; static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); CallableLogger.returnLogEntryEventBuilderInOutput = true; } 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..7674cb465 100644 --- a/nebula-logger/core/tests/logger-engine/classes/ComponentLogger_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/ComponentLogger_Tests.cls @@ -8,6 +8,11 @@ ) @IsTest(IsParallel=true) private class ComponentLogger_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_should_return_logger_settings() { LoggerSettings__c loggerSettings = LoggerSettings__c.getInstance(); 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 8ebfbac13..c4f95b9bf 100644 --- a/nebula-logger/core/tests/logger-engine/classes/FlowCollectionLogEntry_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/FlowCollectionLogEntry_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions, PMD.NcssMethodCount') @IsTest(IsParallel=true) private class FlowCollectionLogEntry_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + static FlowCollectionLogEntry createFlowCollectionLogEntry() { FlowCollectionLogEntry flowCollectionEntry = new FlowCollectionLogEntry(); flowCollectionEntry.flowName = 'MyFlowOrProcessBuilder'; diff --git a/nebula-logger/core/tests/logger-engine/classes/FlowLogEntry_Tests.cls b/nebula-logger/core/tests/logger-engine/classes/FlowLogEntry_Tests.cls index 05b9a27cf..4baa4908b 100644 --- a/nebula-logger/core/tests/logger-engine/classes/FlowLogEntry_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/FlowLogEntry_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions, PMD.NcssMethodCount') @IsTest(IsParallel=true) private class FlowLogEntry_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + static FlowLogEntry createFlowLogEntry() { FlowLogEntry flowEntry = new FlowLogEntry(); flowEntry.flowName = 'MyFlowOrProcessBuilder'; diff --git a/nebula-logger/core/tests/logger-engine/classes/FlowLogger_Tests.cls b/nebula-logger/core/tests/logger-engine/classes/FlowLogger_Tests.cls index 6e0489e46..a51ffea5b 100644 --- a/nebula-logger/core/tests/logger-engine/classes/FlowLogger_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/FlowLogger_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions, PMD.NcssMethodCount') @IsTest(IsParallel=true) private class FlowLogger_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_should_add_entry_to_logger_buffer() { LoggerDataStore.setMock(LoggerMockDataStore.getEventBus()); 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 4c43f7d46..1a6c875ef 100644 --- a/nebula-logger/core/tests/logger-engine/classes/FlowRecordLogEntry_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/FlowRecordLogEntry_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions, PMD.NcssMethodCount') @IsTest(IsParallel=true) private class FlowRecordLogEntry_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + static FlowRecordLogEntry createFlowRecordLogEntry() { FlowRecordLogEntry flowRecordEntry = new FlowRecordLogEntry(); flowRecordEntry.flowName = 'MyFlowOrProcessBuilder'; 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 85a96c6df..f5ae095b5 100644 --- a/nebula-logger/core/tests/logger-engine/classes/LogEntryEventBuilder_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/LogEntryEventBuilder_Tests.cls @@ -9,6 +9,8 @@ @IsTest(IsParallel=false) private class LogEntryEventBuilder_Tests { static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); LoggerStackTrace.ignoreOrigin(LogEntryEventBuilder.class); } 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 fcaf59377..4851b7649 100644 --- a/nebula-logger/core/tests/logger-engine/classes/LoggerDataStore_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/LoggerDataStore_Tests.cls @@ -9,6 +9,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions') @IsTest(IsParallel=true) private class LoggerDataStore_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + // Database DML tests @IsTest static void it_should_delete_record() { 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..ec686d804 100644 --- a/nebula-logger/core/tests/logger-engine/classes/LoggerSObjectHandler_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/LoggerSObjectHandler_Tests.cls @@ -13,6 +13,11 @@ private class LoggerSObjectHandler_Tests { private static final String FAKE_PROFILE_NAME = 'Some String'; + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_should_return_configured_sobject_handler() { Schema.SObjectType sobjectType = new MockSObjectHandler().getSObjectType(); 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 5ea0c6a26..b60fefe35 100644 --- a/nebula-logger/core/tests/logger-engine/classes/Logger_Tests.cls +++ b/nebula-logger/core/tests/logger-engine/classes/Logger_Tests.cls @@ -6,6 +6,11 @@ @SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ExcessiveParameterList, PMD.MethodNamingConventions, PMD.NcssMethodCount, PMD.NcssTypeCount') @IsTest(IsParallel=true) private class Logger_Tests { + static { + // Don't use the org's actual custom metadata records when running tests + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_should_return_version_number() { String expectedVersionNumber = Logger.CURRENT_VERSION_NUMBER; diff --git a/nebula-logger/extra-tests/tests/LogEntryEventHandler_Tests_FieldMappings.cls b/nebula-logger/extra-tests/tests/LogEntryEventHandler_Tests_FieldMappings.cls index 7f79fae96..cf57d8aec 100644 --- a/nebula-logger/extra-tests/tests/LogEntryEventHandler_Tests_FieldMappings.cls +++ b/nebula-logger/extra-tests/tests/LogEntryEventHandler_Tests_FieldMappings.cls @@ -6,6 +6,10 @@ @SuppressWarnings('PMD.ApexDoc, PMD.MethodNamingConventions') @IsTest(IsParallel=false) private class LogEntryEventHandler_Tests_FieldMappings { + static { + LoggerConfigurationDataSelector.useMocks(); + } + @IsTest static void it_should_use_field_mappings_on_logger_scenario_and_log_and_log_entry_when_mappings_have_been_configured() { LoggerDataStore.setMock(LoggerMockDataStore.getEventBus());