Skip to content

Commit

Permalink
Simplified the setup of the test logger instance
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-baillie-ortoo committed Apr 19, 2022
1 parent c7a6997 commit 912d43f
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void query_whenCalledTwiceByUserWithAccessToCache_onlyIssuesOneSoql() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement = 'SELECT Id FROM Account';
Expand Down Expand Up @@ -36,7 +35,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void query_org_whenCalledTwiceByUserWithAccessToCache_onlyIssuesOneSoql() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement = 'SELECT Id FROM Account';
Expand Down Expand Up @@ -66,7 +64,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void query_whenCalledTwiceByUserWithoutAccessToCache_issuesTwoSoqls() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement = 'SELECT Id FROM Account';
Expand All @@ -93,7 +90,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void clearCacheFor_whenGivenSoqlThatWasExecuted_clearsCacheForThatStatement() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement = 'SELECT Id FROM Account';
Expand Down Expand Up @@ -124,7 +120,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void clearCacheFor_whenGivenSoqlThatWasExecuted_willNotClearCacheForOthers() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement1 = 'SELECT Id FROM Account';
Expand Down Expand Up @@ -152,7 +147,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void clearCacheFor_whenGivenSoqlThatHasNotBeenExecuted_willNotThrow() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement = 'SELECT Id FROM Account';
Expand All @@ -173,7 +167,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void clearCacheFor_whenTheUserDoesNotHaveAccessToCache_throwsAnException() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement = 'SELECT Id FROM Account';
Expand Down Expand Up @@ -202,7 +195,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void query_whenRanFor100Queries_willNotThrow()
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

List<String> soqlStatements = new List<String>();
Expand Down Expand Up @@ -241,7 +233,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void query_session_whenCalledTwiceByUserWithAccessToCache_onlyIssuesOneSoql() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement = 'SELECT Id FROM Account';
Expand All @@ -267,7 +258,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void query_session_whenCalledTwiceByUserWithoutAccessToCache_issuesOneSoql() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement = 'SELECT Id FROM Account';
Expand All @@ -289,7 +279,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void clearCacheFor_session_whenGivenSoqlThatWasExecuted_clearsCacheForThatStatement() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement = 'SELECT Id FROM Account';
Expand Down Expand Up @@ -317,7 +306,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void clearCacheFor_session_whenGivenSoqlThatWasExecuted_willNotClearCacheForOthers() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement1 = 'SELECT Id FROM Account';
Expand Down Expand Up @@ -346,7 +334,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void clearCacheFor_session_whenGivenSoqlThatHasNotBeenExecuted_willNotThrow() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement = 'SELECT Id FROM Account';
Expand All @@ -367,7 +354,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void clearCacheFor_session_whenTheUserDoesNotHaveAccessToTheOrgCache_willNotThrow() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement = 'SELECT Id FROM Account';
Expand All @@ -388,7 +374,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void query_session_whenRanFor100Queries_willNotThrow()
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

List<String> soqlStatements = new List<String>();
Expand Down Expand Up @@ -427,7 +412,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void query_none_whenCalledTwiceByUserWithAccessToCache_issuesTwoSoqls() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement = 'SELECT Id FROM Account';
Expand All @@ -450,7 +434,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void query_none_whenCalledTwiceByUserWithoutAccessToCache_issuesTwoSoqls() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement = 'SELECT Id FROM Account';
Expand All @@ -473,7 +456,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void clearCacheFor_none_doesNotAffectTheNumberOfSoqlsIssued() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement = 'SELECT Id FROM Account';
Expand All @@ -498,7 +480,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void clearCacheFor_none_whenTheUserDoesNotHaveAccessToCache_throwsAnException() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

String soqlStatement = 'SELECT Id FROM Account';
Expand All @@ -519,7 +500,6 @@ private without sharing class CachedSoqlExecutorTest
@isTest
private static void query_none_whenRanFor100Queries_willNotThrow() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

List<String> soqlStatements = new List<String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class TestLoggerService implements ILoggerService

public List<String> methods = new List<String>();
public List<List<Object>> parameters = new List<List<Object>>();
Boolean defaultLoggingEnabledReturns = false;
Boolean defaultLoggingEnabledReturns = true;
Boolean loggingThrowsException = false;

public TestLoggerService clearLogHistory()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ private without sharing class ServiceUtilsTest
@isTest
private static void logAndRethrow_whenGivenAStandardException_logsItAndRethrowsIt() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

DmlException exceptionToLog = new DmlException( 'The exception to log' );
Expand All @@ -28,7 +27,6 @@ private without sharing class ServiceUtilsTest
@isTest
private static void logAndRethrow_whenGivenAnOrtooException_logsItStripsItAndRethrowsIt() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

Amoss_Instance exceptionController = new Amoss_Instance( ortoo_Exception.class );
Expand Down Expand Up @@ -58,7 +56,6 @@ private without sharing class ServiceUtilsTest
@isTest
private static void logAndRethrow_whenGivenAValidationException_willNotLogIt() // NOPMD: Test method name format
{
TestLoggerUtils.switchLoggingOn();
TestLoggerService logger = TestLoggerUtils.registerTestLoggerService();

Exception exceptionToLog = new Exceptions.ValidationException( 'ValidationFailed' );
Expand Down

0 comments on commit 912d43f

Please sign in to comment.