Skip to content

Commit 7f4ba12

Browse files
committed
CollectionServiceImpl: use NOPLogger for unit tests to reduce output to console.
No functional changes.
1 parent 35738be commit 7f4ba12

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/main/java/ru/mystamps/web/config/ServicesConfig.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ public CategoryService getCategoryService() {
6767

6868
@Bean
6969
public CollectionService getCollectionService() {
70-
return new CollectionServiceImpl(daoConfig.getCollectionDao());
70+
return new CollectionServiceImpl(
71+
LoggerFactory.getLogger(CollectionServiceImpl.class),
72+
daoConfig.getCollectionDao()
73+
);
7174
}
7275

7376
@Bean

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.apache.commons.lang3.Validate;
2525

2626
import org.slf4j.Logger;
27-
import org.slf4j.LoggerFactory;
2827

2928
import org.springframework.transaction.annotation.Transactional;
3029

@@ -41,8 +40,8 @@
4140

4241
@RequiredArgsConstructor
4342
public class CollectionServiceImpl implements CollectionService {
44-
private static final Logger LOG = LoggerFactory.getLogger(CollectionServiceImpl.class);
4543

44+
private final Logger log;
4645
private final CollectionDao collectionDao;
4746

4847
@Override
@@ -64,7 +63,7 @@ public void createCollection(Integer ownerId, String ownerLogin) {
6463

6564
Integer id = collectionDao.add(collection);
6665

67-
LOG.info("Collection #{} has been created ({})", id, collection);
66+
log.info("Collection #{} has been created ({})", id, collection);
6867
}
6968

7069
@Override
@@ -77,7 +76,7 @@ public void addToCollection(Integer userId, Integer seriesId) {
7776
collectionDao.addSeriesToUserCollection(userId, seriesId);
7877
collectionDao.markAsModified(userId, new Date());
7978

80-
LOG.info("Series #{} has been added to collection of user #{}", seriesId, userId);
79+
log.info("Series #{} has been added to collection of user #{}", seriesId, userId);
8180
}
8281

8382
@Override
@@ -90,7 +89,7 @@ public void removeFromCollection(Integer userId, Integer seriesId) {
9089
collectionDao.removeSeriesFromUserCollection(userId, seriesId);
9190
collectionDao.markAsModified(userId, new Date());
9291

93-
LOG.info("Series #{} has been removed from collection of user #{}", seriesId, userId);
92+
log.info("Series #{} has been removed from collection of user #{}", seriesId, userId);
9493
}
9594

9695
@Override

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ package ru.mystamps.web.service
2020
import spock.lang.Specification
2121
import spock.lang.Unroll
2222

23+
import org.slf4j.helpers.NOPLogger
24+
2325
import ru.mystamps.web.dao.CollectionDao
2426
import ru.mystamps.web.dao.dto.AddCollectionDbDto
2527
import ru.mystamps.web.dao.dto.CollectionInfoDto
@@ -34,7 +36,7 @@ class CollectionServiceImplTest extends Specification {
3436
private CollectionService service
3537

3638
def setup() {
37-
service = new CollectionServiceImpl(collectionDao)
39+
service = new CollectionServiceImpl(NOPLogger.NOP_LOGGER, collectionDao)
3840
}
3941

4042
//

0 commit comments

Comments
 (0)