Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Labels.excludes预期效果不对 #1856

@myoss

Description

@myoss
org.junit.ComparisonFailure: 
Expected :{"id":123,"info":"fofo","name":"wenshao"}
Actual   :{"info":"fofo"}

想排除掉 “AuditIdEntity” 的字段,但是直接吧 “LogicDeleteEntity” 的字段也排除掉了,我的用法不对吗?测试代码如下

 @Test
    public void test_excludes() throws Exception {
        VO vo = new VO();
        vo.setId(123);
        vo.setName("wenshao");
        vo.setPassword("ooxxx");
        vo.setInfo("fofo");

        String text = JSON.toJSONString(vo, Labels.excludes("AuditIdEntity"));
        Assert.assertEquals("{\"id\":123,\"info\":\"fofo\",\"name\":\"wenshao\"}", text);
    }

    public static class VO {

        private int    id;
        private String name;
        private String password;
        private String info;

        @JSONField(label = "LogicDeleteEntity")
        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        @JSONField(label = "LogicDeleteEntity")
        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        @JSONField(label = "AuditIdEntity")
        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public String getInfo() {
            return info;
        }

        public void setInfo(String info) {
            this.info = info;
        }

    }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions