Skip to content

Commit 26fd370

Browse files
authored
Merge pull request #2387 from navikt/apex
changes to testclasses
2 parents e0a7c1b + bd263d5 commit 26fd370

7 files changed

+890
-579
lines changed

force-app/ipsPortalReport/classes/IPS_ParticipantPortalReportContTest.cls

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@isTest
22
public class IPS_ParticipantPortalReportContTest {
33

4+
45
@TestSetup
56
static void makeData() {
67
Person__c participant = IPS_TestDataFactory.createPerson();
@@ -29,7 +30,17 @@ public class IPS_ParticipantPortalReportContTest {
2930

3031
Task taskDeactive = IPS_TestDataFactory.createPassiveDeactivateGoal(jobbspor.Id);
3132
insert taskDeactive;
32-
33+
34+
35+
Task participantGoalsOpen = IPS_TestDataFactory.creategoal(jobbspor.Id);
36+
insert participantGoalsOpen;
37+
38+
Task participantGoalsCompleted = IPS_TestDataFactory.creategoal(jobbspor.Id);
39+
participantGoalsCompleted.ips_Due_Date_Time__c = System.today().addDays(-7);
40+
participantGoalsCompleted.ActivityDate = System.today().addDays(-7);
41+
participantGoalsCompleted.Status = 'Completed' ;
42+
insert participantGoalsCompleted;
43+
3344
Event participantMeetingCompleted = IPS_TestDataFactory.createParticipantEvent(contactId, jobbspor.Id);
3445
insert participantMeetingCompleted;
3546

@@ -42,6 +53,25 @@ public class IPS_ParticipantPortalReportContTest {
4253
participantMeetingAbsent.IPS_Status1__c = 'Participant Absent';
4354
update participantMeetingAbsent;
4455

56+
57+
58+
Event employerMeetingCompletedIPS = IPS_TestDataFactory.createEmployerEventWithParticipant(
59+
businessAccount.id,
60+
userId.id,
61+
jobbspor.id
62+
);
63+
employerMeetingCompletedIPS.IPS_Status1__c = 'Completed';
64+
insert employerMeetingCompletedIPS;
65+
66+
Event employerMeetingAbsentIPS = IPS_TestDataFactory.createEmployerEventWithParticipant(
67+
businessAccount.id,
68+
userId.id,
69+
jobbspor.id
70+
);
71+
employerMeetingAbsentIPS.IPS_Status1__c = 'Participant Absent';
72+
insert employerMeetingAbsentIPS;
73+
74+
4575
ips_job__c jobOngoingIPS = IPS_TestDataFactory.createJob(businessAccount.id, jobbspor.id, 'Ongoing');
4676
insert jobOngoingIPS;
4777

@@ -52,21 +82,16 @@ public class IPS_ParticipantPortalReportContTest {
5282
insert eduOngoingIPS;
5383

5484
ips_Education__c eduPlannedIPS = IPS_TestDataFactory.createEducation(jobbspor.id);
55-
insert eduPlannedIPS;
56-
5785
eduPlannedIPS.ips_Status__c = 'Planned';
5886
eduPlannedIPS.ips_Start_Date__c = System.today().addDays(7);
59-
update eduPlannedIPS;
87+
insert eduPlannedIPS;
6088

6189
ips_Education__c eduCompletedIPS = IPS_TestDataFactory.createEducation(jobbspor.id);
62-
insert eduCompletedIPS;
63-
6490
eduCompletedIPS.ips_Status__c = 'Completed';
6591
eduCompletedIPS.ips_Start_Date__c = System.today().addDays(-7);
6692
eduCompletedIPS.ips_End_Date__c = System.today().addDays(30);
67-
update eduCompletedIPS;
68-
69-
93+
insert eduCompletedIPS;
94+
7095
/***** AMS *****/
7196
Work_Trail__c jobbsporAMS = IPS_TestDataFactory.createUOJobbspor(participantId);
7297
insert jobbsporAMS;
@@ -75,35 +100,29 @@ public class IPS_ParticipantPortalReportContTest {
75100
insert eduOngoingAMS;
76101

77102
AMS_Vocational_education_and_training__c eduPlannedAMS = IPS_TestDataFactory.createEducationAMS(jobbsporAMS.id);
78-
insert eduPlannedAMS;
79-
80103
eduPlannedAMS.AMS_Status__c = 'Planned';
81104
eduPlannedAMS.AMS_Start_Date__c = System.today().addDays(7);
82105
eduPlannedAMS.AMS_End_Date__c = System.today().addDays(30);
83-
update eduPlannedAMS;
106+
insert eduPlannedAMS;
84107

85108
AMS_Vocational_education_and_training__c eduCompletedAMS = IPS_TestDataFactory.createEducationAMS(
86109
jobbsporAMS.id
87110
);
88-
insert eduCompletedAMS;
89-
90111
eduCompletedAMS.AMS_Status__c = 'Completed';
91112
eduCompletedAMS.AMS_Start_Date__c = System.today().addDays(-7);
92113
eduCompletedAMS.AMS_End_Date__c = System.today();
93-
update eduCompletedAMS;
94-
95-
114+
insert eduCompletedAMS;
115+
96116
}
97117

98118
@isTest
99119
static void getReportPortalIPS() {
100120
ID workTrailId = [SELECT id FROM Work_Trail__c WHERE RecordType.developername = 'IPS' LIMIT 1]?.id;
101121

102122
ips_report__c intervallReport = IPS_TestDataFactory.createIntervallReport(workTrailId);
103-
insert intervallReport;
104123
intervallReport.IPS_worktrail_Type__c = 'IPS';
105124
intervallReport.IPS_status__c='Shared report';
106-
update intervallReport;
125+
insert intervallReport;
107126

108127
List<IPS_ParticipantPortalReport> listReport = IPS_ParticipantPortalReportController.getParticipantReport(workTrailId,'TRAIL');
109128
}
@@ -113,10 +132,9 @@ public class IPS_ParticipantPortalReportContTest {
113132
ID workTrailId = [SELECT id FROM Work_Trail__c WHERE RecordType.developername = 'ips_Supported_Employment' LIMIT 1]?.id;
114133

115134
ips_report__c intervallReport = IPS_TestDataFactory.createIntervallReport(workTrailId);
116-
insert intervallReport;
117135
intervallReport.IPS_worktrail_Type__c = 'Supported Employment';
118136
intervallReport.IPS_status__c='Shared report';
119-
update intervallReport;
137+
insert intervallReport;
120138

121139
List<IPS_ParticipantPortalReport> listReport = IPS_ParticipantPortalReportController.getParticipantReport(workTrailId,'TRAIL');
122140
}
@@ -126,21 +144,21 @@ public class IPS_ParticipantPortalReportContTest {
126144
ID workTrailId = [SELECT id FROM Work_Trail__c WHERE RecordType.developername = 'IPS' LIMIT 1]?.id;
127145

128146
ips_report__c intervallReport = IPS_TestDataFactory.createIntervallReport(workTrailId);
129-
insert intervallReport;
130147
intervallReport.IPS_status__c='Shared report';
131-
update intervallReport;
148+
insert intervallReport;
132149

133150
List<IPS_ParticipantPortalReport> listReport = IPS_ParticipantPortalReportController.getParticipantReport(intervallReport.id,'REPORT');
134151
}
135152

153+
154+
136155
@isTest
137156
static void intervallReport(){
138157
ID workTrailId = [SELECT id FROM Work_Trail__c WHERE RecordType.developername = 'IPS' LIMIT 1]?.id;
139158

140159
ips_report__c intervallReport = IPS_TestDataFactory.createIntervallReport(workTrailId);
141-
insert intervallReport;
142160
intervallReport.IPS_status__c='Shared report';
143-
update intervallReport;
161+
insert intervallReport;
144162

145163
List<IPS_ParticipantPortalTask> goal = IPS_ParticipantPortalReportController.getParticipantsReportCompletedGoals(intervallReport.id,'Intervall',intervallReport.IPS_intervallDateFrom__c,intervallReport.IPS_intervallDateTo__c);
146164
List<IPS_ParticipantPortalTask> openGoal = IPS_ParticipantPortalReportController.getParticipantsReportOpenGoals(intervallReport.id, 'Intervall', intervallReport.IPS_intervallDateTo__c);
@@ -158,20 +176,16 @@ public class IPS_ParticipantPortalReportContTest {
158176
ID workTrailId = [SELECT id FROM Work_Trail__c WHERE RecordType.developername = 'IPS' LIMIT 1]?.id;
159177

160178
ips_report__c endReport = IPS_TestDataFactory.createEndReport(workTrailId);
161-
insert endReport;
162179
endReport.IPS_status__c='Shared report';
163-
update endReport;
180+
insert endReport;
164181

165182
List<IPS_ParticipantPortalTask> goal = IPS_ParticipantPortalReportController.getParticipantsReportCompletedGoals(endReport.id,'End report',null,null);
166183
List<IPS_ParticipantPortalEvent> meeting = IPS_ParticipantPortalReportController.getParticipantsReportCompletedMeetings(endReport.id,'End report',null,null);
167184
List<IPS_ParticipantPortalEvent> absent = IPS_ParticipantPortalReportController.getParticipantsReportAbsentMeetings(endReport.id,'End report',null,null);
168185
List<IPS_ParticipantPortalEvent> cancelled = IPS_ParticipantPortalReportController.getParticipantReportCancelledMeetings(endReport.id,'End report',null,null);
169-
/*
170-
List<IPS_ParticipantPortalEvent> employee = IPS_ParticipantPortalReportController.getParticipantsReportEmployeeCompletedMeetings(intervallReport.id,'Intervall',intervallReport.IPS_intervallDateFrom__c,intervallReport.IPS_intervallDateTo__c);
171-
List<IPS_ParticipantPortalEvent> openmeeting = IPS_ParticipantPortalReportController.getParticipantsReportOpenMeetings(intervallReport.id,'Intervall',intervallReport.IPS_intervallDateTo__c);
172-
List<IPS_ParticipantPortalJob> jobs = IPS_ParticipantPortalReportController.getParticipantJobs(workTrailId,intervallReport.IPS_intervallDateFrom__c,intervallReport.IPS_intervallDateTo__c);
173-
List<ips_ParticipantPortalEducation> edu = IPS_ParticipantPortalReportController.getParticipantEducations(workTrailId,'Intervall',intervallReport.IPS_intervallDateFrom__c,intervallReport.IPS_intervallDateTo__c);
174-
*/
186+
List<IPS_ParticipantPortalEvent> employee = IPS_ParticipantPortalReportController.getParticipantsReportEmployeeCompletedMeetings(endReport.id,'End report',null,null);
187+
// List<IPS_ParticipantPortalJob> jobs = IPS_ParticipantPortalReportController.getParticipantJobs(endReport.id,'End report',null,null);
188+
List<ips_ParticipantPortalEducation> edu = IPS_ParticipantPortalReportController.getParticipantEducations(endReport.id,'End report',null,null);
175189
}
176190

177191
@isTest

0 commit comments

Comments
 (0)