Skip to content

Commit 5a4d48e

Browse files
committed
StampsCatalogServiceImpl: use NOPLogger for unit tests to reduce output to console.
No functional changes.
1 parent 3ea17c3 commit 5a4d48e

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,38 @@ public UserService getUserService() {
174174

175175
@Bean
176176
public StampsCatalogService getMichelCatalogService() {
177-
return new StampsCatalogServiceImpl("Michel", daoConfig.getMichelCatalogDao());
177+
return new StampsCatalogServiceImpl(
178+
LoggerFactory.getLogger(StampsCatalogServiceImpl.class),
179+
"Michel",
180+
daoConfig.getMichelCatalogDao()
181+
);
178182
}
179183

180184
@Bean
181185
public StampsCatalogService getScottCatalogService() {
182-
return new StampsCatalogServiceImpl("Scott", daoConfig.getScottCatalogDao());
186+
return new StampsCatalogServiceImpl(
187+
LoggerFactory.getLogger(StampsCatalogServiceImpl.class),
188+
"Scott",
189+
daoConfig.getScottCatalogDao()
190+
);
183191
}
184192

185193
@Bean
186194
public StampsCatalogService getYvertCatalogService() {
187-
return new StampsCatalogServiceImpl("Yvert", daoConfig.getYvertCatalogDao());
195+
return new StampsCatalogServiceImpl(
196+
LoggerFactory.getLogger(StampsCatalogServiceImpl.class),
197+
"Yvert",
198+
daoConfig.getYvertCatalogDao()
199+
);
188200
}
189201

190202
@Bean
191203
public StampsCatalogService getGibbonsCatalogService() {
192-
return new StampsCatalogServiceImpl("Gibbons", daoConfig.getGibbonsCatalogDao());
204+
return new StampsCatalogServiceImpl(
205+
LoggerFactory.getLogger(StampsCatalogServiceImpl.class),
206+
"Gibbons",
207+
daoConfig.getGibbonsCatalogDao()
208+
);
193209
}
194210

195211
@Bean

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

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

2525
import org.slf4j.Logger;
26-
import org.slf4j.LoggerFactory;
2726

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

@@ -36,8 +35,8 @@
3635

3736
@RequiredArgsConstructor
3837
public class StampsCatalogServiceImpl implements StampsCatalogService {
39-
private static final Logger LOG = LoggerFactory.getLogger(StampsCatalogServiceImpl.class);
4038

39+
private final Logger log;
4140
private final String catalogName;
4241
private final StampsCatalogDao stampsCatalogDao;
4342

@@ -51,7 +50,7 @@ public void add(Set<String> catalogNumbers) {
5150
List<String> insertedNumbers = stampsCatalogDao.add(catalogNumbers);
5251

5352
if (!insertedNumbers.isEmpty()) {
54-
LOG.info("{} numbers {} were created", catalogName, insertedNumbers);
53+
log.info("{} numbers {} were created", catalogName, insertedNumbers);
5554
}
5655
}
5756

@@ -65,7 +64,7 @@ public void addToSeries(Integer seriesId, Set<String> catalogNumbers) {
6564

6665
stampsCatalogDao.addToSeries(seriesId, catalogNumbers);
6766

68-
LOG.info("Series #{}: {} numbers {} were added", seriesId, catalogName, catalogNumbers);
67+
log.info("Series #{}: {} numbers {} were added", seriesId, catalogName, catalogNumbers);
6968
}
7069

7170
@Override

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

Lines changed: 7 additions & 1 deletion
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.StampsCatalogDao
@@ -26,7 +28,11 @@ class StampsCatalogServiceImplTest extends Specification {
2628

2729
private final StampsCatalogDao stampsCatalogDao = Mock()
2830

29-
private final StampsCatalogService service = new StampsCatalogServiceImpl('TestCatalog', stampsCatalogDao)
31+
private final StampsCatalogService service = new StampsCatalogServiceImpl(
32+
NOPLogger.NOP_LOGGER,
33+
'TestCatalog',
34+
stampsCatalogDao
35+
)
3036

3137
//
3238
// Tests for add()

0 commit comments

Comments
 (0)