Skip to content

Commit 2ffc1a5

Browse files
committed
CronServiceImpl: use NOPLogger for unit tests to reduce output to console.
No functional changes.
1 parent ae91f14 commit 2ffc1a5

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public CollectionService getCollectionService() {
7777
@Bean
7878
public CronService getCronService() {
7979
return new CronServiceImpl(
80+
LoggerFactory.getLogger(CronServiceImpl.class),
8081
getCategoryService(),
8182
getCountryService(),
8283
getCollectionService(),

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.apache.commons.lang3.time.DateUtils;
2626

2727
import org.slf4j.Logger;
28-
import org.slf4j.LoggerFactory;
2928

3029
import org.springframework.scheduling.annotation.Scheduled;
3130
import org.springframework.transaction.annotation.Transactional;
@@ -43,8 +42,7 @@ public class CronServiceImpl implements CronService {
4342
private static final String EVERY_DAY_AT_00_00 = "0 0 0 * * *";
4443
private static final String EVERY_DAY_AT_00_30 = "0 30 0 * * *";
4544

46-
private static final Logger LOG = LoggerFactory.getLogger(CronServiceImpl.class);
47-
45+
private final Logger log;
4846
private final CategoryService categoryService;
4947
private final CountryService countryService;
5048
private final CollectionService collectionService;
@@ -122,12 +120,12 @@ public void purgeUsersActivations() {
122120
Validate.validState(expiredActivations != null, "Expired activations must be non null");
123121

124122
if (expiredActivations.isEmpty()) {
125-
LOG.info("Expired activations were not found.");
123+
log.info("Expired activations were not found.");
126124
return;
127125
}
128126

129127
for (UsersActivationFullDto activation : expiredActivations) {
130-
LOG.info(
128+
log.info(
131129
"Delete expired activation (key: {}, email: {}, created: {})",
132130
activation.getActivationKey(),
133131
activation.getEmail(),

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
package ru.mystamps.web.service
1919

20+
import org.slf4j.helpers.NOPLogger
21+
2022
import spock.lang.Specification
2123

2224
import ru.mystamps.web.dao.dto.UsersActivationFullDto
@@ -35,6 +37,7 @@ class CronServiceImplTest extends Specification {
3537
private final UsersActivationService usersActivationService = Mock()
3638

3739
private final CronService service = new CronServiceImpl(
40+
NOPLogger.NOP_LOGGER,
3841
categoryService,
3942
countryService,
4043
collectionService,

0 commit comments

Comments
 (0)