Skip to content

Commit 8ebc90c

Browse files
committed
Ignorer alle oppdatering fra Modia Integrasjonsbruker, bortsett fra STO_Sensitive_Information__c
1 parent 958259e commit 8ebc90c

File tree

2 files changed

+52
-5
lines changed

2 files changed

+52
-5
lines changed

src/integration/henvendelse-cache/classes/helpers/ConvNoteCacheFilterHelper.cls

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public with sharing class ConvNoteCacheFilterHelper {
99
//Only cache records created in Salesforce
1010
if (
1111
convNote.LastModifiedById != modiaIntegrationUser.UserId ||
12-
isUpdate
12+
(isUpdate && convNote.STO_Sensitive_Information__c == true) //Updates from Modia should be handled by the NAIS-app, except redaction requests
1313
) {
1414
recordIds.add(convNote.Id);
1515
}

src/integration/henvendelse-cache/classes/helpers/tests/ConvNoteCacheFilterHelperTest.cls

+51-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ConvNoteCacheFilterHelperTest {
1414
);
1515

1616
List<Conversation_Note__c> convNotes = [
17-
SELECT Id, LastModifiedById
17+
SELECT Id, LastModifiedById, STO_Sensitive_Information__c
1818
FROM Conversation_Note__c
1919
WHERE CRM_Henvendelse_BehandlingskjedeId__c = '123'
2020
];
@@ -62,7 +62,7 @@ public class ConvNoteCacheFilterHelperTest {
6262
}
6363

6464
List<Conversation_Note__c> convNotes = [
65-
SELECT Id, LastModifiedById
65+
SELECT Id, LastModifiedById, STO_Sensitive_Information__c
6666
FROM Conversation_Note__c
6767
WHERE CRM_Henvendelse_BehandlingskjedeId__c = '789'
6868
];
@@ -78,7 +78,7 @@ public class ConvNoteCacheFilterHelperTest {
7878
}
7979

8080
@IsTest
81-
static void shouldReturnOneRecordIdForConvNoteUpdatedByModiaIntegrationUser() {
81+
static void shoulNotForConvNoteUpdatedByModiaIntegrationUserAndSensitiveInformationIsFalse() {
8282
myTriggers.disable(ConvNoteCacheHandler.class);
8383

8484
Id profileId = [
@@ -108,7 +108,54 @@ public class ConvNoteCacheFilterHelperTest {
108108
}
109109

110110
List<Conversation_Note__c> convNotes = [
111-
SELECT Id, LastModifiedById
111+
SELECT Id, LastModifiedById, STO_Sensitive_Information__c
112+
FROM Conversation_Note__c
113+
WHERE CRM_Henvendelse_BehandlingskjedeId__c = '789'
114+
];
115+
116+
Test.startTest();
117+
Set<Id> result = ConvNoteCacheFilterHelper.getRecordIdsRequiringCacheClear(
118+
convNotes,
119+
true //record is updated
120+
);
121+
Test.stopTest();
122+
123+
Assert.areEqual(0, result.size());
124+
}
125+
126+
@IsTest
127+
static void shouldReturnOneRecordIdForConvNoteUpdatedByModiaIntegrationUserAndSensitiveInformationIsTrue() {
128+
myTriggers.disable(ConvNoteCacheHandler.class);
129+
130+
Id profileId = [
131+
SELECT Id
132+
FROM Profile
133+
WHERE Name = 'System Administrator'
134+
LIMIT 1
135+
]
136+
.Id;
137+
User modiaIntegrationUser = (User) SharedTestDataFactory.createRecord(
138+
new User(
139+
username = '[email protected]',
140+
ProfileId = profileId
141+
)
142+
);
143+
144+
Account personAccount = SharedTestDataFactory.createPersonAccount();
145+
146+
System.runAs(modiaIntegrationUser) {
147+
SharedTestDataFactory.createRecord(
148+
new Conversation_Note__c(
149+
CRM_Account__c = personAccount.Id,
150+
CRM_Conversation_Note__c = 'DUMMY TEXT',
151+
CRM_Henvendelse_BehandlingskjedeId__c = '789',
152+
STO_Sensitive_Information__c = true
153+
)
154+
);
155+
}
156+
157+
List<Conversation_Note__c> convNotes = [
158+
SELECT Id, LastModifiedById, STO_Sensitive_Information__c
112159
FROM Conversation_Note__c
113160
WHERE CRM_Henvendelse_BehandlingskjedeId__c = '789'
114161
];

0 commit comments

Comments
 (0)