Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public with sharing class AccountWelcomeTaskWriter implements AfterInsert.Writer

public void writeOnAfterInsert(TriggerTypes.InsertRecord record, TriggerTypes.UnitOfWork unitOfWork) {
Account newAccount = (Account) record.getNewSObject();
User owner = (User) record.getNewParent('Owner');
User owner = (User) record.getNewParent(Account.OwnerId);

unitOfWork.toInsert(new Task(WhatId = record.getId(), OwnerId = newAccount.OwnerId, Subject = 'Onboarding call - ' + newAccount.Name, Description = 'Assigned to ' + owner?.Name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public with sharing class AccountWelcomeTaskWriter implements AfterInsert.Writer

public void writeOnAfterInsert(TriggerTypes.InsertRecord record, TriggerTypes.UnitOfWork unitOfWork) {
Account newAccount = (Account) record.getNewSObject();
User owner = (User) record.getNewParent('Owner');
User owner = (User) record.getNewParent(Account.OwnerId);

unitOfWork.toInsert(
new Task(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:AccountWelcomeTaskWriter')
private class AccountWelcomeTaskWriterTest {
@IsTest
static void writeOnAfterInsertWithCustomer() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:AccountAddressCascadeWriter')
private class AccountAddressCascadeWriterTest {
@IsTest
static void writeOnAfterUpdateWithoutContacts() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public with sharing class AccountOwnerTransferWriter implements AfterUpdate.Writ

public void writeOnAfterUpdate(TriggerTypes.UpdateRecord record, TriggerTypes.UnitOfWork unitOfWork) {
Account newAccount = (Account) record.getNewSObject();
User oldOwner = (User) record.getOldParent('Owner');
User newOwner = (User) record.getNewParent('Owner');
User oldOwner = (User) record.getOldParent(Account.OwnerId);
User newOwner = (User) record.getNewParent(Account.OwnerId);
String handoverNote = Date.today().format() + ' - account handed over from ' + oldOwner?.Name + ' to ' + newOwner?.Name;

for (SObject row : record.getRelated('openOpportunities').getAllWhereKeyEquals(record.getId())) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:AccountOwnerTransferWriter')
private class AccountOwnerTransferWriterTest {
@IsTest
static void writeOnAfterUpdateWithoutOpenOpportunities() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public with sharing class AccountParentDefaultsPopulator implements BeforeInsert
}

public void populateOnBeforeInsert(TriggerTypes.InsertRecord record) {
Account parent = (Account) record.getNewParent('Parent');
Account parent = (Account) record.getNewParent(Account.ParentId);

if (parent == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:AccountParentDefaultsPopulator')
private class AccountParentDefaultsPopulatorTest {
@IsTest
static void populateOnBeforeInsertWithBlankIndustry() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:AccountRatingPopulator')
private class AccountRatingPopulatorTest {
@IsTest
static void populateOnBeforeInsertWithFiveMillionRevenue() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:AccountShippingAddressPopulator')
private class AccountShippingAddressPopulatorTest {
@IsTest
static void populateOnBeforeInsertWithBillingAddress() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:AccountCustomerDataValidator')
private class AccountCustomerDataValidatorTest {
@IsTest
static void addErrorOnBeforeInsertWithBlankIndustry() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ public with sharing class AccountParentTypeValidator implements BeforeInsert.Val
}

public Boolean addErrorOnBeforeInsertWhen(TriggerTypes.InsertRecord record) {
Account parent = (Account) record.getNewParent('Parent');
Account parent = (Account) record.getNewParent(Account.ParentId);

return record.isNotNull(Account.ParentId) && parent?.Type == 'Prospect';
}

public void addErrorOnBeforeInsert(TriggerTypes.RejectableInsertRecord record) {
Account parent = (Account) record.getNewParent('Parent');
Account parent = (Account) record.getNewParent(Account.ParentId);

record.addError(Account.ParentId, 'Parent account "' + parent.Name + '" is still a Prospect and cannot head a hierarchy. Qualify it first.');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:AccountParentTypeValidator')
private class AccountParentTypeValidatorTest {
@IsTest
static void addErrorOnBeforeInsertWithProspectParent() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:AccountRatingRefreshPopulator')
private class AccountRatingRefreshPopulatorTest {
@IsTest
static void populateOnBeforeUpdateWithFiveMillionRevenue() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:AccountShippingSyncPopulator')
private class AccountShippingSyncPopulatorTest {
@IsTest
static void populateOnBeforeUpdateWithShippingMatchingBilling() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:AccountTypeAuditPopulator')
private class AccountTypeAuditPopulatorTest {
@IsTest
static void populateOnBeforeUpdateWithChangedType() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:AccountBillingCountryValidator')
private class AccountBillingCountryValidatorTest {
@IsTest
static void addErrorOnBeforeUpdateWithClearedBillingCountry() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:AccountDemotionValidator')
private class AccountDemotionValidatorTest {
@IsTest
static void addErrorOnBeforeUpdateWithCustomerChangedToProspect() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public with sharing class AccountParentMoveValidator implements BeforeUpdate.Val
return false;
}

Account oldParent = (Account) record.getOldParent('Parent');
Account newParent = (Account) record.getNewParent('Parent');
Account oldParent = (Account) record.getOldParent(Account.ParentId);
Account newParent = (Account) record.getNewParent(Account.ParentId);

return oldParent != null && newParent != null && oldParent.BillingCountry != newParent.BillingCountry;
}

public void addErrorOnBeforeUpdate(TriggerTypes.RejectableUpdateRecord record) {
Account oldParent = (Account) record.getOldParent('Parent');
Account newParent = (Account) record.getNewParent('Parent');
Account oldParent = (Account) record.getOldParent(Account.ParentId);
Account newParent = (Account) record.getNewParent(Account.ParentId);

record.addError(
Account.ParentId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:AccountParentMoveValidator')
private class AccountParentMoveValidatorTest {
@IsTest
static void addErrorOnBeforeUpdateWithParentInAnotherCountry() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public with sharing class ContactFollowUpTaskWriter implements AfterInsert.Write

public void writeOnAfterInsert(TriggerTypes.InsertRecord record, TriggerTypes.UnitOfWork unitOfWork) {
Contact newContact = (Contact) record.getNewSObject();
Account account = (Account) record.getNewParent('Account');
Account account = (Account) record.getNewParent(Contact.AccountId);

unitOfWork.toInsert(
new Task(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:ContactFollowUpTaskWriter')
private class ContactFollowUpTaskWriterTest {
@IsTest
static void writeOnAfterInsertWithWebLeadSource() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ public with sharing class ContactOwnerAlignmentWriter implements AfterInsert.Wri

public Boolean writeOnAfterInsertWhen(TriggerTypes.InsertRecord record) {
Contact newContact = (Contact) record.getNewSObject();
Account account = (Account) record.getNewParent('Account');
Account account = (Account) record.getNewParent(Contact.AccountId);

return account?.Owner?.IsActive == true && account.OwnerId != newContact.OwnerId;
}

public void writeOnAfterInsert(TriggerTypes.InsertRecord record, TriggerTypes.UnitOfWork unitOfWork) {
Account account = (Account) record.getNewParent('Account');
Account account = (Account) record.getNewParent(Contact.AccountId);

unitOfWork.toUpdate(new Contact(Id = record.getId(), OwnerId = account.OwnerId));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:ContactOwnerAlignmentWriter')
private class ContactOwnerAlignmentWriterTest {
@IsTest
static void writeOnAfterInsertWithActiveAccountOwner() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:ContactEmailNormalizationPopulator')
private class ContactEmailNormalizationPopulatorTest {
@IsTest
static void populateOnBeforeInsertWithMixedCaseEmail() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public with sharing class ContactMailingAddressPopulator implements BeforeInsert
}

public void populateOnBeforeInsert(TriggerTypes.InsertRecord record) {
Account account = (Account) record.getNewParent('Account');
Account account = (Account) record.getNewParent(Contact.AccountId);

if (account == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:ContactMailingAddressPopulator')
private class ContactMailingAddressPopulatorTest {
@IsTest
static void populateOnBeforeInsertWithAccountBillingAddress() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:ContactBirthdateValidator')
private class ContactBirthdateValidatorTest {
@IsTest
static void addErrorOnBeforeInsertWithFutureBirthdate() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:ContactEmailFormatValidator')
private class ContactEmailFormatValidatorTest {
@IsTest
static void addErrorOnBeforeInsertWithEmailWithoutAtSign() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:ContactReachabilityValidator')
private class ContactReachabilityValidatorTest {
@IsTest
static void addErrorOnBeforeInsertWithoutContactDetails() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public with sharing class ContactAccountTransferPopulator implements BeforeUpdat

public void populateOnBeforeUpdate(TriggerTypes.UpdateRecord record) {
Contact newContact = (Contact) record.getNewSObject();
Account oldAccount = (Account) record.getOldParent('Account');
Account newAccount = (Account) record.getNewParent('Account');
Account oldAccount = (Account) record.getOldParent(Contact.AccountId);
Account newAccount = (Account) record.getNewParent(Contact.AccountId);

String auditLine = Date.today().format() + ' - transferred from ' + (oldAccount?.Name ?? 'a deleted account') + ' to ' + (newAccount?.Name ?? 'no account') + '.';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:ContactAccountTransferPopulator')
private class ContactAccountTransferPopulatorTest {
@IsTest
static void populateOnBeforeUpdateWithTransferredAccount() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:ContactTitleDepartmentPopulator')
private class ContactTitleDepartmentPopulatorTest {
@IsTest
static void populateOnBeforeUpdateWithKnownTitle() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:ContactDoNotCallValidator')
private class ContactDoNotCallValidatorTest {
@IsTest
static void addErrorOnBeforeUpdateWithDoNotCallWithoutDescription() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:ContactEmailRemovalValidator')
private class ContactEmailRemovalValidatorTest {
@IsTest
static void addErrorOnBeforeUpdateWithClearedEmail() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public with sharing class OpportunityAccountTypeWriter implements AfterUpdate.Wr
}

public Boolean writeOnAfterUpdateWhen(TriggerTypes.UpdateRecord record) {
Account account = (Account) record.getNewParent('Account');
Account account = (Account) record.getNewParent(Opportunity.AccountId);

return record.isChangedTo(Opportunity.StageName, 'Closed Won') && account != null && account.Type != 'Customer - Direct';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:OpportunityAccountTypeWriter')
private class OpportunityAccountTypeWriterTest {
@IsTest
static void writeOnAfterUpdateWithWonOpportunity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public with sharing class OpportunityWinTaskWriter implements AfterUpdate.Writer

public void writeOnAfterUpdate(TriggerTypes.UpdateRecord record, TriggerTypes.UnitOfWork unitOfWork) {
Opportunity newOpportunity = (Opportunity) record.getNewSObject();
Account account = (Account) record.getNewParent('Account');
Account account = (Account) record.getNewParent(Opportunity.AccountId);

unitOfWork.toInsert(
new Task(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:OpportunityWinTaskWriter')
private class OpportunityWinTaskWriterTest {
@IsTest
static void writeOnAfterUpdateWithWonOpportunity() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:OpportunityCloseDatePopulator')
private class OpportunityCloseDatePopulatorTest {
@IsTest
static void populateOnBeforeInsertWithoutCloseDate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public with sharing class OpportunityTypeFromAccountPopulator implements BeforeI
}

public void populateOnBeforeInsert(TriggerTypes.InsertRecord record) {
Account account = (Account) record.getNewParent('Account');
Account account = (Account) record.getNewParent(Opportunity.AccountId);
Boolean isCustomerAccount = account?.Type?.startsWith('Customer') == true;

record.put(Opportunity.Type, isCustomerAccount ? 'Existing Customer - Upgrade' : 'New Customer');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:OpportunityTypeFromAccountPopulator')
private class OpportunityTypeFromAccountPopulatorTest {
@IsTest
static void populateOnBeforeInsertWithCustomerAccount() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:OpportunityAmountValidator')
private class OpportunityAmountValidatorTest {
@IsTest
static void addErrorOnBeforeInsertWithNegativeAmount() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:OpportunityCloseDateValidator')
private class OpportunityCloseDateValidatorTest {
@IsTest
static void addErrorOnBeforeInsertWithPastCloseDate() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:OpportunityClosingPopulator')
private class OpportunityClosingPopulatorTest {
@IsTest
static void populateOnBeforeUpdateWithWonOpportunity() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:OpportunityForecastPopulator')
private class OpportunityForecastPopulatorTest {
@IsTest
static void populateOnBeforeUpdateWithSmallAmount() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:OpportunityProbabilityPopulator')
private class OpportunityProbabilityPopulatorTest {
@IsTest
static void populateOnBeforeUpdateWithStageChange() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public with sharing class OpportunityAccountMoveValidator implements BeforeUpdat
}

public void addErrorOnBeforeUpdate(TriggerTypes.RejectableUpdateRecord record) {
Account oldAccount = (Account) record.getOldParent('Account');
Account newAccount = (Account) record.getNewParent('Account');
Account oldAccount = (Account) record.getOldParent(Opportunity.AccountId);
Account newAccount = (Account) record.getNewParent(Opportunity.AccountId);

record.addError(
Opportunity.AccountId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:OpportunityAccountMoveValidator')
private class OpportunityAccountMoveValidatorTest {
@IsTest
static void addErrorOnBeforeUpdateWithMovedWonOpportunity() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:OpportunityLargeDealValidator')
private class OpportunityLargeDealValidatorTest {
@IsTest
static void addErrorOnBeforeUpdateWithoutNextStep() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:OpportunityReopenValidator')
private class OpportunityReopenValidatorTest {
@IsTest
static void addErrorOnBeforeUpdateWithReopenedDeal() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@IsTest(IsParallel=true)
@IsTest(IsParallel=true testFor='ApexClass:OpportunityWinAmountValidator')
private class OpportunityWinAmountValidatorTest {
@IsTest
static void addErrorOnBeforeUpdateWithoutAmount() {
Expand Down
Loading
Loading