|
|
@@ -1,124 +0,0 @@
|
|
|
-package cn.reghao.tnb.content.app.vod.service;
|
|
|
-
|
|
|
-import cn.reghao.jutil.jdk.io.TextFile;
|
|
|
-import cn.reghao.tnb.content.app.data.service.CommentService;
|
|
|
-import cn.reghao.tnb.content.app.vod.db.mapper.VideoPostMapper;
|
|
|
-import cn.reghao.tnb.content.app.vod.db.mongo.UserCommentMongo;
|
|
|
-import org.junit.Test;
|
|
|
-import org.junit.runner.RunWith;
|
|
|
-import org.mockito.InjectMocks;
|
|
|
-import org.mockito.Mock;
|
|
|
-import org.mockito.Mockito;
|
|
|
-import org.mockito.junit.MockitoJUnitRunner;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashSet;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author reghao
|
|
|
- * @date 2025-05-29 09:16:31
|
|
|
- */
|
|
|
-@RunWith(MockitoJUnitRunner.class)
|
|
|
-public class UnitTest {
|
|
|
- @Mock
|
|
|
- private UserCommentMongo userCommentMongo;
|
|
|
- //@Mock
|
|
|
- private VideoPostMapper videoPostMapper;
|
|
|
- @InjectMocks
|
|
|
- CommentService commentService;
|
|
|
-
|
|
|
- @Test
|
|
|
- public void unitTest() {
|
|
|
- String videoId = "abcdefg";
|
|
|
- Mockito.when(userCommentMongo.countByPostId(videoId)).thenReturn(1024L);
|
|
|
- long total = commentService.countPostComment(videoId);
|
|
|
- System.out.println();
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void vodTest() {
|
|
|
- TextFile textFile = new TextFile();
|
|
|
-
|
|
|
- String filePath = "/home/reghao/Downloads/1_fyt91.txt";
|
|
|
- List<String> existList = new ArrayList<>();
|
|
|
- List<String> notexistList = new ArrayList<>();
|
|
|
- List<String> list = new ArrayList<>();
|
|
|
- for (String line : textFile.read(filePath)) {
|
|
|
- if (line.startsWith("exist")) {
|
|
|
- existList.add(line);
|
|
|
-
|
|
|
- /*String videoIdsStr = line.split(" videoId ")[1];
|
|
|
- String[] videoIds = videoIdsStr.replace("[", "")
|
|
|
- .replace("]", "")
|
|
|
- .split(", ");
|
|
|
-
|
|
|
- for (String videoId : videoIds) {
|
|
|
- VideoPost videoPost = videoPostMapper.findByVideoId(videoId);
|
|
|
- long publishBy = videoPost.getPublishBy();
|
|
|
- }*/
|
|
|
- } else if (line.startsWith("notexist")) {
|
|
|
- notexistList.add(line);
|
|
|
- } else {
|
|
|
- list.add(line);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- textFile.write("/home/reghao/Downloads/1_fyt91.txt_exist", existList);
|
|
|
- textFile.write("/home/reghao/Downloads/1_fyt91.txt_notexist", notexistList);
|
|
|
- textFile.write("/home/reghao/Downloads/1_fyt91.txt_list", list);
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void vodTest1() {
|
|
|
- TextFile textFile = new TextFile();
|
|
|
-
|
|
|
- String filePath = "/home/reghao/Downloads/3.txt";
|
|
|
- String text = textFile.readFile(filePath);
|
|
|
- String[] tags = text.replace("[", "")
|
|
|
- .replace("]", "")
|
|
|
- .split(", ");
|
|
|
-
|
|
|
- Set<String> set1 = new HashSet<>();
|
|
|
- Set<String> set2 = new HashSet<>();
|
|
|
- String regex = "^[a-z0-9A-Z]+$";
|
|
|
- for (String tag : tags) {
|
|
|
- if (tag.equals("tnb")) {
|
|
|
- set2.add(tag);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- if (tag.matches(regex)) {
|
|
|
- set1.add(tag);
|
|
|
- } else {
|
|
|
- set2.add(tag);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- System.out.println();
|
|
|
- }
|
|
|
-
|
|
|
- private void test1() {
|
|
|
- TextFile textFile = new TextFile();
|
|
|
-
|
|
|
- String filePath = "/home/reghao/Downloads/1_fyt91.txt_notexist";
|
|
|
- List<String> existList = new ArrayList<>();
|
|
|
- List<String> notexistList = new ArrayList<>();
|
|
|
- List<String> list = new ArrayList<>();
|
|
|
-
|
|
|
- Set<String> set = new HashSet<>();
|
|
|
- for (String line : textFile.read(filePath)) {
|
|
|
- String line1 = line.replace("notexist ", "");
|
|
|
- set.add(line1);
|
|
|
- }
|
|
|
-
|
|
|
- filePath = "/home/reghao/Downloads/1_fytgc.txt_notexist";
|
|
|
- for (String line : textFile.read(filePath)) {
|
|
|
- String line1 = line.replace("notexist ", "");
|
|
|
- if (set.contains(line1)) {
|
|
|
- System.out.println(line);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|