package com.alibaba.json.bvt.serializer.filters;

import org.junit.Assert;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.ValueFilter;

import junit.framework.TestCase;

public class MTopFilterTest extends TestCase {

    public void test_0() throws Exception {
        Model model = new Model();
        model.id = 1001;
        model.user = new Person();
        model.user.id = 2002;

        ValueFilter valueFilter = new ValueFilter() {

            @Override
            public Object process(Object object, String name, Object value) {
                System.out.printf("%s_%s\n", name, value);
                return value;
            }
        };

        String jsonString = JSON.toJSONString(model, valueFilter);
        Assert.assertEquals("{\"id\":1001,\"user\":{\"id\":2002}}", jsonString);
    }

    public static class Model {

        private int    id;
        private Person user;

        public int getId() {
            return id;
        }

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

        public Person getUser() {
            return user;
        }

        public void setUser(Person user) {
            this.user = user;
        }

    }

    public static class Person {

        private int id;

        public int getId() {
            return id;
        }

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

    }
}

@@ -342,16 +342,47 @@
 = 1001;%0A
+        model.name = %22yongbo%22;%0A
         
@@ -404,24 +404,24 @@
 w Person();%0A
-
         mode
@@ -598,67 +598,8 @@
 ) %7B%0A
-                System.out.printf(%22%25s_%25s%5Cn%22, name, value);%0A
     
@@ -761,16 +761,36 @@
 :1001,%5C%22
+name%5C%22:%5C%22yongbo%5C%22,%5C%22
 user%5C%22:%7B
@@ -881,24 +881,53 @@
  int    id;%0A
+        private String name;%0A
         priv
@@ -1189,24 +1189,24 @@
 son user) %7B%0A
-
             
@@ -1230,24 +1230,178 @@
 %0A        %7D%0A%0A
+        public String getName() %7B%0A            return name;%0A        %7D%0A%0A        public void setName(String name) %7B%0A            this.name = name;%0A        %7D%0A%0A
     %7D%0A%0A    p

change testcase