File tree 3 files changed +37
-0
lines changed
groovy/ru/mystamps/web/service
3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import spock.lang.Specification
27
27
import ru.mystamps.web.dao.TransactionParticipantDao
28
28
import ru.mystamps.web.dao.dto.AddParticipantDbDto
29
29
import ru.mystamps.web.dao.dto.EntityWithIdDto
30
+ import ru.mystamps.web.dao.dto.TransactionParticipantDto
30
31
import ru.mystamps.web.controller.dto.AddParticipantForm
31
32
import ru.mystamps.web.tests.Random
32
33
@@ -114,6 +115,22 @@ class TransactionParticipantServiceImplTest extends Specification {
114
115
})
115
116
}
116
117
118
+ //
119
+ // Tests for findBuyersWithParents()
120
+ //
121
+
122
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
123
+ def ' findBuyersWithParents() should invoke dao and return its result' () {
124
+ given :
125
+ List<TransactionParticipantDto > expectedResult = Random . listOfTransactionParticipantDto()
126
+ when :
127
+ List<TransactionParticipantDto > result = service. findBuyersWithParents()
128
+ then :
129
+ 1 * transactionParticipantDao. findBuyersWithParents() >> expectedResult
130
+ and :
131
+ result == expectedResult
132
+ }
133
+
117
134
//
118
135
// Tests for findAllGroups()
119
136
//
Original file line number Diff line number Diff line change @@ -209,4 +209,11 @@ public static CategoryDto createCategoryDto() {
209
209
return new CategoryDto (name , slug , parentName );
210
210
}
211
211
212
+ public static TransactionParticipantDto createTransactionParticipantDto () {
213
+ String name = Random .categoryName ();
214
+ // @todo #702 TestObjects: introduce name generator for transaction participant groups
215
+ String parentName = Random .categoryName ();
216
+ return new TransactionParticipantDto (Random .id (), name , parentName );
217
+ }
218
+
212
219
}
Original file line number Diff line number Diff line change 26
26
27
27
import ru .mystamps .web .dao .dto .CategoryDto ;
28
28
import ru .mystamps .web .dao .dto .EntityWithIdDto ;
29
+ import ru .mystamps .web .dao .dto .TransactionParticipantDto ;
29
30
import ru .mystamps .web .service .TestObjects ;
30
31
import ru .mystamps .web .validation .ValidationRules ;
31
32
@@ -145,4 +146,16 @@ public static List<CategoryDto> listOfCategoryDto() {
145
146
);
146
147
}
147
148
149
+ public static List <TransactionParticipantDto > listOfTransactionParticipantDto () {
150
+ final int minSize = 1 ;
151
+ final int maxSize = 3 ;
152
+ int size = integer (minSize , maxSize );
153
+ return sampleMultiple (
154
+ size ,
155
+ TestObjects .createTransactionParticipantDto (),
156
+ TestObjects .createTransactionParticipantDto (),
157
+ TestObjects .createTransactionParticipantDto ()
158
+ );
159
+ }
160
+
148
161
}
You can’t perform that action at this time.
0 commit comments