-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test: toCsvLineString 테스트 추가 * test: writeStocks 테스트 추가 * fix: csv 구부낮 콜론으로 변경 * feat: reloadStocks 위임하는 방식으로 변경
- Loading branch information
1 parent
af3d2b9
commit 4ffd6c9
Showing
5 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/test/java/codesquad/fineants/domain/stock/domain/entity/StockTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package codesquad.fineants.domain.stock.domain.entity; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class StockTest { | ||
|
||
@DisplayName("csv에 저장하기 위해서 쉼표(,)로 구분한 한줄의 문자열로 변환한다") | ||
@Test | ||
void toCsvLineString() { | ||
// given | ||
Stock stock = Stock.of("000370", "한화손해보험보통주", "Hanwha General Insurance Co.,Ltd.", "KR7000370007", "보험", | ||
Market.KOSPI); | ||
// when | ||
String result = stock.toCsvLineString(); | ||
// then | ||
String expected = "KR7000370007:000370:한화손해보험보통주:Hanwha General Insurance Co.,Ltd.:KOSPI:보험"; | ||
Assertions.assertThat(result).isEqualTo(expected); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/test/java/codesquad/fineants/infra/s3/service/AmazonS3StockServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package codesquad.fineants.infra.s3.service; | ||
|
||
import java.util.List; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import codesquad.fineants.AbstractContainerBaseTest; | ||
import codesquad.fineants.domain.stock.domain.entity.Market; | ||
import codesquad.fineants.domain.stock.domain.entity.Stock; | ||
|
||
class AmazonS3StockServiceTest extends AbstractContainerBaseTest { | ||
|
||
@Autowired | ||
private AmazonS3StockService amazonS3StockService; | ||
|
||
@DisplayName("종목 정보를 csv 파일에 저장한다") | ||
@Test | ||
void writeStocks() { | ||
// given | ||
Stock stock = Stock.of("000370", "한화손해보험보통주", "Hanwha General Insurance Co.,Ltd.", "KR7000370007", "보험", | ||
Market.KOSPI); | ||
// when | ||
amazonS3StockService.writeStocks(List.of(stock)); | ||
// then | ||
Stock findStock = amazonS3StockService.fetchStocks().stream() | ||
.findAny() | ||
.orElseThrow(); | ||
Assertions.assertThat(findStock) | ||
.extracting(Stock::getTickerSymbol, Stock::getCompanyName, Stock::getCompanyNameEng, Stock::getStockCode, | ||
Stock::getSector, Stock::getMarket) | ||
.containsExactly("000370", "한화손해보험보통주", "Hanwha General Insurance Co.,Ltd.", "KR7000370007", "보험", | ||
Market.KOSPI); | ||
} | ||
} |