|
|
@@ -0,0 +1,57 @@
|
|
|
+package com.sckw.system.model;
|
|
|
+
|
|
|
+import com.sckw.system.model.vo.res.AppMenuPermItemResVo;
|
|
|
+import org.junit.Test;
|
|
|
+
|
|
|
+import java.net.URL;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Paths;
|
|
|
+
|
|
|
+import static org.junit.Assert.assertEquals;
|
|
|
+import static org.junit.Assert.assertNotNull;
|
|
|
+import static org.junit.Assert.assertTrue;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 菜单未选中图标字段映射测试。
|
|
|
+ */
|
|
|
+public class KwsMenuFieldMappingTest {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证新增字段可在菜单实体和返回对象中正常读写。
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void shouldReadAndWriteNotSelectedIconPath() {
|
|
|
+ String notSelectedIconPath = "/static/menu/home-unselected.png";
|
|
|
+
|
|
|
+ KwsMenu kwsMenu = new KwsMenu();
|
|
|
+ kwsMenu.setNotSelectedIconPath(notSelectedIconPath);
|
|
|
+
|
|
|
+ AppMenuPermItemResVo resVo = new AppMenuPermItemResVo();
|
|
|
+ resVo.setNotSelectedIconPath(kwsMenu.getNotSelectedIconPath());
|
|
|
+
|
|
|
+ assertEquals(notSelectedIconPath, kwsMenu.getNotSelectedIconPath());
|
|
|
+ assertEquals(notSelectedIconPath, resVo.getNotSelectedIconPath());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证新增字段已配置到 MyBatis 新增、更新和查询映射中。
|
|
|
+ *
|
|
|
+ * @throws Exception 读取 XML 资源失败时抛出异常
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void shouldContainNotSelectedIconPathSqlMapping() throws Exception {
|
|
|
+ URL mapperUrl = Thread.currentThread()
|
|
|
+ .getContextClassLoader()
|
|
|
+ .getResource("mapper/KwsMenuDao.xml");
|
|
|
+ assertNotNull(mapperUrl);
|
|
|
+
|
|
|
+ String xml = Files.readString(Paths.get(mapperUrl.toURI()), StandardCharsets.UTF_8);
|
|
|
+
|
|
|
+ assertTrue(xml.contains("property=\"notSelectedIconPath\""));
|
|
|
+ assertTrue(xml.contains("sm.not_selected_icon_path"));
|
|
|
+ assertTrue(xml.contains("not_selected_icon_path,"));
|
|
|
+ assertTrue(xml.contains("#{notSelectedIconPath,jdbcType=VARCHAR}"));
|
|
|
+ assertTrue(xml.contains("not_selected_icon_path = #{notSelectedIconPath,jdbcType=VARCHAR}"));
|
|
|
+ }
|
|
|
+}
|