| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import cn.reghao.dfs.store.DfsStoreApplication;
- import cn.reghao.dfs.store.db.mapper.*;
- import cn.reghao.dfs.store.model.po.*;
- import lombok.extern.slf4j.Slf4j;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.test.context.SpringBootTest;
- import org.springframework.test.context.ActiveProfiles;
- import org.springframework.test.context.junit4.SpringRunner;
- import java.util.List;
- /**
- * @author reghao
- * @date 2023-03-22 16:19:12
- */
- @Slf4j
- @ActiveProfiles("dev")
- @SpringBootTest(classes = DfsStoreApplication.class)
- @RunWith(SpringRunner.class)
- public class MediaFileTest {
- @Autowired
- VideoFileMapper videoFileMapper;
- @Autowired
- VideoUrlMapper videoUrlMapper;
- @Autowired
- FileMetaMapper fileMetaMapper;
- public void mediaTest() {
- videoUrlTest();
- log.info("------------------------------------------------------------");
- imageFileTest();
- }
- @Test
- public void videoUrlTest() {
- List<VideoUrl> list = videoUrlMapper.findAll();
- for (VideoUrl videoUrl : list) {
- process(videoUrl);
- }
- }
- private void process(VideoUrl videoUrl) {
- String videoFileId = videoUrl.getVideoFileId();
- VideoFile videoFile = videoFileMapper.findByVideoFileId(videoFileId);
- if (videoFile == null) {
- log.error("videoFileId {} not exist in video_file", videoFileId);
- return;
- }
- String objectId = videoUrl.getObjectId();
- FileMeta fileMeta = fileMetaMapper.findByObjectId(objectId);
- if (fileMeta == null) {
- log.error("objectId {} not exist in file_meta", objectId);
- }
- }
- @Autowired
- ImageFileMapper imageFileMapper;
- @Test
- public void imageFileTest() {
- List<ImageFile> list = imageFileMapper.findAll();
- for (ImageFile imageFile : list) {
- process(imageFile);
- }
- }
- private void process(ImageFile imageFile) {
- String jpegObjectId = imageFile.getJpegObjectId();
- FileMeta fileMeta = fileMetaMapper.findByObjectId(jpegObjectId);
- if (fileMeta == null) {
- log.error("jpegObjectId {} not exist in file_meta", jpegObjectId);
- }
- String webpObjectId = imageFile.getWebpObjectId();
- if (webpObjectId != null) {
- FileMeta fileMeta1 = fileMetaMapper.findByObjectId(webpObjectId);
- if (fileMeta1 == null) {
- log.error("webpObjectId {} not exist in file_meta", webpObjectId);
- }
- }
- }
- @Test
- public void test11() {
- int scope = 4;
- List<String> list = List.of("eadf4146d67846f7abdf8ce63e354440", "98d20cf30c27417c8e5bcdb83e18562b");
- fileMetaMapper.updateScopeByObjectIds(scope, list);
- }
- }
|