【8.3.0】【scanner】【test】测试为空对象的解析

master
stylefeng 2024-08-07 14:57:58 +08:00
parent 581ee10805
commit cac851f055
3 changed files with 56 additions and 57 deletions

View File

@ -0,0 +1,42 @@
package cn.stylefeng.roses.kernel.scanner.api;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.util.IdUtil;
import cn.stylefeng.roses.kernel.scanner.api.factory.ClassMetaFactory;
import cn.stylefeng.roses.kernel.scanner.api.pojo.EmptyObject;
import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.FieldMetadata;
import cn.stylefeng.roses.kernel.scanner.api.util.AdvancedClassTypeUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONWriter;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.lang.reflect.Type;
/**
*
*
* @author fengshuonan
* @since 2024/8/7 14:57
*/
public class TestEmptyObject {
@BeforeEach
public void setUp() {
AdvancedClassTypeUtil.TEMP_SCAN_PACKAGE_LIST = ListUtil.of("cn.stylefeng");
}
@Test
public void testEmptyObj() {
Type type = new TypeReference<EmptyObject>() {
}.getType();
FieldMetadata fieldMetadata = ClassMetaFactory.beginCreateFieldMetadata(type, IdUtil.fastSimpleUUID());
String jsonString = JSON.toJSONString(fieldMetadata, JSONWriter.Feature.PrettyFormat);
System.out.println(jsonString);
}
}

View File

@ -0,0 +1,14 @@
package cn.stylefeng.roses.kernel.scanner.api.pojo;
import lombok.Data;
/**
*
*
* @author fengshuonan
* @since 2024/8/7 14:56
*/
@Data
public class EmptyObject {
}

View File

@ -1,57 +0,0 @@
package cn.stylefeng.roses.kernel.scanner.api.pojo;
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.List;
/**
*
*
* @author fengshuonan
* @since 2024/8/5 10:32
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class MyRequest extends BaseRequest {
/**
* id
*/
@ChineseDescription("用户id")
@NotNull(message = "用户id不能为空", groups = add.class)
private Long userId;
/**
*
*/
@ChineseDescription("用户名")
@NotEmpty(message = "用户名不能为空", groups = add.class)
private String userName;
/**
*
*/
@ChineseDescription("年龄")
@NotNull(message = "年龄不能为空", groups = edit.class)
private Integer age;
/**
*
*/
@ChineseDescription("用户分数")
@NotNull(message = "用户分数不能为空", groups = edit.class)
private BigDecimal userScore;
/**
*
*/
@ChineseDescription("列表")
@NotEmpty(message = "列表不能为空", groups = {add.class, edit.class})
private List<String> mySimpleList;
}