Skip to content

Commit 79a1b85

Browse files
committed
TransactionParticipantServiceImpl.findGroupIdByName(): add unit tests.
Fix #921
1 parent 3f4e886 commit 79a1b85

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/main/java/ru/mystamps/web/service/TransactionParticipantServiceImpl.java

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ public List<EntityWithIdDto> findAllGroups() {
9696
return transactionParticipantDao.findAllGroups();
9797
}
9898

99-
// @todo #857 TransactionParticipantServiceImpl.findGroupIdByName(): add unit tests
10099
// @todo #857 TransactionParticipantServiceImpl.findGroupIdByName(): move to a separate service
101100
@Override
102101
@Transactional(readOnly = true)

src/test/groovy/ru/mystamps/web/service/TransactionParticipantServiceImplTest.groovy

+24
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,28 @@ class TransactionParticipantServiceImplTest extends Specification {
197197
result == expectedResult
198198
}
199199

200+
//
201+
// Tests for findGroupIdByName()
202+
//
203+
204+
def 'findGroupIdByName() should throw exception when name is null, empty or blank'() {
205+
when:
206+
service.findGroupIdByName(nullOrBlank())
207+
then:
208+
IllegalArgumentException ex = thrown()
209+
ex.message == 'Group name must be non-blank'
210+
}
211+
212+
def 'findGroupIdByName() should invoke dao and return its result'() {
213+
given:
214+
String expectedName = 'Some Group'
215+
Integer expectedResult = Random.id()
216+
when:
217+
Integer result = service.findGroupIdByName(expectedName)
218+
then:
219+
1 * transactionParticipantDao.findGroupIdByName(expectedName) >> expectedResult
220+
and:
221+
result == expectedResult
222+
}
223+
200224
}

0 commit comments

Comments
 (0)