Skip to content

Commit

Permalink
test: Modify quantityTest() to check DB (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
nusuy committed Sep 27, 2023
1 parent 69aa439 commit 8c4301f
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.cubix.extsearchbatch;

import com.cubix.extsearchbatch.dto.NaverRawNewsItemDto;
import com.cubix.extsearchbatch.entity.NewsRepository;
import com.cubix.extsearchbatch.service.DataUpdateService;
import com.cubix.extsearchbatch.util.data.NewsDataReader;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -18,25 +20,29 @@
@DisplayName("ext-search-batch Test")
@SpringBootTest
public class BatchTest {
private final DataUpdateService dataUpdateService;
private final NewsRepository newsRepository;
private final NewsDataReader newsDataReader;
final int DISPLAY_DEF = 100;

@Autowired
public BatchTest(NewsDataReader newsDataReader) {
public BatchTest(DataUpdateService dataUpdateService, NewsRepository newsRepository, NewsDataReader newsDataReader) {
this.dataUpdateService = dataUpdateService;
this.newsRepository = newsRepository;
this.newsDataReader = newsDataReader;
}

@Test
@DisplayName("적재 데이터량 테스트")
public void quantityTest() {
// given
long expectedSize = 100;
long expectedSize = 1000;

// when
ArrayList<NaverRawNewsItemDto> items = newsDataReader.get(DISPLAY_DEF, 1).getItems();
dataUpdateService.updateNewsData();

// then
long size = items.size();
long size = newsRepository.count();
assertThat(size).as("[Test Failed: 1,000 건 적재 실패] - actual: " + size).isEqualTo(expectedSize);
}

Expand Down

0 comments on commit 8c4301f

Please sign in to comment.