|
@@ -0,0 +1,53 @@
|
|
|
|
|
+package com.finikes.oc.vote.dao;
|
|
|
|
|
+
|
|
|
|
|
+import com.finikes.oc.App;
|
|
|
|
|
+import com.finikes.oc.vote.entity.Option;
|
|
|
|
|
+import org.junit.jupiter.api.MethodOrderer;
|
|
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
|
|
+import org.junit.jupiter.api.TestMethodOrder;
|
|
|
|
|
+import org.junit.runner.RunWith;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
+import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.UUID;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+import java.util.stream.IntStream;
|
|
|
|
|
+
|
|
|
|
|
+import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
|
+
|
|
|
|
|
+@RunWith(SpringRunner.class)
|
|
|
|
|
+@SpringBootTest(classes = App.class)
|
|
|
|
|
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
|
|
|
|
+class OptionDaoTest {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private OptionDao optionDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void deleteByVoteId() {
|
|
|
|
|
+ optionDao.deleteByVoteId(0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void bulkInsert() {
|
|
|
|
|
+ List<Option> options = new ArrayList<>();
|
|
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
|
|
+ Option option = new Option();
|
|
|
|
|
+ option.setVoteId(0);
|
|
|
|
|
+ option.setValue(UUID.randomUUID().toString());
|
|
|
|
|
+ options.add(option);
|
|
|
|
|
+ }
|
|
|
|
|
+ optionDao.bulkInsert(options);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void selectByVoteIds() {
|
|
|
|
|
+ List<Integer> integers = IntStream.range(0, 10)
|
|
|
|
|
+ .boxed()
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ optionDao.selectByVoteIds(integers);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|