package com.taoke.autopay.dao;
|
|
import com.taoke.autopay.entity.ClientAdditionalInfo;
|
import org.junit.jupiter.api.Test;
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
|
/**
|
* @author
|
* @title: ClientAdditionalInfoMapperTest
|
* @description: ClientAdditionalInfoMapper单元测试
|
* @date 2024/6/14 18:09
|
*/
|
@SpringBootTest
|
public class ClientAdditionalInfoMapperTest {
|
|
@Resource
|
private ClientAdditionalInfoMapper clientAdditionalInfoMapper;
|
|
@Test
|
public void testInsert() {
|
ClientAdditionalInfo info = ClientAdditionalInfo.builder()
|
.id(System.currentTimeMillis()) // 使用当前时间戳作为ID
|
.mobile("13800138000")
|
.alipayAccount("alipay@example.com")
|
.alipayPassword("password123")
|
.createTime(new Date())
|
.updateTime(new Date())
|
.build();
|
|
int result = clientAdditionalInfoMapper.insert(info);
|
System.out.println("插入结果: " + result);
|
}
|
|
@Test
|
public void testSelectByPrimaryKey() {
|
// 先插入一条测试数据
|
long id = System.currentTimeMillis();
|
ClientAdditionalInfo info = ClientAdditionalInfo.builder()
|
.id(id)
|
.mobile("13900139000")
|
.alipayAccount("alipay2@example.com")
|
.alipayPassword("password456")
|
.createTime(new Date())
|
.updateTime(new Date())
|
.build();
|
|
clientAdditionalInfoMapper.insert(info);
|
|
// 查询刚刚插入的数据
|
ClientAdditionalInfo result = clientAdditionalInfoMapper.selectByPrimaryKey(id);
|
System.out.println("查询结果: " + result);
|
}
|
|
@Test
|
public void testUpdateByPrimaryKey() {
|
// 先插入一条测试数据
|
long id = System.currentTimeMillis();
|
ClientAdditionalInfo info = ClientAdditionalInfo.builder()
|
.id(id)
|
.mobile("13700137000")
|
.alipayAccount("alipay3@example.com")
|
.alipayPassword("password789")
|
.createTime(new Date())
|
.updateTime(new Date())
|
.build();
|
|
clientAdditionalInfoMapper.insert(info);
|
|
// 更新数据
|
ClientAdditionalInfo updateInfo = ClientAdditionalInfo.builder()
|
.id(id)
|
.mobile("13600136000")
|
.alipayAccount("alipay4@example.com")
|
.alipayPassword("newpassword123")
|
.createTime(info.getCreateTime())
|
.updateTime(new Date())
|
.build();
|
|
int result = clientAdditionalInfoMapper.updateByPrimaryKey(updateInfo);
|
System.out.println("更新结果: " + result);
|
|
// 查询更新后的数据
|
ClientAdditionalInfo resultInfo = clientAdditionalInfoMapper.selectByPrimaryKey(id);
|
System.out.println("更新后数据: " + resultInfo);
|
}
|
|
@Test
|
public void testDeleteByPrimaryKey() {
|
// 先插入一条测试数据
|
long id = System.currentTimeMillis();
|
ClientAdditionalInfo info = ClientAdditionalInfo.builder()
|
.id(id)
|
.mobile("13500135000")
|
.alipayAccount("alipay5@example.com")
|
.alipayPassword("password999")
|
.createTime(new Date())
|
.updateTime(new Date())
|
.build();
|
|
clientAdditionalInfoMapper.insert(info);
|
|
// 删除数据
|
int result = clientAdditionalInfoMapper.deleteByPrimaryKey(id);
|
System.out.println("删除结果: " + result);
|
}
|
}
|