일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- aggregation
- ELASTIC
- API
- query
- token filter test
- zip 암호화
- Kafka
- springboot
- sort
- Elasticsearch
- high level client
- licence delete curl
- Mac
- license delete
- flask
- 파이썬
- matplotlib
- 900gle
- Test
- MySQL
- plugin
- License
- Java
- docker
- aggs
- zip 파일 암호화
- 차트
- TensorFlow
- analyzer test
- Python
Archives
- Today
- Total
개발잡부
[test] keywords Service TEST Code 본문
반응형
package com.bbongdoo.doo.keyword;
import com.bbongdoo.doo.domain.Keywords;
import com.bbongdoo.doo.domain.KeywordsRepository;
import com.bbongdoo.doo.service.KeywordsService;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.LongStream;
@SpringBootTest
@Transactional
public class KeywordServiceTest {
@Autowired
private KeywordsService keywordsService;
@Autowired
private KeywordsRepository keywordsRepository;
private int count = 10;
List<Keywords> keywords;
List<String> names;
@BeforeEach
void setUp() {
keywords = LongStream.range(1, count + 1)
.mapToObj(number -> new Keywords("에르디아" + number, "Y"))
.collect(Collectors.toList());
names = keywords.stream()
.map(Keywords::getKeyword)
.collect(Collectors.toList());
System.out.println("---------------insert---------------");
keywordsRepository.saveAll(keywords);
}
@Test
void findAllTest() {
System.out.println("---------------findAll---------------");
List<Keywords> keywords = keywordsService.get();
Assertions.assertThat(keywords.size()).isEqualTo(count);
}
@Test
void findAllByUseTest() {
System.out.println("---------------findAllByUse---------------");
List<Keywords> keywordsByUse = keywordsService.getKeywordsByUse("Y");
Assertions.assertThat(keywordsByUse.size()).isEqualTo(count);
}
@Test
void findAllByKeywordTest() {
System.out.println("---------------findAllByKeyword---------------");
List<Keywords> keywordsByKeyword = keywordsService.getKeywordsByKeyword("에르디아1");
Assertions.assertThat(keywordsByKeyword.size()).isGreaterThan(0);
}
}
반응형
'JAVA > test code' 카테고리의 다른 글
[TEST]ReflectionTestUtils (0) | 2023.03.14 |
---|
Comments