Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc4e31f0

Browse files
chetanmaharishichetanmaharshijmirandaewaterman
authored
OBGM-328 Reference implementation for transaction type unit tests (#4619)
Co-authored-by: chetanmaharshi <chetan.maharshi@gmail.com>Co-authored-by: jmiranda <jcm62@columbia.edu>Co-authored-by: Evan <evanwaterman@hotmail.com>
1 parent6f48e3a commitc4e31f0

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
packageunit.org.pih.warehouse.inventory
2+
3+
importgrails.testing.gorm.DomainUnitTest
4+
importspock.lang.Specification
5+
importspock.lang.Unroll
6+
7+
importorg.pih.warehouse.inventory.TransactionCode
8+
importorg.pih.warehouse.inventory.TransactionType
9+
10+
@Unroll
11+
classTransactionTypeSpecextendsSpecificationimplementsDomainUnitTest<TransactionType> {
12+
13+
def'should return #expected with error code #expectedErrorCode when validating transaction type given name #value'() {
14+
given:"the name is #value"
15+
domain.name= value
16+
17+
when:"the transaction type is validated"
18+
boolean actual= domain.validate(["name"])
19+
20+
then:"the name property should be valid or invalid with the expected error code"
21+
actual== expected
22+
domain.errors.getFieldError("name")?.code== expectedErrorCode
23+
24+
where:
25+
value|| expected | expectedErrorCode
26+
null||false |'nullable'
27+
'a'*256||false |'maxSize.exceeded'
28+
'b'*255||true |null
29+
'Dummy Name'||true |null
30+
}
31+
32+
void'should return #expected with error code #expectedErrorCode when validating transaction type given name #value'() {
33+
when:
34+
domain.description= value
35+
36+
then:
37+
assert domain.validate(['description'])== expected
38+
assert domain.errors.getFieldError("description")?.code== expectedErrorCode
39+
40+
where:
41+
value|| expected | expectedErrorCode
42+
null||true |null
43+
'a'*256||false |'maxSize.exceeded'
44+
'Dummy description'||true |null
45+
}
46+
47+
void'compareName should expect the names to be the same'() {
48+
given:"a valid transaction type with multiple"
49+
TransactionType transactionType=
50+
newTransactionType(name:"Debit|sp:Débito|fr:Débit",transactionCode:TransactionCode.DEBIT)
51+
52+
when:"the name is compared with debit"
53+
boolean nameIsSame= transactionType.compareName("Debit")
54+
55+
then:"the name is the same"
56+
assert nameIsSame
57+
}
58+
59+
void'should return #expected with error code #expectedErrorCode when validating transaction type given name #value'() {
60+
given:
61+
domain.transactionCode= value
62+
63+
when:
64+
boolean actual= domain.validate(['transactionCode'])
65+
66+
then:
67+
actual== expected
68+
domain.errors.getFieldError("transactionCode")?.code== expectedErrorCode
69+
70+
where:
71+
value|| expected | expectedErrorCode
72+
null||false |'nullable'
73+
TransactionCode.DEBIT||true |null
74+
}
75+
76+
void'isAdjustment should return #expected when given name #value'() {
77+
given:
78+
domain.name= value
79+
80+
expect:
81+
domain.isAdjustment()== expected
82+
83+
where:
84+
value|| expected
85+
'Adjustment|fr:Ajustement|es:Ajustamiento'||true
86+
'NO_Adjustment'||false
87+
'Adjustment'||true
88+
}
89+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp