blob: 214e325ff7657cbc7b4b3da6bb9291e6d2ac059a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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());
}
}
|