-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1350 from bcgov/EDRD-PH1_Sept24Release_defectsFix…
…ingBranch Adding NULL check for dataload
- Loading branch information
Showing
16 changed files
with
255 additions
and
37 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
dev-app-post/main/default/classes/UserTriggerHandlerTest.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,60 @@ | ||
/********************************************************************************************** | ||
* @Author: Accenture | ||
* @Date: 24 Sept 2024 | ||
* @Description: The purpose of this class is to cover Code coverage of UserTriggerHandler | ||
* @Revision(s): [Date] - [Change Reference] - [Changed By] - [Description] | ||
24Sept - EDRD-911 - Deepak - Added activateACROnEDRDPortalEnable_Test method | ||
***********************************************************************************************/ | ||
@isTest | ||
public class UserTriggerHandlerTest { | ||
|
||
/** | ||
* @author: Deepak | ||
* @date: 24 Sept 2024 | ||
* @description: The purpose of this method is to cover Testcoverage of activateACROnAccportalEnable | ||
* @Modification Log: [Date] - [Change Reference] - [Changed By] - [Description] | ||
*/ | ||
@isTest | ||
public static void activateACROnEDRDPortalEnable_Test(){ | ||
Account patientAcc1 = TestFactory.newPatient('Patient1'); | ||
insert patientAcc1; | ||
Account providerAcc = TestFactory.newProvider('Provider Test'); | ||
insert providerAcc; | ||
|
||
Id patientContactId = [SELECT Id FROM Contact Where accountId =: patientAcc1.Id].get(0).Id; | ||
AccountContactRelation ACRObj = new AccountContactRelation(); | ||
ACRObj.AccountId = providerAcc.Id; | ||
ACRObj.ContactId = patientContactId; | ||
ACRObj.Roles = ESA_cls_constants.EDRD_PHYSICIAN; | ||
ACRObj.IsActive = false; | ||
ACRObj.Is_EDRD_Data_Migration__c = true; | ||
insert ACRObj; | ||
|
||
Profile profileObj = [SELECT Id FROM Profile WHERE Name =: ESA_cls_constants.EDRD_PRESCRIBER_COMMUNITY_USER LIMIT 1]; | ||
Id ContactId = [SELECT Id FROM Contact WHERE AccountID =: providerAcc.Id].get(0).Id; | ||
User accCommunityUser = TestFactory.createCommunityUser(ContactId, profileObj.Id, 'Provider', 'Test'); | ||
|
||
Test.startTest(); | ||
insert accCommunityUser; | ||
Test.stopTest(); | ||
|
||
List<User> communityUser = [SELECT Id FROM User WHERE Id =: accCommunityUser.Id LIMIT 1]; | ||
|
||
List<Account> accUser = [SELECT Id, IsCustomerPortal FROM Account WHERE Id =: providerAcc.Id LIMIT 1]; | ||
|
||
List<AccountContactRelation> aCRList = [SELECT Id, AccountId, ContactId, Roles, Is_EDRD_Data_Migration__c, IsActive | ||
FROM AccountContactRelation | ||
WHERE AccountID =: providerAcc.Id LIMIT 1]; | ||
|
||
List<AccountShare> accShareList1 = [SELECT Id, AccountId, UserOrGroupId, RowCause, AccountAccessLevel | ||
FROM AccountShare WHERE AccountId =: patientAcc1.Id | ||
AND UserOrGroupId =: accCommunityUser.Id LIMIT 1]; | ||
|
||
Assert.areEqual(accUser[0].IsCustomerPortal, True, 'Portal User should be Active'); | ||
Assert.areEqual(aCRList[0].isActive, True, 'ACR should be Active'); | ||
Assert.areEqual(accShareList1[0].AccountAccessLevel, 'Edit', 'AccountShare access level should be Edit'); | ||
Assert.areEqual(accShareList1.size(), 1, 'AccountShare should have been created for the Patient'); | ||
Assert.areNotEqual(accShareList1.isEmpty(), true, 'AccountShare list should not be empty'); | ||
Assert.areNotEqual(accShareList1[0].UserOrGroupId, null, 'UserOrGroupId should not be null'); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
dev-app-post/main/default/classes/UserTriggerHandlerTest.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>60.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
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
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,62 @@ | ||
/********************************************************************************************** | ||
* @Author: Accenture | ||
* @Date: 24 Sept 2024 | ||
* @Description: The purpose of this class is to create methods which can be used by different trigger event | ||
* @Revision(s): [Date] - [Change Reference] - [Changed By] - [Description] | ||
24Sept - EDRD-911 - Accenture - Added activateACROnEDRDPortalEnable method | ||
***********************************************************************************************/ | ||
public with sharing class UserTriggerHandler { | ||
public static Id eDRDPrescriberProfileId = [SELECT Id FROM Profile WHERE Name =: ESA_cls_constants.EDRD_PRESCRIBER_COMMUNITY_USER LIMIT 1].Id; | ||
public static Id recordTypeProvider = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get(ESA_cls_constants.EDRD_PROVIDER).getRecordTypeId(); | ||
|
||
/** | ||
* @author: Deepak | ||
* @date: 24 Sept 2024 | ||
* @description: The purpose of this method is to activate EDRD related ACR on provider releated to user. | ||
* @Modification Log: [Date] - [Change Reference] - [Changed By] - [Description] | ||
*/ | ||
public static void activateACROnEDRDPortalEnable(List<User> newUserList){ | ||
try{ | ||
Set<Id> providerIdSet = new Set<Id>(); | ||
Set<Id> accProviderIdSet = new Set<Id>(); | ||
Set<Id> acrIdsToUpdate = new Set<Id>(); | ||
Map<Id, Contact> contactIdVsContactRec; | ||
|
||
for(User userObj: newUserList){ | ||
if((userObj.ProfileId == eDRDPrescriberProfileId && userObj.IsPortalEnabled)){ | ||
providerIdSet.add(userObj.ContactId); | ||
} | ||
} | ||
|
||
if(!providerIdSet.isEmpty()){ | ||
contactIdVsContactRec = new Map<Id, Contact>([SELECT Id, AccountId FROM Contact | ||
WHERE ID IN: providerIdSet AND | ||
Account.RecordTypeId =: recordTypeProvider]); | ||
for(Contact conObj: contactIdVsContactRec.values()){ | ||
accProviderIdSet.add(conObj.accountId); | ||
} | ||
} | ||
|
||
if(!accProviderIdSet.isEmpty()){ | ||
List<AccountContactRelation> aCRList = [SELECT Id, AccountId, ContactId, Roles, Is_EDRD_Data_Migration__c, IsActive | ||
FROM AccountContactRelation | ||
WHERE AccountID IN: accProviderIdSet AND IsActive = false | ||
AND Is_EDRD_Data_Migration__c = true]; | ||
|
||
for(AccountContactRelation aCRObj : aCRList){ | ||
if(!String.isEmpty(aCRObj.Roles) && aCRObj.Roles.containsIgnoreCase(ESA_cls_constants.EDRD_PHYSICIAN)){ | ||
acrIdsToUpdate.add(aCRObj.Id); | ||
} | ||
} | ||
|
||
if (!acrIdsToUpdate.isEmpty()) { | ||
// Calling the future method to update ACR records in a separate transaction | ||
UserTriggerHelper.updateACRRecords(acrIdsToUpdate); | ||
} | ||
} | ||
} | ||
catch(Exception ex){ | ||
System.debug('An unexpected error occurred: ' + ex.getMessage()); | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
force-app/main/default/classes/UserTriggerHandler.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>60.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
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,35 @@ | ||
/********************************************************************************************** | ||
* @Author: Accenture | ||
* @Date: 24 Sept 2024 | ||
* @Description: The purpose of this helper class is to update ACR records on User trigger event | ||
* @Revision(s): [Date] - [Change Reference] - [Changed By] - [Description] | ||
***********************************************************************************************/ | ||
public with sharing class UserTriggerHelper{ | ||
|
||
/** | ||
* @author: Deepak | ||
* @date: 24 Sept 2024 | ||
* @description: Update AccountContactRelation records in future method. | ||
* @param Set<Id> acrIdsToUpdate: Set of ACR records to update. | ||
* @Modification Log: [Date] - [Change Reference] - [Changed By] - [Description] | ||
*/ | ||
@future | ||
public static void updateACRRecords(Set<Id> acrIdsToUpdate){ | ||
try { | ||
List<AccountContactRelation> aCRListToUpdate = [SELECT Id, IsActive, Is_EDRD_Data_Migration__c | ||
FROM AccountContactRelation | ||
WHERE Id IN :acrIdsToUpdate]; | ||
|
||
for(AccountContactRelation aCRObj : aCRListToUpdate){ | ||
aCRObj.IsActive = true; | ||
aCRObj.Is_EDRD_Data_Migration__c = false; | ||
} | ||
|
||
if(!aCRListToUpdate.isEmpty()){ | ||
Database.update(aCRListToUpdate, true); | ||
} | ||
} catch(Exception ex){ | ||
System.debug('Error while updating ACR records: ' + ex.getMessage()); | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
force-app/main/default/classes/UserTriggerHelper.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>60.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
9 changes: 9 additions & 0 deletions
9
...in/default/objects/AccountContactRelation/fields/Is_EDRD_Data_Migration__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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<fullName>Is_EDRD_Data_Migration__c</fullName> | ||
<defaultValue>false</defaultValue> | ||
<externalId>false</externalId> | ||
<label>Is EDRD Data Migration</label> | ||
<trackHistory>false</trackHistory> | ||
<type>Checkbox</type> | ||
</CustomField> |
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
Oops, something went wrong.