forked from apex-enterprise-patterns/fflib-apex-common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set the default logging level in the logging service implementation
Reduced WARNING to WARN in order to match System.debug Added test for the null logger
- Loading branch information
1 parent
ae77a3e
commit 53caeec
Showing
11 changed files
with
141 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
framework/default/modules/logger/services/logger/classes/ILoggerService.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
framework/default/modules/logger/services/logger/classes/tests/NullLoggerServiceImplTest.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
@isTest | ||
private without sharing class NullLoggerServiceImplTest | ||
{ | ||
@isTest | ||
private static void getDefaultLoggingEnabled_returnsFalse() // NOPMD: Test method name format | ||
{ | ||
ILoggerService loggerServiceImpl = new NullLoggerServiceImpl(); | ||
|
||
System.assertEquals( false, loggerServiceImpl.getDefaultLoggingEnabled( LoggerService.Level.ERROR ), 'getDefaultLoggingEnabled, when called with ERROR, returns false' ); | ||
System.assertEquals( false, loggerServiceImpl.getDefaultLoggingEnabled( LoggerService.Level.WARN ), 'getDefaultLoggingEnabled, when called with WARN, returns false' ); | ||
System.assertEquals( false, loggerServiceImpl.getDefaultLoggingEnabled( LoggerService.Level.INFO ), 'getDefaultLoggingEnabled, when called with INFO, returns false' ); | ||
} | ||
|
||
@isTest | ||
private static void log_whenGivenLogLevelAndMessage_doNothing() // NOPMD: Test method name format | ||
{ | ||
Application.SERVICE.setMock( ILoggerService.class, new NullLoggerServiceImpl() ); | ||
|
||
LoggerService.Level logLevel = null; | ||
String message = null; | ||
|
||
Test.startTest(); | ||
LoggerService.log( logLevel, message ); | ||
Test.stopTest(); | ||
|
||
System.assert( true, 'log, when given a log level and message, will do nothing' ); | ||
} | ||
|
||
@isTest | ||
private static void log_whenGivenLogLevelMessageAndId_doNothing() // NOPMD: Test method name format | ||
{ | ||
Application.SERVICE.setMock( ILoggerService.class, new NullLoggerServiceImpl() ); | ||
|
||
LoggerService.Level logLevel = null; | ||
String message = null; | ||
Id sobjectId = null; | ||
|
||
Test.startTest(); | ||
LoggerService.log( logLevel, message, sobjectId ); | ||
Test.stopTest(); | ||
|
||
System.assert( true, 'log, when given a log level, message and sobject Id, will do nothing' ); | ||
} | ||
|
||
@isTest | ||
private static void log_whenGivenAnException_doNothing() // NOPMD: Test method name format | ||
{ | ||
Application.SERVICE.setMock( ILoggerService.class, new NullLoggerServiceImpl() ); | ||
|
||
Exception e = null; | ||
|
||
Test.startTest(); | ||
LoggerService.log( e ); | ||
Test.stopTest(); | ||
|
||
System.assert( true, 'log, when given an exception, will do nothing' ); | ||
} | ||
|
||
@isTest | ||
private static void log_whenGivenAnExceptionAndAnId_doNothing() // NOPMD: Test method name format | ||
{ | ||
Application.SERVICE.setMock( ILoggerService.class, new NullLoggerServiceImpl() ); | ||
|
||
Exception e = null; | ||
Id sobjectId = null; | ||
|
||
Test.startTest(); | ||
LoggerService.log( e, sobjectId ); | ||
Test.stopTest(); | ||
|
||
System.assert( true, 'log, when given an exception and an sobject Id, will do nothing' ); | ||
} | ||
|
||
@isTest | ||
private static void log_whenGivenADmlExceptionAndAnId_doNothing() // NOPMD: Test method name format | ||
{ | ||
Application.SERVICE.setMock( ILoggerService.class, new NullLoggerServiceImpl() ); | ||
|
||
DmlException e = null; | ||
Id sobjectId = null; | ||
|
||
Test.startTest(); | ||
LoggerService.log( e, sobjectId ); | ||
Test.stopTest(); | ||
|
||
System.assert( true, 'log, when given a dml exception and an sobject Id, will do nothing' ); | ||
} | ||
|
||
@isTest | ||
private static void log_whenGivenAnOrtooExceptionAndAnId_doNothing() // NOPMD: Test method name format | ||
{ | ||
Application.SERVICE.setMock( ILoggerService.class, new NullLoggerServiceImpl() ); | ||
|
||
ortoo_Exception e = null; | ||
Id sobjectId = null; | ||
|
||
Test.startTest(); | ||
LoggerService.log( e, sobjectId ); | ||
Test.stopTest(); | ||
|
||
System.assert( true, 'log, when given an ortoo exception and an sobject Id, will do nothing' ); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...fault/modules/logger/services/logger/classes/tests/NullLoggerServiceImplTest.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>54.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
8 changes: 4 additions & 4 deletions
8
..._WARNING_Level_Messages__c.field-meta.xml → ...Log_WARN_Level_Messages__c.field-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<fullName>Log_WARNING_Level_Messages__c</fullName> | ||
<fullName>Log_WARN_Level_Messages__c</fullName> | ||
<defaultValue>false</defaultValue> | ||
<description>Should messages with the level of 'WARNING' be logged?</description> | ||
<description>Should messages with the level of 'WARN' be logged?</description> | ||
<externalId>false</externalId> | ||
<inlineHelpText>Should messages with the level of 'WARNING' be logged?</inlineHelpText> | ||
<label>Log WARNING Level Messages</label> | ||
<inlineHelpText>Should messages with the level of 'WARN' be logged?</inlineHelpText> | ||
<label>Log WARN Level Messages</label> | ||
<trackTrending>false</trackTrending> | ||
<type>Checkbox</type> | ||
</CustomField> |
5 changes: 5 additions & 0 deletions
5
...standard-services/default/classes/services/permissions-service/PermissionsServiceImpl.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters