summaryrefslogtreecommitdiff
path: root/src/test/java/com/mesasoft/cn/dao
diff options
context:
space:
mode:
authorzhanghongqing <[email protected]>2022-08-09 16:54:16 +0800
committerzhanghongqing <[email protected]>2022-08-09 16:54:16 +0800
commitb3fa11d4b1b5a68d7b04fde5eb6cfbda557927eb (patch)
treea49d344e49fc427fbf4cf00aa4963c4d04cd98a4 /src/test/java/com/mesasoft/cn/dao
parentd8a2be0d094ac9ba2d47c81ebf03b3fe6e34a078 (diff)
initializeHEADmain
Diffstat (limited to 'src/test/java/com/mesasoft/cn/dao')
-rw-r--r--src/test/java/com/mesasoft/cn/dao/AuthDAOTest.java30
-rw-r--r--src/test/java/com/mesasoft/cn/dao/CategoryDAOTest.java48
-rw-r--r--src/test/java/com/mesasoft/cn/dao/DownloadedDAOTest.java30
-rw-r--r--src/test/java/com/mesasoft/cn/dao/FileDAOTest.java32
-rw-r--r--src/test/java/com/mesasoft/cn/dao/UserDAOTest.java63
-rw-r--r--src/test/java/com/mesasoft/cn/dao/sqlprovider/FileSqlProviderTest.java41
6 files changed, 244 insertions, 0 deletions
diff --git a/src/test/java/com/mesasoft/cn/dao/AuthDAOTest.java b/src/test/java/com/mesasoft/cn/dao/AuthDAOTest.java
new file mode 100644
index 0000000..c3eb364
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/dao/AuthDAOTest.java
@@ -0,0 +1,30 @@
+package com.mesasoft.cn.dao;
+
+import com.mesasoft.cn.SketchApplicationTest;
+import com.zhazhapan.util.Formatter;
+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.junit4.SpringRunner;
+
+/**
+ * @author pantao
+ * @since 2018/1/19
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class AuthDAOTest {
+
+ static {
+ SketchApplicationTest.setSettings();
+ }
+
+ @Autowired
+ private AuthDAO authDAO;
+
+ @Test
+ public void testGetAuthBy() {
+ System.out.println(Formatter.listToJson(authDAO.listAuthBy(0, 0, 0, "", 0)));
+ }
+}
diff --git a/src/test/java/com/mesasoft/cn/dao/CategoryDAOTest.java b/src/test/java/com/mesasoft/cn/dao/CategoryDAOTest.java
new file mode 100644
index 0000000..c389c5a
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/dao/CategoryDAOTest.java
@@ -0,0 +1,48 @@
+package com.mesasoft.cn.dao;
+
+import com.zhazhapan.util.Formatter;
+import com.zhazhapan.util.RandomUtils;
+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.junit4.SpringRunner;
+
+/**
+ * @author pantao
+ * @since 2018/1/18
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class CategoryDAOTest {
+
+ @Autowired
+ CategoryDAO categoryDAO;
+
+ @Test
+ public void testInsertCategory() {
+ for (int i = 0; i < 10; i++) {
+ categoryDAO.insertCategory(RandomUtils.getRandomStringOnlyLowerCase(6));
+ }
+ }
+
+ @Test
+ public void testRemoveCategoryById() {
+ categoryDAO.removeCategoryById(1);
+ }
+
+ @Test
+ public void testUpdateName() {
+ categoryDAO.updateNameById(3, "update");
+ }
+
+ @Test
+ public void testGetAllCategory() {
+ System.out.println(Formatter.listToJson(categoryDAO.listCategory()));
+ }
+
+ @Test
+ public void testGetCategoryById() {
+ System.out.println(categoryDAO.getCategoryById(6).toString());
+ }
+}
diff --git a/src/test/java/com/mesasoft/cn/dao/DownloadedDAOTest.java b/src/test/java/com/mesasoft/cn/dao/DownloadedDAOTest.java
new file mode 100644
index 0000000..df8ec44
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/dao/DownloadedDAOTest.java
@@ -0,0 +1,30 @@
+package com.mesasoft.cn.dao;
+
+import com.mesasoft.cn.SketchApplicationTest;
+import com.zhazhapan.modules.constant.ValueConsts;
+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.junit4.SpringRunner;
+
+/**
+ * @author pantao
+ * @since 2018/1/19
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class DownloadedDAOTest {
+
+ static {
+ SketchApplicationTest.setSettings();
+ }
+
+ @Autowired
+ DownloadedDAO downloadDAO;
+
+ @Test
+ public void testGetDownloadBy() {
+ System.out.println(downloadDAO.listDownloadedBy(1, 1, "", ValueConsts.ZERO_INT, 0));
+ }
+}
diff --git a/src/test/java/com/mesasoft/cn/dao/FileDAOTest.java b/src/test/java/com/mesasoft/cn/dao/FileDAOTest.java
new file mode 100644
index 0000000..d96328c
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/dao/FileDAOTest.java
@@ -0,0 +1,32 @@
+package com.mesasoft.cn.dao;
+
+import com.mesasoft.cn.SketchApplicationTest;
+import com.zhazhapan.util.Formatter;
+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.junit4.SpringRunner;
+
+/**
+ * @author pantao
+ * @since 2018/2/5
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class FileDAOTest {
+
+ @Autowired
+ FileDAO fileDAO;
+
+ @Test
+ public void testRemoveFile() {
+ assert fileDAO.removeById(3);
+ }
+
+ @Test
+ public void testGetUserDownloaded() {
+ SketchApplicationTest.setSettings();
+ System.out.println(Formatter.listToJson(fileDAO.listUserDownloaded(2, 0, "")));
+ }
+}
diff --git a/src/test/java/com/mesasoft/cn/dao/UserDAOTest.java b/src/test/java/com/mesasoft/cn/dao/UserDAOTest.java
new file mode 100644
index 0000000..214e325
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/dao/UserDAOTest.java
@@ -0,0 +1,63 @@
+package com.mesasoft.cn.dao;
+
+import com.mesasoft.cn.SketchApplicationTest;
+import com.mesasoft.cn.entity.User;
+import com.zhazhapan.util.Checker;
+import com.zhazhapan.util.Formatter;
+import com.zhazhapan.util.RandomUtils;
+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.junit4.SpringRunner;
+
+/**
+ * @author pantao
+ * @since 2018/1/18
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class UserDAOTest {
+
+ static {
+ SketchApplicationTest.setSettings();
+ }
+
+ @Autowired
+ private UserDAO userDAO;
+
+ @Test
+ public void testUpdateUserAuth() {
+ assert userDAO.updateAuthById(1, 1, 1, 1, 1, 1);
+ }
+
+ @Test
+ public void testUpdateUserLoginTime() {
+ assert userDAO.updateUserLoginTime(1);
+ }
+
+ @Test
+ public void testDoLogin() {
+ assert Checker.isNotNull(userDAO.login("system", "123456"));
+ }
+
+ @Test
+ public void testInsertUser() {
+ String username = RandomUtils.getRandomStringOnlyLowerCase(6);
+ String realName = RandomUtils.getRandomStringOnlyLowerCase(6);
+ String email = RandomUtils.getRandomEmail();
+ String password = RandomUtils.getRandomStringWithoutSymbol(16);
+ User user = new User(username, realName, email, password);
+ assert userDAO.insertUser(user);
+ }
+
+ @Test
+ public void testGetAllUser() {
+ System.out.println(Formatter.listToJson(userDAO.listUserBy(3, "", 0)));
+ }
+
+ @Test
+ public void testGetUser() {
+ System.out.println(userDAO.getUserById(1).toString());
+ }
+}
diff --git a/src/test/java/com/mesasoft/cn/dao/sqlprovider/FileSqlProviderTest.java b/src/test/java/com/mesasoft/cn/dao/sqlprovider/FileSqlProviderTest.java
new file mode 100644
index 0000000..1d1d201
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/dao/sqlprovider/FileSqlProviderTest.java
@@ -0,0 +1,41 @@
+package com.mesasoft.cn.dao.sqlprovider;
+
+import com.mesasoft.cn.SketchApplicationTest;
+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.junit4.SpringRunner;
+
+/**
+ * @author pantao
+ * @since 2018/2/6
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class FileSqlProviderTest {
+
+ @Autowired
+ FileSqlProvider fileSqlProvider;
+
+ @Test
+ public void updateAuthById() {
+ System.out.println(fileSqlProvider.updateAuthById());
+ }
+
+ @Test
+ public void getAll() {
+ SketchApplicationTest.setSettings();
+ System.out.println(fileSqlProvider.getAll(0, 0, "", ""));
+ }
+
+ @Test
+ public void getUserUploaded() {
+ System.out.println(fileSqlProvider.getUserUploaded(0, ""));
+ }
+
+ @Test
+ public void getUserDownloaded() {
+ System.out.println(fileSqlProvider.getUserDownloaded(0, ""));
+ }
+}