Skip to content

Commit

Permalink
[WIP] Created LoggerConfigurationDataSelector class, and added actual…
Browse files Browse the repository at this point in the history
… CMDT records to the extra-tests folder to use for integration tests in the pipeline
  • Loading branch information
jongpie committed Jul 7, 2024
1 parent 4d56ecb commit d6ca13a
Show file tree
Hide file tree
Showing 12 changed files with 482 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//------------------------------------------------------------------------------------------------//
// 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. //
//------------------------------------------------------------------------------------------------//

/**
* @group Configuration
* @description Selector class used for all queries that are specific to the configuration layer
*/
public without sharing virtual class LoggerConfigurationDataSelector {
private static LoggerConfigurationDataSelector instance = new LoggerConfigurationDataSelector();

@SuppressWarnings('PMD.EmptyStatementBlock')
@TestVisible
private LoggerConfigurationDataSelector() {
}

/**
* @description The instance `LoggerConfigurationDataSelector` used for any querying specific to the configuration layer
* @return The singleton instance of `LoggerConfigurationDataSelector`
*/
public static LoggerConfigurationDataSelector getInstance() {
return instance;
}

// TODO decide if LoggerSettings__c should be here (I don't think so)
public virtual List<LogEntryDataMaskRule__mdt> getLogEntryDataMaskRules() {
return LogEntryDataMaskRule__mdt.getAll().values();
}

public virtual List<LogEntryTagRule__mdt> getLogEntryTagRules() {
return LogEntryTagRule__mdt.getAll().values();
}

// public virtual List<LoggerFieldMapping__mdt> getLoggerFieldMappings() {
// return [
// SELECT
// DeveloperName,
// IsEnabled__c,
// SourceSObjectType__r.QualifiedApiName,
// SourceField__r.QualifiedApiName,
// TargetSObjectType__r.QualifiedApiName,
// TargetField__r.QualifiedApiName
// FROM LoggerFieldMapping__mdt
// WHERE IsEnabled__c = TRUE
// ];
// }

public virtual List<LoggerParameter__mdt> getLoggerParameters() {
return LoggerParameter__mdt.getAll().values();
}

public virtual List<LoggerPlugin__mdt> getLoggerPlugins() {
return LoggerPlugin__mdt.getAll().values();
}

public virtual List<LoggerScenarioRule__mdt> getLoggerScenarioRules() {
return LoggerScenarioRule__mdt.getAll().values();
}

public virtual List<LoggerSObjectHandler__mdt> getLoggerSObjectHandlers() {
return LoggerSObjectHandler__mdt.getAll().values();
}

public virtual List<LogStatus__mdt> getLogStatuses() {
return LogStatus__mdt.getAll().values();
}

@TestVisible
private static void setMock(LoggerConfigurationDataSelector mockSelectorInstance) {
instance = mockSelectorInstance;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>61.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<CustomMetadata
xmlns="http://soap.sforce.com/2006/04/metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<label>Mastercard Credit Card Number</label>
<protected>false</protected>
<values>
<field>ApplyToMessage__c</field>
<value xsi:type="xsd:boolean">true</value>
</values>
<values>
<field>ApplyToRecordJson__c</field>
<value xsi:type="xsd:boolean">true</value>
</values>
<values>
<field>IsEnabled__c</field>
<value xsi:type="xsd:boolean">true</value>
</values>
<values>
<field>ReplacementRegEx__c</field>
<value xsi:type="xsd:string">$1****-****-****-$5</value>
</values>
<values>
<field>SensitiveDataRegEx__c</field>
<value xsi:type="xsd:string">(^|[ ])(5\d{3})[- ]*(\d{4})[- ]*(\d{4})[- ]*(\d{4})</value>
</values>
</CustomMetadata>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Some Example</label>
<protected>false</protected>
<values>
<field>ComparisonType__c</field>
<value xsi:type="xsd:string">CONTAINS</value>
</values>
<values>
<field>ComparisonValue__c</field>
<value xsi:type="xsd:string">some value</value>
</values>
<values>
<field>IsEnabled__c</field>
<value xsi:type="xsd:boolean">true</value>
</values>
<values>
<field>SObjectField__c</field>
<value xsi:type="xsd:string">Message__c</value>
</values>
<values>
<field>SObjectType__c</field>
<value xsi:type="xsd:string">LogEntry__c</value>
</values>
<values>
<field>Tags__c</field>
<value xsi:type="xsd:string">Special tag
Another tag
And yet again, one more tag</value>
</values>
</CustomMetadata>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<CustomMetadata
xmlns="http://soap.sforce.com/2006/04/metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<label>Some Example</label>
<protected>false</protected>
<values>
<field>IsActive__c</field>
<value xsi:type="xsd:boolean">true</value>
</values>
<values>
<field>IsClosed__c</field>
<value xsi:type="xsd:boolean">true</value>
</values>
<values>
<field>IsResolved__c</field>
<value xsi:type="xsd:boolean">true</value>
</values>
</CustomMetadata>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Some Example</label>
<protected>false</protected>
<values>
<field>IsEnabled__c</field>
<value xsi:type="xsd:boolean">true</value>
</values>
<values>
<field>SourceField__c</field>
<value xsi:type="xsd:string">Message__c</value>
</values>
<values>
<field>SourceSObjectType__c</field>
<value xsi:type="xsd:string">LogEntryEvent__e</value>
</values>
<values>
<field>TargetField__c</field>
<value xsi:type="xsd:string">Message__c</value>
</values>
<values>
<field>TargetSObjectType__c</field>
<value xsi:type="xsd:string">LogEntry__c</value>
</values>
</CustomMetadata>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<CustomMetadata
xmlns="http://soap.sforce.com/2006/04/metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<label>Some Example</label>
<protected>false</protected>
<values>
<field>Comments__c</field>
<value xsi:nil="true" />
</values>
<values>
<field>Description__c</field>
<value xsi:nil="true" />
</values>
<values>
<field>Value__c</field>
<value xsi:type="xsd:string">Some example value</value>
</values>
</CustomMetadata>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Some Example</label>
<protected>true</protected>
<values>
<field>BatchPurgerApexClass__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>BatchPurgerExecutionOrder__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>BatchPurgerFlowName__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>Description__c</field>
<value xsi:type="xsd:string">Some example plugin configuration</value>
</values>
<values>
<field>ExecutionOrder__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>IsEnabled__c</field>
<value xsi:type="xsd:boolean">true</value>
</values>
<values>
<field>Link__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>PluginApiName__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>PluginType__c</field>
<value xsi:type="xsd:string">Apex</value>
</values>
<values>
<field>SObjectHandlerApexClass__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>SObjectHandlerExecutionOrder__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>SObjectHandlerFlowName__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>SObjectType__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>VersionNumber__c</field>
<value xsi:nil="true"/>
</values>
</CustomMetadata>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<CustomMetadata
xmlns="http://soap.sforce.com/2006/04/metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<label>Some Example config</label>
<protected>false</protected>
<values>
<field>IsEnabled__c</field>
<value xsi:type="xsd:boolean">true</value>
</values>
<values>
<field>SObjectHandlerApexClass__c</field>
<value xsi:type="xsd:string">SomeOtherHandler</value>
</values>
<values>
<field>SObjectTypeOverride__c</field>
<value xsi:type="xsd:string">Account</value>
</values>
<values>
<field>SObjectType__c</field>
<value xsi:nil="true" />
</values>
</CustomMetadata>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Some Example</label>
<protected>false</protected>
<values>
<field>EndTime__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>IsAnonymousModeEnabled__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>IsApexSystemDebugLoggingEnabled__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>IsDataMaskingEnabled__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>IsEnabled__c</field>
<value xsi:type="xsd:boolean">true</value>
</values>
<values>
<field>IsJavaScriptConsoleLoggingEnabled__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>IsLogAssignmentEnabled__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>IsLogRetentionOverrideEnabled__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>IsLoggerEnabled__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>IsPlatformEventStorageLocationEnabled__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>IsRecordFieldStrippingEnabled__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>IsSavingEnabled__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>NumberOfDaysToRetainLogs__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>PlatformEventStorageLocation__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>SaveMethod__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>Scenario__c</field>
<value xsi:type="xsd:string">Some example scenario</value>
</values>
<values>
<field>StartTime__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>UserLoggingLevel__c</field>
<value xsi:nil="true"/>
</values>
</CustomMetadata>
Loading

0 comments on commit d6ca13a

Please sign in to comment.