|
|
@@ -0,0 +1,32 @@
|
|
|
+package com.zksy.video;
|
|
|
+
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+import org.mybatis.spring.annotation.MapperScan;
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
+import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
+
|
|
|
+/**
|
|
|
+ * The video module registers its two mappers with @Mapper, so a package-wide MapperScan is both
|
|
|
+ * unnecessary and harmful: it also turns ordinary interfaces (VideoLifecycleStore) into mapper
|
|
|
+ * beans, which makes VideoLifecycleService ambiguous and prevents the service from starting.
|
|
|
+ */
|
|
|
+class VideoApplicationWiringTest {
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void mapperScanDoesNotSweepTheWholeVideoPackage() {
|
|
|
+ MapperScan scan = VideoApplication.class.getAnnotation(MapperScan.class);
|
|
|
+ assertTrue(scan != null, "VideoApplication must declare its mapper scan explicitly");
|
|
|
+ assertFalse(Arrays.asList(scan.basePackages()).contains("com.zksy.video"),
|
|
|
+ "com.zksy.video must not be scanned for mappers: it holds ordinary interfaces such as VideoLifecycleStore");
|
|
|
+ assertTrue(Arrays.asList(scan.basePackages()).contains("com.ruoyi.wvp.mapper"),
|
|
|
+ "the wvp mappers still need the package scan");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void bothVideoMappersDeclareThemselvesSoThePackageScanIsNotNeeded() {
|
|
|
+ assertTrue(RegisteredVideoMapper.class.isAnnotationPresent(org.apache.ibatis.annotations.Mapper.class));
|
|
|
+ assertTrue(VideoEquipmentStatusMapper.class.isAnnotationPresent(org.apache.ibatis.annotations.Mapper.class));
|
|
|
+ }
|
|
|
+}
|