mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
test: 优化一些测试。
This commit is contained in:
parent
3e23a68b6c
commit
d3135c2d6b
@ -79,6 +79,15 @@ public class UpdateChainTest implements WithAssertions {
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAll() {
|
||||
assertThatThrownBy(() -> {
|
||||
UpdateChain.of(accountMapper)
|
||||
.set(Account::getAge, 11)
|
||||
.update();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
public void testUpdateChain() {
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
|
||||
package com.mybatisflex.test.alisa;
|
||||
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
|
||||
/**
|
||||
@ -27,6 +29,7 @@ import com.mybatisflex.annotation.Table;
|
||||
@Table("sys_dept")
|
||||
public class SysDept extends BaseEntity {
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Integer id;
|
||||
private String deptName;
|
||||
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
|
||||
package com.mybatisflex.test.alisa;
|
||||
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
|
||||
/**
|
||||
@ -27,6 +29,7 @@ import com.mybatisflex.annotation.Table;
|
||||
@Table("sys_role")
|
||||
public class SysRole extends BaseEntity {
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Integer id;
|
||||
private String roleKey;
|
||||
private String roleName;
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
package com.mybatisflex.test.alisa;
|
||||
|
||||
import com.mybatisflex.annotation.ColumnAlias;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
|
||||
import java.util.Date;
|
||||
@ -31,6 +33,7 @@ import java.util.List;
|
||||
@Table("sys_user")
|
||||
public class SysUser extends BaseEntity {
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Integer id;
|
||||
private String userName;
|
||||
@ColumnAlias("user_age")
|
||||
|
||||
@ -18,6 +18,8 @@ package com.mybatisflex.test.model;
|
||||
|
||||
import com.mybatisflex.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 王帅
|
||||
* @since 2023-06-07
|
||||
@ -28,7 +30,7 @@ public class UserVO3 {
|
||||
@Id
|
||||
private String userId;
|
||||
private String userName;
|
||||
private RoleVO3 roleVO3;
|
||||
private List<RoleVO3> roleVO3;
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
@ -46,11 +48,11 @@ public class UserVO3 {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public RoleVO3 getRoleVO3() {
|
||||
public List<RoleVO3> getRoleVO3() {
|
||||
return roleVO3;
|
||||
}
|
||||
|
||||
public void setRoleVO3(RoleVO3 roleVO3) {
|
||||
public void setRoleVO3(List<RoleVO3> roleVO3) {
|
||||
this.roleVO3 = roleVO3;
|
||||
}
|
||||
|
||||
|
||||
@ -166,4 +166,11 @@ class AlisaTest {
|
||||
Assertions.assertEquals(userList1, userList2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void test08() throws JsonProcessingException {
|
||||
SysUser user = userMapper.selectOneById(1);
|
||||
ObjectWriter objectWriter = objectMapper.writerWithDefaultPrettyPrinter();
|
||||
System.out.println(objectWriter.writeValueAsString(user));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -60,11 +60,11 @@ class UserMapperTest {
|
||||
.from(USER.as("u"))
|
||||
.leftJoin(USER_ROLE).as("ur").on(USER_ROLE.USER_ID.eq(USER.USER_ID))
|
||||
.leftJoin(ROLE).as("r").on(USER_ROLE.ROLE_ID.eq(ROLE.ROLE_ID))
|
||||
.where(USER.USER_ID.eq(1));
|
||||
.where(USER.USER_ID.eq(3));
|
||||
System.out.println(queryWrapper.toSQL());
|
||||
// UserVO userVO = userMapper.selectOneByQueryAs(queryWrapper, UserVO.class);
|
||||
// UserVO1 userVO = userMapper.selectOneByQueryAs(queryWrapper, UserVO1.class);
|
||||
// UserVO2 userVO = userMapper.selectOneByQueryAs(queryWrapper, UserVO2.class);
|
||||
// UserVO userVO = userMapper.selectOneByQueryAs(queryWrapper, UserVO.class);
|
||||
// UserVO1 userVO = userMapper.selectOneByQueryAs(queryWrapper, UserVO1.class);
|
||||
// UserVO2 userVO = userMapper.selectOneByQueryAs(queryWrapper, UserVO2.class);
|
||||
UserVO3 userVO = userMapper.selectOneByQueryAs(queryWrapper, UserVO3.class);
|
||||
System.err.println(userVO);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user