From d33aa470aa870c5b71a2def6f60d5a51bb03b331 Mon Sep 17 00:00:00 2001 From: Heber <Anthony.Heber@gmail.com> Date: Wed, 27 Nov 2024 13:11:58 -0700 Subject: [PATCH] Simplify tests --- dlrs/main/classes/RollupCalculateJobTest.cls | 19 ++++++++----------- dlrs/main/classes/RollupJobTest.cls | 19 ++++++++----------- dlrs/main/classes/UtilitiesTest.cls | 3 +-- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/dlrs/main/classes/RollupCalculateJobTest.cls b/dlrs/main/classes/RollupCalculateJobTest.cls index e6a6ab84..648a65a4 100644 --- a/dlrs/main/classes/RollupCalculateJobTest.cls +++ b/dlrs/main/classes/RollupCalculateJobTest.cls @@ -261,17 +261,14 @@ private class RollupCalculateJobTest { RollupCalculateJob job = new RollupCalculateJob(rollupCfg.Id, 'Id != NULL'); String jobId; - System.runAs(new User(Id = UserInfo.getUserId())) { - Test.startTest(); - Assert.areEqual( - true, - Utilities.userHasCustomPermission(permName), - 'Expected user to have ' + permName - ); - // go into runAs because we need to get the perms recalculated - jobId = Database.executeBatch(job); - Test.stopTest(); - } + Test.startTest(); + Assert.isTrue( + Utilities.userHasCustomPermission(permName), + 'Expected user to have ' + permName + ); + // go into runAs because we need to get the perms recalculated + jobId = Database.executeBatch(job); + Test.stopTest(); AsyncApexJob asyncJob = [ SELECT Id, Status, JobItemsProcessed, TotalJobItems diff --git a/dlrs/main/classes/RollupJobTest.cls b/dlrs/main/classes/RollupJobTest.cls index 3768be3e..7c79ee23 100644 --- a/dlrs/main/classes/RollupJobTest.cls +++ b/dlrs/main/classes/RollupJobTest.cls @@ -251,17 +251,14 @@ private class RollupJobTest { insert items; String jobId; - System.runAs(new User(Id = UserInfo.getUserId())) { - Test.startTest(); - Assert.areEqual( - true, - Utilities.userHasCustomPermission(permName), - 'Expected user to have ' + permName - ); - // go into runAs because we need to get the perms recalculated - jobId = Database.executeBatch(new RollupJob()); - Test.stopTest(); - } + Test.startTest(); + Assert.isTrue( + Utilities.userHasCustomPermission(permName), + 'Expected user to have ' + permName + ); + // go into runAs because we need to get the perms recalculated + jobId = Database.executeBatch(new RollupJob()); + Test.stopTest(); AsyncApexJob asyncJob = [ SELECT Id, Status, JobItemsProcessed, TotalJobItems diff --git a/dlrs/main/classes/UtilitiesTest.cls b/dlrs/main/classes/UtilitiesTest.cls index 0daf47c0..23be6eba 100644 --- a/dlrs/main/classes/UtilitiesTest.cls +++ b/dlrs/main/classes/UtilitiesTest.cls @@ -44,8 +44,7 @@ public class UtilitiesTest { if (String.isNotBlank(perm.NamespacePrefix)) { permName = perm.NamespacePrefix + '__' + perm.DeveloperName; } - Assert.areEqual( - true, + Assert.isTrue( Utilities.userHasCustomPermission(permName), 'Expected user to have ' + permName );