Skip to content

Commit e280c66

Browse files
committed
CollectionService.createCollection(): modify check for invalid slug.
Unify this check with the similar in CategoryService/CountryService and also make it possible to write unit test for it. Addressed to #35
1 parent 3057460 commit e280c66

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
package ru.mystamps.web.service;
1919

20+
import org.apache.commons.lang3.StringUtils;
2021
import org.apache.commons.lang3.Validate;
2122

2223
import org.slf4j.Logger;
@@ -49,7 +50,10 @@ public void createCollection(Integer ownerId, String ownerLogin) {
4950
collection.setOwnerId(ownerId);
5051

5152
String slug = SlugUtils.slugify(ownerLogin);
52-
Validate.isTrue(slug != null, "Slug for string '%s' is null", ownerLogin);
53+
Validate.isTrue(
54+
StringUtils.isNotEmpty(slug),
55+
"Slug for string '%s' must be non empty", ownerLogin
56+
);
5357
collection.setSlug(slug);
5458

5559
Integer id = collectionDao.add(collection);

0 commit comments

Comments
 (0)