-
Notifications
You must be signed in to change notification settings - Fork 151
/
batchSHR_test.go
570 lines (503 loc) · 18.6 KB
/
batchSHR_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
// 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 (
"testing"
"github.com/moov-io/base"
"github.com/stretchr/testify/require"
)
// mockBatchSHRHeader creates a BatchSHR BatchHeader
func mockBatchSHRHeader() *BatchHeader {
bh := NewBatchHeader()
bh.ServiceClassCode = DebitsOnly
bh.StandardEntryClassCode = SHR
bh.CompanyName = "Payee Name"
bh.CompanyIdentification = "121042882"
bh.CompanyEntryDescription = "ACH SHR"
bh.ODFIIdentification = "12104288"
return bh
}
// mockSHREntryDetail creates a BatchSHR EntryDetail
func mockSHREntryDetail() *EntryDetail {
entry := NewEntryDetail()
entry.TransactionCode = CheckingDebit
entry.SetRDFI("231380104")
entry.DFIAccountNumber = "744-5678-99"
entry.Amount = 25000
entry.SetSHRCardExpirationDate("0722")
entry.SetSHRDocumentReferenceNumber("12345678910")
entry.SetSHRIndividualCardAccountNumber("1234567891123456789")
entry.SetTraceNumber(mockBatchSHRHeader().ODFIIdentification, 1)
entry.DiscretionaryData = "01"
entry.Category = CategoryForward
return entry
}
// mockBatchSHR creates a BatchSHR
func mockBatchSHR(t testing.TB) *BatchSHR {
mockBatch := NewBatchSHR(mockBatchSHRHeader())
mockBatch.AddEntry(mockSHREntryDetail())
mockBatch.GetEntries()[0].Addenda02 = mockAddenda02()
mockBatch.Entries[0].AddendaRecordIndicator = 1
require.NoError(t, mockBatch.Create())
return mockBatch
}
// testBatchSHRHeader creates a BatchSHR BatchHeader
func testBatchSHRHeader(t testing.TB) {
batch, _ := NewBatch(mockBatchSHRHeader())
err, ok := batch.(*BatchSHR)
if !ok {
t.Errorf("Expecting BatchSHR got %T", err)
}
}
// TestBatchSHRHeader tests validating BatchSHR BatchHeader
func TestBatchSHRHeader(t *testing.T) {
testBatchSHRHeader(t)
}
// BenchmarkBatchSHRHeader benchmarks validating BatchSHR BatchHeader
func BenchmarkBatchSHRHeader(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRHeader(b)
}
}
// testBatchSHRCreate validates BatchSHR create
func testBatchSHRCreate(t testing.TB) {
mockBatch := mockBatchSHR(t)
if err := mockBatch.Create(); err != nil {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchSHRCreate tests validating BatchSHR create
func TestBatchSHRCreate(t *testing.T) {
testBatchSHRCreate(t)
}
// BenchmarkBatchSHRCreate benchmarks validating BatchSHR create
func BenchmarkBatchSHRCreate(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRCreate(b)
}
}
// testBatchSHRStandardEntryClassCode validates BatchSHR create for an invalid StandardEntryClassCode
func testBatchSHRStandardEntryClassCode(t testing.TB) {
mockBatch := mockBatchSHR(t)
mockBatch.Header.StandardEntryClassCode = WEB
err := mockBatch.Create()
if !base.Match(err, ErrBatchSECType) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchSHRStandardEntryClassCode tests validating BatchSHR create for an invalid StandardEntryClassCode
func TestBatchSHRStandardEntryClassCode(t *testing.T) {
testBatchSHRStandardEntryClassCode(t)
}
// BenchmarkBatchSHRStandardEntryClassCode benchmarks validating BatchSHR create for an invalid StandardEntryClassCode
func BenchmarkBatchSHRStandardEntryClassCode(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRStandardEntryClassCode(b)
}
}
// testBatchSHRServiceClassCodeEquality validates service class code equality
func testBatchSHRServiceClassCodeEquality(t testing.TB) {
mockBatch := mockBatchSHR(t)
mockBatch.GetControl().ServiceClassCode = MixedDebitsAndCredits
err := mockBatch.Validate()
if !base.Match(err, NewErrBatchHeaderControlEquality(220, MixedDebitsAndCredits)) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchSHRServiceClassCodeEquality tests validating service class code equality
func TestBatchSHRServiceClassCodeEquality(t *testing.T) {
testBatchSHRServiceClassCodeEquality(t)
}
// BenchmarkBatchSHRServiceClassCodeEquality benchmarks validating service class code equality
func BenchmarkBatchSHRServiceClassCodeEquality(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRServiceClassCodeEquality(b)
}
}
// testBatchSHRMixedCreditsAndDebits validates BatchSHR create for an invalid MixedCreditsAndDebits
func testBatchSHRMixedCreditsAndDebits(t testing.TB) {
mockBatch := mockBatchSHR(t)
mockBatch.Header.ServiceClassCode = MixedDebitsAndCredits
err := mockBatch.Validate()
if !base.Match(err, NewErrBatchHeaderControlEquality(MixedDebitsAndCredits, 225)) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchSHRMixedCreditsAndDebits tests validating BatchSHR create for an invalid MixedCreditsAndDebits
func TestBatchSHRMixedCreditsAndDebits(t *testing.T) {
testBatchSHRMixedCreditsAndDebits(t)
}
// BenchmarkBatchSHRMixedCreditsAndDebits benchmarks validating BatchSHR create for an invalid MixedCreditsAndDebits
func BenchmarkBatchSHRMixedCreditsAndDebits(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRMixedCreditsAndDebits(b)
}
}
// testBatchSHRCreditsOnly validates BatchSHR create for an invalid CreditsOnly
func testBatchSHRCreditsOnly(t testing.TB) {
mockBatch := mockBatchSHR(t)
mockBatch.Header.ServiceClassCode = CreditsOnly
err := mockBatch.Validate()
if !base.Match(err, NewErrBatchHeaderControlEquality(CreditsOnly, 225)) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchSHRCreditsOnly tests validating BatchSHR create for an invalid CreditsOnly
func TestBatchSHRCreditsOnly(t *testing.T) {
testBatchSHRCreditsOnly(t)
}
// BenchmarkBatchSHRCreditsOnly benchmarks validating BatchSHR create for an invalid CreditsOnly
func BenchmarkBatchSHRCreditsOnly(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRCreditsOnly(b)
}
}
// testBatchSHRAutomatedAccountingAdvices validates BatchSHR create for an invalid AutomatedAccountingAdvices
func testBatchSHRAutomatedAccountingAdvices(t testing.TB) {
mockBatch := mockBatchSHR(t)
mockBatch.Header.ServiceClassCode = AutomatedAccountingAdvices
err := mockBatch.Validate()
if !base.Match(err, NewErrBatchHeaderControlEquality(AutomatedAccountingAdvices, 225)) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchSHRAutomatedAccountingAdvices tests validating BatchSHR create for an invalid AutomatedAccountingAdvices
func TestBatchSHRAutomatedAccountingAdvices(t *testing.T) {
testBatchSHRAutomatedAccountingAdvices(t)
}
// BenchmarkBatchSHRAutomatedAccountingAdvices benchmarks validating BatchSHR create for an invalid AutomatedAccountingAdvices
func BenchmarkBatchSHRAutomatedAccountingAdvices(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRAutomatedAccountingAdvices(b)
}
}
// testBatchSHRTransactionCode validates BatchSHR TransactionCode is not a credit
func testBatchSHRTransactionCode(t testing.TB) {
mockBatch := mockBatchSHR(t)
mockBatch.GetEntries()[0].TransactionCode = CheckingCredit
err := mockBatch.Create()
if !base.Match(err, ErrBatchDebitOnly) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchSHRTransactionCode tests validating BatchSHR TransactionCode is not a credit
func TestBatchSHRTransactionCode(t *testing.T) {
testBatchSHRTransactionCode(t)
}
// BenchmarkBatchSHRTransactionCode benchmarks validating BatchSHR TransactionCode is not a credit
func BenchmarkBatchSHRTransactionCode(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRTransactionCode(b)
}
}
// testBatchSHRAddendaCount validates BatchSHR Addendum count of 2
func testBatchSHRAddendaCount(t testing.TB) {
mockBatch := mockBatchSHR(t)
mockBatch.GetEntries()[0].Addenda02 = mockAddenda02()
err := mockBatch.Create()
// TODO: are we not expecting any errors here?
if !base.Match(err, nil) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchSHRAddendaCount tests validating BatchSHR Addendum count of 2
func TestBatchSHRAddendaCount(t *testing.T) {
testBatchSHRAddendaCount(t)
}
// BenchmarkBatchSHRAddendaCount benchmarks validating BatchSHR Addendum count of 2
func BenchmarkBatchSHRAddendaCount(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRAddendaCount(b)
}
}
// testBatchSHRAddendaCountZero validates Addendum count of 0
func testBatchSHRAddendaCountZero(t testing.TB) {
mockBatch := NewBatchSHR(mockBatchSHRHeader())
mockBatch.AddEntry(mockSHREntryDetail())
mockAddenda02 := mockAddenda02()
mockBatch.GetEntries()[0].Addenda02 = mockAddenda02
mockBatch.Entries[0].AddendaRecordIndicator = 1
err := mockBatch.Validate()
if !base.Match(err, NewErrBatchHeaderControlEquality("225", "200")) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchSHRAddendaCountZero tests validating Addendum count of 0
func TestBatchSHRAddendaCountZero(t *testing.T) {
testBatchSHRAddendaCountZero(t)
}
// BenchmarkBatchSHRAddendaCountZero benchmarks validating Addendum count of 0
func BenchmarkBatchSHRAddendaCountZero(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRAddendaCountZero(b)
}
}
// TestBatchSHRAddendum98 validates Addenda98 returns an error
func TestBatchSHRAddendum98(t *testing.T) {
mockBatch := NewBatchSHR(mockBatchSHRHeader())
mockBatch.AddEntry(mockSHREntryDetail())
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)
}
}
// TestBatchSHRAddendum99 validates Addenda99 returns an error
func TestBatchSHRAddendum99(t *testing.T) {
mockBatch := NewBatchSHR(mockBatchSHRHeader())
mockBatch.AddEntry(mockSHREntryDetail())
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)
}
}
// testBatchSHRInvalidAddendum validates Addendum must be Addenda02
func testBatchSHRInvalidAddendum(t testing.TB) {
mockBatch := NewBatchSHR(mockBatchSHRHeader())
mockBatch.AddEntry(mockSHREntryDetail())
mockBatch.GetEntries()[0].Addenda02 = mockAddenda02()
mockBatch.GetEntries()[0].AddAddenda05(mockAddenda05())
mockBatch.Entries[0].AddendaRecordIndicator = 1
err := mockBatch.Create()
if !base.Match(err, ErrBatchAddendaCategory) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchSHRInvalidAddendum tests validating Addendum must be Addenda02
func TestBatchSHRInvalidAddendum(t *testing.T) {
testBatchSHRInvalidAddendum(t)
}
// BenchmarkBatchSHRInvalidAddendum benchmarks validating Addendum must be Addenda02
func BenchmarkBatchSHRInvalidAddendum(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRInvalidAddendum(b)
}
}
// testBatchSHRInvalidAddenda validates Addendum must be Addenda02
func testBatchSHRInvalidAddenda(t testing.TB) {
mockBatch := NewBatchSHR(mockBatchSHRHeader())
mockBatch.AddEntry(mockSHREntryDetail())
addenda02 := mockAddenda02()
addenda02.TypeCode = "63"
mockBatch.GetEntries()[0].Addenda02 = addenda02
mockBatch.Entries[0].AddendaRecordIndicator = 1
err := mockBatch.Create()
if !base.Match(err, ErrAddendaTypeCode) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchSHRInvalidAddenda tests validating Addendum must be Addenda02
func TestBatchSHRInvalidAddenda(t *testing.T) {
testBatchSHRInvalidAddenda(t)
}
// BenchmarkBatchSHRInvalidAddenda benchmarks validating Addendum must be Addenda02
func BenchmarkBatchSHRInvalidAddenda(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRInvalidAddenda(b)
}
}
// testBatchSHRInvalidBuild validates an invalid batch build
func testBatchSHRInvalidBuild(t testing.TB) {
mockBatch := mockBatchSHR(t)
mockBatch.GetHeader().ServiceClassCode = 3
err := mockBatch.Create()
if !base.Match(err, ErrServiceClass) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchSHRInvalidBuild tests validating an invalid batch build
func TestBatchSHRInvalidBuild(t *testing.T) {
testBatchSHRInvalidBuild(t)
}
// BenchmarkBatchSHRInvalidBuild benchmarks validating an invalid batch build
func BenchmarkBatchSHRInvalidBuild(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRInvalidBuild(b)
}
}
// testBatchSHRCardTransactionType validates BatchSHR create for an invalid CardTransactionType
func testBatchSHRCardTransactionType(t testing.TB) {
mockBatch := mockBatchSHR(t)
mockBatch.GetEntries()[0].DiscretionaryData = "555"
err := mockBatch.Validate()
if !base.Match(err, ErrBatchInvalidCardTransactionType) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchSHRCardTransactionType tests validating BatchSHR create for an invalid CardTransactionType
func TestBatchSHRCardTransactionType(t *testing.T) {
testBatchSHRCardTransactionType(t)
}
// BenchmarkBatchSHRCardTransactionType benchmarks validating BatchSHR create for an invalid CardTransactionType
func BenchmarkBatchSHRCardTransactionType(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRCardTransactionType(b)
}
}
// testBatchSHRCardExpirationDateField validates SHRCardExpirationDate
// characters 0-4 of underlying IdentificationNumber
func testBatchSHRCardExpirationDateField(t testing.TB) {
mockBatch := mockBatchSHR(t)
ts := mockBatch.Entries[0].SHRCardExpirationDateField()
if ts != "0722" {
t.Error("Card Expiration Date is invalid")
}
}
// TestBatchSHRCardExpirationDateField tests validatingSHRCardExpirationDate
// characters 0-4 of underlying IdentificationNumber
func TestBatchSHRCardExpirationDateField(t *testing.T) {
testBatchSHRCardExpirationDateField(t)
}
// BenchmarkBatchSHRCardExpirationDateField benchmarks validating SHRCardExpirationDate
// characters 0-4 of underlying IdentificationNumber
func BenchmarkBatchSHRCardExpirationDateField(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRCardExpirationDateField(b)
}
}
// testBatchSHRDocumentReferenceNumberField validates SHRDocumentReferenceNumberField
// characters 5-15 of underlying IdentificationNumber
func testBatchSHRDocumentReferenceNumberField(t testing.TB) {
mockBatch := mockBatchSHR(t)
ts := mockBatch.Entries[0].SHRDocumentReferenceNumberField()
if ts != "12345678910" {
t.Error("Document Reference Number is invalid")
}
}
// TestBatchSHRDocumentReferenceNumberField tests validating SHRDocumentReferenceNumberField
// characters 5-15 of underlying IdentificationNumber
func TestBatchSHRDocumentReferenceNumberField(t *testing.T) {
testBatchSHRDocumentReferenceNumberField(t)
}
// BenchmarkBatchSHRDocumentReferenceNumberField benchmarks validating SHRDocumentReferenceNumberField
// characters 5-15 of underlying IdentificationNumber
func BenchmarkSHRDocumentReferenceNumberField(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRDocumentReferenceNumberField(b)
}
}
// testBatchSHRIndividualCardAccountNumberField validates SHRIndividualCardAccountNumberField
// underlying IndividualName
func testBatchSHRIndividualCardAccountNumberField(t testing.TB) {
mockBatch := mockBatchSHR(t)
ts := mockBatch.Entries[0].SHRIndividualCardAccountNumberField()
if ts != "0001234567891123456789" {
t.Error("Individual Card Account Number is invalid")
}
}
// TestBatchSHRIndividualCardAccountNumberField tests validating SHRIndividualCardAccountNumberField
// underlying IndividualName
func TestBatchSHRIndividualCardAccountNumberField(t *testing.T) {
testBatchSHRIndividualCardAccountNumberField(t)
}
// BenchmarkBatchSHRIndividualCardAccountNumberField benchmarks validating SHRIndividualCardAccountNumberField
// underlying IndividualName
func BenchmarkBatchSHRDocumentReferenceNumberField(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testBatchSHRIndividualCardAccountNumberField(b)
}
}
// testSHRCardExpirationDateMonth validates the month is valid for CardExpirationDate
func testSHRCardExpirationDateMonth(t testing.TB) {
mockBatch := mockBatchSHR(t)
mockBatch.GetEntries()[0].SetSHRCardExpirationDate("1306")
err := mockBatch.Validate()
if !base.Match(err, ErrValidMonth) {
t.Errorf("%T: %s", err, err)
}
}
// TestSHRCardExpirationDateMonth tests validating the month is valid for CardExpirationDate
func TestSHRSHRCardExpirationDateMonth(t *testing.T) {
testSHRCardExpirationDateMonth(t)
}
// BenchmarkSHRCardExpirationDateMonth test validating the month is valid for CardExpirationDate
func BenchmarkSHRCardExpirationDateMonth(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testSHRCardExpirationDateMonth(b)
}
}
// testSHRCardExpirationDateYear validates the year is valid for CardExpirationDate
func testSHRCardExpirationDateYear(t testing.TB) {
mockBatch := mockBatchSHR(t)
mockBatch.GetEntries()[0].SetSHRCardExpirationDate("0612")
err := mockBatch.Validate()
if !base.Match(err, ErrValidYear) {
t.Errorf("%T: %s", err, err)
}
}
// TestSHRCardExpirationDateYear tests validating the year is valid for CardExpirationDate
func TestSHRSHRCardExpirationDateYear(t *testing.T) {
testSHRCardExpirationDateYear(t)
}
// BenchmarkSHRCardExpirationDateYear test validating the year is valid for CardExpirationDate
func BenchmarkSHRCardExpirationDateYear(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
testSHRCardExpirationDateYear(b)
}
}
// TestBatchSHRAddendum99Category validates Addenda99 returns an error
func TestBatchSHRAddendum99Category(t *testing.T) {
mockBatch := NewBatchSHR(mockBatchSHRHeader())
mockBatch.AddEntry(mockSHREntryDetail())
mockAddenda99 := mockAddenda99()
mockBatch.Entries[0].AddendaRecordIndicator = 1
mockBatch.Entries[0].Category = CategoryNOC
mockBatch.Entries[0].Addenda99 = mockAddenda99
err := mockBatch.Create()
if !base.Match(err, ErrBatchAddendaCategory) {
t.Errorf("%T: %s", err, err)
}
}
// TestBatchSHRTerminalState validates TerminalState returns an error if invalid from usabbrev
func TestBatchSHRTerminalState(t *testing.T) {
mockBatch := NewBatchSHR(mockBatchSHRHeader())
mockBatch.AddEntry(mockSHREntryDetail())
mockAddenda02 := mockAddenda02()
mockAddenda02.TerminalState = "YY"
mockBatch.GetEntries()[0].Addenda02 = mockAddenda02
mockBatch.Entries[0].AddendaRecordIndicator = 1
err := mockBatch.Create()
if !base.Match(err, ErrValidState) {
t.Errorf("%T: %s", err, err)
}
}