forked from moov-io/ach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
batchTRX_test.go
602 lines (527 loc) · 18.5 KB
/
batchTRX_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
// Licensed to The Moov Authors under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. The Moov Authors licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package ach
import (
"log"
"testing"
"github.com/moov-io/base"
)
// mockBatchTRXHeader creates a BatchTRX BatchHeader
func mockBatchTRXHeader() *BatchHeader {
bh := NewBatchHeader()
bh.ServiceClassCode = DebitsOnly
bh.StandardEntryClassCode = TRX
bh.CompanyName = "Payee Name"
bh.CompanyIdentification = "121042882"
bh.CompanyEntryDescription = "ACH TRX"
bh.ODFIIdentification = "12104288"
return bh
}
// mockTRXEntryDetail creates a BatchTRX EntryDetail
func mockTRXEntryDetail() *EntryDetail {
entry := NewEntryDetail()
entry.TransactionCode = CheckingDebit
entry.SetRDFI("231380104")
entry.DFIAccountNumber = "744-5678-99"
entry.Amount = 25000
entry.IdentificationNumber = "45689033"
entry.SetCATXAddendaRecords(1)
entry.SetCATXReceivingCompany("Receiver Company")
entry.SetTraceNumber(mockBatchTRXHeader().ODFIIdentification, 1)
entry.SetItemTypeIndicator("01")
entry.Category = CategoryForward
return entry
}
// mockBatchTRX creates a BatchTRX
func mockBatchTRX() *BatchTRX {
mockBatch := NewBatchTRX(mockBatchTRXHeader())
mockBatch.AddEntry(mockTRXEntryDetail())
mockBatch.GetEntries()[0].AddAddenda05(mockAddenda05())
mockBatch.Entries[0].AddendaRecordIndicator = 1
if err := mockBatch.Create(); err != nil {
log.Fatal(err)
}
return mockBatch
}
// mockBatchTRXHeaderCredit creates a BatchTRX BatchHeader
func mockBatchTRXHeaderCredit() *BatchHeader {
bh := NewBatchHeader()
bh.ServiceClassCode = DebitsOnly
bh.StandardEntryClassCode = TRX
bh.CompanyName = "Payee Name"
bh.CompanyIdentification = "121042882"
bh.CompanyEntryDescription = TRX
bh.ODFIIdentification = "12104288"
return bh
}
// mockTRXEntryDetailCredit creates a TRX EntryDetail with a credit entry
func mockTRXEntryDetailCredit() *EntryDetail {
entry := NewEntryDetail()
entry.TransactionCode = CheckingCredit
entry.SetRDFI("231380104")
entry.DFIAccountNumber = "744-5678-99"
entry.Amount = 25000
entry.SetCheckSerialNumber("123456789")
entry.SetProcessControlField("CHECK1")
entry.SetItemResearchNumber("182726")
entry.SetTraceNumber(mockBatchTRXHeader().ODFIIdentification, 1)
entry.Category = CategoryForward
return entry
}
// mockBatchTRXCredit creates a BatchTRX with a Credit entry
func mockBatchTRXCredit() *BatchTRX {
mockBatch := NewBatchTRX(mockBatchTRXHeaderCredit())
mockBatch.AddEntry(mockTRXEntryDetailCredit())
return mockBatch
}
// testBatchTRXHeader creates a BatchTRX BatchHeader
func testBatchTRXHeader(t testing.TB) {
batch, _ := NewBatch(mockBatchTRXHeader())
err, ok := batch.(*BatchTRX)
if !ok {
t.Errorf("Expecting BatchTRX got %T", err)
}
}
// TestBatchTRXHeader tests validating BatchTRX BatchHeader
func TestBatchTRXHeader(t *testing.T) {
testBatchTRXHeader(t)
}
// BenchmarkBatchTRXHeader benchmarks validating BatchTRX BatchHeader
func BenchmarkBatchTRXHeader(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXHeader(b)
}
}
// testBatchTRXCreate validates BatchTRX create
func testBatchTRXCreate(t testing.TB) {
mockBatch := mockBatchTRX()
if err := mockBatch.Validate(); err != nil {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchTRXCreate tests validating BatchTRX create
func TestBatchTRXCreate(t *testing.T) {
testBatchTRXCreate(t)
}
// BenchmarkBatchTRXCreate benchmarks validating BatchTRX create
func BenchmarkBatchTRXCreate(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXCreate(b)
}
}
// testBatchTRXStandardEntryClassCode validates BatchTRX create for an invalid StandardEntryClassCode
func testBatchTRXStandardEntryClassCode(t testing.TB) {
mockBatch := mockBatchTRX()
mockBatch.Header.StandardEntryClassCode = WEB
err := mockBatch.Create()
if !base.Match(err, ErrBatchSECType) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchTRXStandardEntryClassCode tests validating BatchTRX create for an invalid StandardEntryClassCode
func TestBatchTRXStandardEntryClassCode(t *testing.T) {
testBatchTRXStandardEntryClassCode(t)
}
// BenchmarkBatchTRXStandardEntryClassCode benchmarks validating BatchTRX create for an invalid StandardEntryClassCode
func BenchmarkBatchTRXStandardEntryClassCode(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXStandardEntryClassCode(b)
}
}
// testBatchTRXServiceClassCodeEquality validates service class code equality
func testBatchTRXServiceClassCodeEquality(t testing.TB) {
mockBatch := mockBatchTRX()
mockBatch.GetControl().ServiceClassCode = MixedDebitsAndCredits
err := mockBatch.Validate()
if !base.Match(err, NewErrBatchHeaderControlEquality(220, MixedDebitsAndCredits)) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchTRXServiceClassCodeEquality tests validating service class code equality
func TestBatchTRXServiceClassCodeEquality(t *testing.T) {
testBatchTRXServiceClassCodeEquality(t)
}
// BenchmarkBatchTRXServiceClassCodeEquality benchmarks validating service class code equality
func BenchmarkBatchTRXServiceClassCodeEquality(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXServiceClassCodeEquality(b)
}
}
// testBatchTRXAddendaCount validates BatchTRX Addendum count of 2
func testBatchTRXAddendaCount(t testing.TB) {
mockBatch := mockBatchTRX()
mockBatch.GetEntries()[0].AddAddenda05(mockAddenda05())
err := mockBatch.Create()
if !base.Match(err, NewErrBatchExpectedAddendaCount(2, 1)) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchTRXAddendaCount tests validating BatchTRX Addendum count of 2
func TestBatchTRXAddendaCount(t *testing.T) {
testBatchTRXAddendaCount(t)
}
// BenchmarkBatchTRXAddendaCount benchmarks validating BatchTRX Addendum count of 2
func BenchmarkBatchTRXAddendaCount(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXAddendaCount(b)
}
}
// testBatchTRXAddendaCountZero validates Addendum count of 0
func testBatchTRXAddendaCountZero(t testing.TB) {
mockBatch := NewBatchTRX(mockBatchTRXHeader())
mockBatch.AddEntry(mockTRXEntryDetail())
err := mockBatch.Create()
if !base.Match(err, NewErrBatchExpectedAddendaCount(0, 1)) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchTRXAddendaCountZero tests validating Addendum count of 0
func TestBatchTRXAddendaCountZero(t *testing.T) {
testBatchTRXAddendaCountZero(t)
}
// BenchmarkBatchTRXAddendaCountZero benchmarks validating Addendum count of 0
func BenchmarkBatchTRXAddendaCountZero(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXAddendaCountZero(b)
}
}
// testBatchTRXInvalidAddendum validates Addendum must be Addenda05
func testBatchTRXInvalidAddendum(t testing.TB) {
mockBatch := NewBatchTRX(mockBatchTRXHeader())
mockBatch.AddEntry(mockTRXEntryDetail())
mockBatch.GetEntries()[0].Addenda02 = mockAddenda02()
mockBatch.Entries[0].AddendaRecordIndicator = 1
err := mockBatch.Create()
if !base.Match(err, NewErrBatchExpectedAddendaCount(0, 1)) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchTRXInvalidAddendum tests validating Addendum must be Addenda05
func TestBatchTRXInvalidAddendum(t *testing.T) {
testBatchTRXInvalidAddendum(t)
}
// BenchmarkBatchTRXInvalidAddendum benchmarks validating Addendum must be Addenda05
func BenchmarkBatchTRXInvalidAddendum(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXInvalidAddendum(b)
}
}
// testBatchTRXInvalidAddenda validates Addendum must be Addenda05 with record type 7
func testBatchTRXInvalidAddenda(t testing.TB) {
mockBatch := NewBatchTRX(mockBatchTRXHeader())
mockBatch.AddEntry(mockTRXEntryDetail())
addenda05 := mockAddenda05()
addenda05.recordType = "63"
mockBatch.GetEntries()[0].AddAddenda05(addenda05)
mockBatch.Entries[0].AddendaRecordIndicator = 1
err := mockBatch.Create()
if !base.Match(err, NewErrRecordType(7)) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchTRXInvalidAddenda tests validating Addendum must be Addenda05 with record type 7
func TestBatchTRXInvalidAddenda(t *testing.T) {
testBatchTRXInvalidAddenda(t)
}
// BenchmarkBatchTRXInvalidAddenda benchmarks validating Addendum must be Addenda05 with record type 7
func BenchmarkBatchTRXInvalidAddenda(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXInvalidAddenda(b)
}
}
// testBatchTRXInvalidBuild validates an invalid batch build
func testBatchTRXInvalidBuild(t testing.TB) {
mockBatch := mockBatchTRX()
mockBatch.GetHeader().recordType = "3"
err := mockBatch.Create()
if !base.Match(err, NewErrRecordType(5)) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchTRXInvalidBuild tests validating an invalid batch build
func TestBatchTRXInvalidBuild(t *testing.T) {
testBatchTRXInvalidBuild(t)
}
// BenchmarkBatchTRXInvalidBuild benchmarks validating an invalid batch build
func BenchmarkBatchTRXInvalidBuild(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXInvalidBuild(b)
}
}
// testBatchTRXAddenda10000 validates error for 10000 Addenda
func testBatchTRXAddenda10000(t testing.TB) {
bh := NewBatchHeader()
bh.ServiceClassCode = DebitsOnly
bh.StandardEntryClassCode = TRX
bh.CompanyName = "Payee Name"
bh.CompanyIdentification = "121042882"
bh.CompanyEntryDescription = "ACH TRX"
bh.ODFIIdentification = "12104288"
entry := NewEntryDetail()
entry.TransactionCode = CheckingDebit
entry.SetRDFI("231380104")
entry.DFIAccountNumber = "744-5678-99"
entry.Amount = 25000
entry.IdentificationNumber = "45689033"
entry.SetCATXAddendaRecords(9999)
entry.SetCATXReceivingCompany("Receiver Company")
entry.SetTraceNumber(mockBatchTRXHeader().ODFIIdentification, 1)
entry.SetItemTypeIndicator("01")
entry.Category = CategoryForward
mockBatch := NewBatchTRX(bh)
mockBatch.AddEntry(entry)
for i := 0; i < 10000; i++ {
mockBatch.GetEntries()[0].AddAddenda05(mockAddenda05())
}
mockBatch.Entries[0].AddendaRecordIndicator = 1
err := mockBatch.Create()
if !base.Match(err, NewErrBatchAddendaCount(10000, 9999)) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchTRXAddenda10000 tests validating error for 10000 Addenda
func TestBatchTRXAddenda10000(t *testing.T) {
testBatchTRXAddenda10000(t)
}
// BenchmarkBatchTRXAddenda10000 benchmarks validating error for 10000 Addenda
func BenchmarkBatchTRXAddenda10000(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXAddenda10000(b)
}
}
// testBatchTRXAddendaRecords validates error for AddendaRecords not equal to addendum
func testBatchTRXAddendaRecords(t testing.TB) {
bh := NewBatchHeader()
bh.ServiceClassCode = DebitsOnly
bh.StandardEntryClassCode = TRX
bh.CompanyName = "Payee Name"
bh.CompanyIdentification = "121042882"
bh.CompanyEntryDescription = "ACH TRX"
bh.ODFIIdentification = "12104288"
entry := NewEntryDetail()
entry.TransactionCode = CheckingDebit
entry.SetRDFI("231380104")
entry.DFIAccountNumber = "744-5678-99"
entry.Amount = 25000
entry.IdentificationNumber = "45689033"
entry.SetCATXAddendaRecords(500)
entry.SetCATXReceivingCompany("Receiver Company")
entry.SetTraceNumber(mockBatchTRXHeader().ODFIIdentification, 1)
entry.DiscretionaryData = "01"
entry.Category = CategoryForward
mockBatch := NewBatchTRX(bh)
mockBatch.AddEntry(entry)
for i := 0; i < 565; i++ {
mockBatch.GetEntries()[0].AddAddenda05(mockAddenda05())
}
mockBatch.Entries[0].AddendaRecordIndicator = 1
err := mockBatch.Create()
if !base.Match(err, NewErrBatchExpectedAddendaCount(565, 500)) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchTRXAddendaRecords tests validating error for AddendaRecords not equal to addendum
func TestBatchTRXAddendaRecords(t *testing.T) {
testBatchTRXAddendaRecords(t)
}
// BenchmarkBatchAddendaRecords benchmarks validating error for AddendaRecords not equal to addendum
func BenchmarkBatchTRXAddendaRecords(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXAddendaRecords(b)
}
}
// testBatchTRXReceivingCompany validates TRXReceivingCompany
func testBatchTRXReceivingCompany(t testing.TB) {
mockBatch := mockBatchTRX()
//mockBatch.GetEntries()[0].SetCATXReceivingCompany("Receiver")
if mockBatch.GetEntries()[0].CATXReceivingCompanyField() != "Receiver Company" {
t.Errorf("expected %v got %v", "Receiver Company", mockBatch.GetEntries()[0].CATXReceivingCompanyField())
}
}
// TestBatchTRXReceivingCompany tests validating TRXReceivingCompany
func TestBatchTRXReceivingCompany(t *testing.T) {
testBatchTRXReceivingCompany(t)
}
// BenchmarkBatchTRXReceivingCompany benchmarks validating TRXReceivingCompany
func BenchmarkBatchTRXReceivingCompany(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXReceivingCompany(b)
}
}
// testBatchTRXReserved validates TRXReservedField
func testBatchTRXReserved(t testing.TB) {
mockBatch := mockBatchTRX()
if mockBatch.GetEntries()[0].CATXReservedField() != " " {
t.Errorf("expected %v got %v", " ", mockBatch.GetEntries()[0].CATXReservedField())
}
}
// TestBatchTRXReserved tests validating TRXReservedField
func TestBatchTRXReserved(t *testing.T) {
testBatchTRXReserved(t)
}
// BenchmarkBatchTRXReserved benchmarks validating TRXReservedField
func BenchmarkBatchTRXReserved(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXReserved(b)
}
}
// testBatchTRXZeroAddendaRecords validates zero addenda records
func testBatchTRXZeroAddendaRecords(t testing.TB) {
bh := NewBatchHeader()
bh.ServiceClassCode = DebitsOnly
bh.StandardEntryClassCode = TRX
bh.CompanyName = "Payee Name"
bh.CompanyIdentification = "121042882"
bh.CompanyEntryDescription = "ACH TRX"
bh.ODFIIdentification = "12104288"
entry := NewEntryDetail()
entry.TransactionCode = CheckingDebit
entry.SetRDFI("231380104")
entry.DFIAccountNumber = "744-5678-99"
entry.Amount = 25000
entry.IdentificationNumber = "45689033"
entry.SetCATXAddendaRecords(1)
entry.SetCATXReceivingCompany("Receiver Company")
entry.SetTraceNumber(mockBatchTRXHeader().ODFIIdentification, 1)
entry.DiscretionaryData = "01"
entry.Category = CategoryForward
mockBatch := NewBatchTRX(bh)
mockBatch.AddEntry(entry)
err := mockBatch.Create()
if !base.Match(err, NewErrBatchExpectedAddendaCount(0, 1)) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchTRXZeroAddendaRecords tests validating zero addenda records
func TestBatchTRXZeroAddendaRecords(t *testing.T) {
testBatchTRXZeroAddendaRecords(t)
}
// BenchmarkBatchZeroAddendaRecords benchmarks validating zero addenda records
func BenchmarkBatchTRXZeroAddendaRecords(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXZeroAddendaRecords(b)
}
}
// testBatchTRXTransactionCode validates BatchTRX TransactionCode is not a credit
func testBatchTRXTransactionCode(t testing.TB) {
mockBatch := mockBatchTRXCredit()
err := mockBatch.Create()
if !base.Match(err, ErrBatchDebitOnly) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchTRXTransactionCode tests validating BatchTRX TransactionCode is not a credit
func TestBatchTRXTransactionCode(t *testing.T) {
testBatchTRXTransactionCode(t)
}
// BenchmarkBatchTRXTransactionCode benchmarks validating BatchTRX TransactionCode is not a credit
func BenchmarkBatchTRXTransactionCode(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXTransactionCode(b)
}
}
// TestBatchTRXAddendum98 validates Addenda98 returns an error
func TestBatchTRXAddendum98(t *testing.T) {
mockBatch := NewBatchTRX(mockBatchTRXHeader())
mockBatch.AddEntry(mockTRXEntryDetail())
mockAddenda98 := mockAddenda98()
mockAddenda98.TypeCode = "05"
mockBatch.GetEntries()[0].Category = CategoryNOC
mockBatch.GetEntries()[0].Addenda98 = mockAddenda98
err := mockBatch.Create()
if !base.Match(err, ErrAddendaTypeCode) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchTRXAddendum99 validates Addenda99 returns an error
func TestBatchTRXAddendum99(t *testing.T) {
mockBatch := NewBatchTRX(mockBatchTRXHeader())
mockBatch.AddEntry(mockCTXEntryDetail())
mockAddenda99 := mockAddenda99()
mockAddenda99.TypeCode = "05"
mockBatch.GetEntries()[0].Category = CategoryReturn
mockBatch.GetEntries()[0].Addenda99 = mockAddenda99
err := mockBatch.Create()
if !base.Match(err, ErrAddendaTypeCode) {
t.Errorf("%T: %s", err, err)
}
}
// testBatchTRXCreditsOnly validates BatchTRX create for an invalid CreditsOnly
func testBatchTRXCreditsOnly(t testing.TB) {
mockBatch := mockBatchTRX()
mockBatch.Header.ServiceClassCode = CreditsOnly
err := mockBatch.Validate()
if !base.Match(err, NewErrBatchHeaderControlEquality(CreditsOnly, 225)) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchTRXCreditsOnly tests validating BatchTRX create for an invalid CreditsOnly
func TestBatchTRXCreditsOnly(t *testing.T) {
testBatchTRXCreditsOnly(t)
}
// BenchmarkBatchTRXCreditsOnly benchmarks validating BatchTRX create for an invalid CreditsOnly
func BenchmarkBatchTRXCreditsOnly(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXCreditsOnly(b)
}
}
// testBatchTRXAutomatedAccountingAdvices validates BatchTRX create for an invalid AutomatedAccountingAdvices
func testBatchTRXAutomatedAccountingAdvices(t testing.TB) {
mockBatch := mockBatchTRX()
mockBatch.Header.ServiceClassCode = AutomatedAccountingAdvices
err := mockBatch.Validate()
if !base.Match(err, NewErrBatchHeaderControlEquality(AutomatedAccountingAdvices, 225)) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchTRXAutomatedAccountingAdvices tests validating BatchTRX create for an invalid AutomatedAccountingAdvices
func TestBatchTRXAutomatedAccountingAdvices(t *testing.T) {
testBatchTRXAutomatedAccountingAdvices(t)
}
// BenchmarkBatchTRXAutomatedAccountingAdvices benchmarks validating BatchTRX create for an invalid AutomatedAccountingAdvices
func BenchmarkBatchTRXAutomatedAccountingAdvices(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchTRXAutomatedAccountingAdvices(b)
}
}
// TestBatchTRXAddenda02 validates BatchTRX create for an invalid Addenda02
func TestBatchTRXAddenda02(t *testing.T) {
mockBatch := mockBatchTRX()
mockBatch.Entries[0].Addenda02 = mockAddenda02()
mockBatch.Entries[0].AddendaRecordIndicator = 1
err := mockBatch.Create()
if !base.Match(err, ErrBatchAddendaCategory) {
t.Errorf("%T: %s", err, err)
}
}