Skip to content

Commit 4820226

Browse files
author
Jorgen-5
committed
Constructor injection
1 parent e77b6be commit 4820226

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

klass-api/src/main/java/no/ssb/klass/api/services/IndexServiceImpl.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,16 @@ public class IndexServiceImpl implements IndexService {
5959
private final ClassificationSeriesRepository classificationRepository;
6060
private final OpenSearchRestTemplate elasticsearchOperations;
6161
private final DocumentMapper documentMapper;
62-
63-
@Autowired
64-
@Lazy
65-
private IndexService indexService;
62+
private final IndexService indexService;
6663

6764
@Autowired
6865
public IndexServiceImpl(
6966
ClassificationSeriesRepository classificationRepository,
70-
OpenSearchRestTemplate elasticsearchOperations) {
67+
OpenSearchRestTemplate elasticsearchOperations, IndexService indexService) {
7168
this.classificationRepository = classificationRepository;
7269
this.elasticsearchOperations = elasticsearchOperations;
7370
this.documentMapper = new DocumentMapper();
71+
this.indexService = indexService;
7472
}
7573

7674
private IndexCoordinates getIndexCoordinates() {

klass-api/src/test/java/no/ssb/klass/api/applicationtest/config/IndexServiceTestConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public OpenSearchRestTemplate openSearchRestTemplate(org.opensearch.client.RestH
2020
@Primary
2121
public IndexService indexService(ClassificationSeriesRepository seriesRepository,
2222
OpenSearchRestTemplate openSearchRestTemplate) {
23-
return new IndexServiceImpl(seriesRepository, openSearchRestTemplate);
23+
return new IndexServiceImpl(seriesRepository, openSearchRestTemplate, null);
2424
}
2525
}

0 commit comments

Comments
 (0)