@@ -110,6 +110,90 @@ private class GiftEntryProcessorQueue_TEST {
110
110
' Should have the correct amount' );
111
111
}
112
112
113
+ @isTest
114
+ static void shouldCreateRDWhenGiftBatchHasRecurringGiftCsvImport () {
115
+ // Arrange
116
+ RD2_EnablementService_TEST .setRecurringDonations2Enabled ();
117
+ Data_Import_Settings__c dataImportSettings = UTIL_CustomSettingsFacade .getDataImportSettings ();
118
+ dataImportSettings .Field_Mapping_Method__c = BDI_DataImportService .FM_DATA_IMPORT_FIELD_MAPPING ;
119
+ dataImportSettings .Default_Data_Import_Field_Mapping_Set__c =
120
+ BDI_MappingServiceAdvanced .DEFAULT_DATA_IMPORT_FIELD_MAPPING_SET_NAME ;
121
+ UTIL_CustomSettingsFacade .setDataImportSettings (dataImportSettings );
122
+
123
+ DataImportBatch__c giftBatch = new DataImportBatch__c ();
124
+ insert giftBatch ;
125
+
126
+ List <DataImport__c > giftsToInsert = new List <DataImport__c >();
127
+ giftsToInsert .add (new DataImport__c (
128
+ Recurring_Donation_Installment_Period__c = ' Monthly' ,
129
+ Recurring_Donation_Effective_Date__c = Date .today (),
130
+ Recurring_Donation_Recurring_Type__c = ' Open' ,
131
+ Recurring_Donation_Installment_Frequency__c = 1 ,
132
+ Recurring_Donation_Day_of_Month__c = ' 5' ,
133
+ Recurring_Donation_Amount__c = 33.00 ,
134
+ Donation_Amount__c = 50.00 ,
135
+ Recurring_Donation_Date_Established__c = Date .today (),
136
+ Donation_Date__c = Date .today (),
137
+ NPSP_Data_Import_Batch__c = giftBatch .Id ,
138
+ Contact1_Lastname__c = ' Dummy Last Name' ,
139
+ Donation_Donor__c = ' Contact1'
140
+ ));
141
+ insert giftsToInsert ;
142
+
143
+ GiftBatchForQueueable giftBatchForProcessing = new GiftBatchForQueueable (new GiftBatchId (giftBatch .Id ), new GiftBatchSelector ());
144
+ giftBatchForProcessing .chunkGiftsThatCanBeProcessed ();
145
+ GiftEntryProcessorQueue processorQueue = new GiftEntryProcessorQueue (giftBatchForProcessing );
146
+
147
+ // Act
148
+ Test .startTest ();
149
+ processorQueue .execute (null );
150
+ Test .stopTest ();
151
+
152
+ // Assert
153
+ npe03__Recurring_Donation__c [] resultingRDs =
154
+ [SELECT Id ,
155
+ npe03__Amount__c ,
156
+ npe03__Installment_Period__c ,
157
+ RecurringType__c ,
158
+ StartDate__c ,
159
+ npe03__Date_Established__c ,
160
+ Day_of_Month__c
161
+ FROM npe03__Recurring_Donation__c ];
162
+
163
+ System .assertEquals (1 , resultingRDs .size (),
164
+ ' Should result in one recurring donation record' );
165
+ System .assertEquals (33.00 , resultingRDs [0 ].npe03__Amount__c ,
166
+ ' Should have the correct amount' );
167
+ System .assertEquals (Date .today (), resultingRDs [0 ].npe03__Date_Established__c ,
168
+ ' Should have the correct date established' );
169
+ System .assertEquals (' Monthly' , resultingRDs [0 ].npe03__Installment_Period__c ,
170
+ ' Should have the correct installment period' );
171
+ System .assertEquals (' Open' , resultingRDs [0 ].RecurringType__c ,
172
+ ' Should have the correct recurring type' );
173
+ System .assertEquals (' 5' , resultingRDs [0 ].Day_of_Month__c ,
174
+ ' Should have the correct day of month' );
175
+
176
+ Opportunity [] resultingOpportunities =
177
+ [SELECT Id ,
178
+ Amount ,
179
+ CloseDate ,
180
+ StageName ,
181
+ npe03__Recurring_Donation__c
182
+ FROM Opportunity ORDER BY CloseDate ASC ];
183
+ System .assertEquals (2 , resultingOpportunities .size (),
184
+ ' Should result in one opportunity record' );
185
+ System .assertEquals (resultingRDs [0 ].Id , resultingOpportunities [0 ].npe03__Recurring_Donation__c ,
186
+ ' Resulting opportunity should look up to the recurring donation' );
187
+ System .assertEquals (50.00 , resultingOpportunities [0 ].Amount ,
188
+ ' First Opp should have the correct Amount' );
189
+ System .assertEquals (Date .today (), resultingOpportunities [0 ].CloseDate ,
190
+ ' First Opp should have the correct Close Date' );
191
+ System .assertEquals (33.00 , resultingOpportunities [1 ].Amount ,
192
+ ' Second Opp should have the correct Amount' );
193
+ System .assertEquals (' Pledged' , resultingOpportunities [1 ].StageName ,
194
+ ' Second Opp should have the correct Stage' );
195
+ }
196
+
113
197
@IsTest
114
198
static void shouldCreate20OpportunitiesAndFail10GiftsIn1Chunk () {
115
199
// Arrange
0 commit comments