package com.alibaba.json.bvt.path;

import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONPath;
import com.alibaba.fastjson.JSONPathException;
import junit.framework.TestCase;

import java.util.HashMap;
import java.util.Map;

public class JSONPath_9 extends TestCase {

    public void test_paths() throws Exception {
        Model m = new Model();
        m.f0 = 101;
        m.f1 = 102;

        Map<String, Object> paths = JSONPath.paths(m);
        assertEquals(3, paths.size());
    }

    public void test_paths_1() throws Exception {
        Map map = new HashMap();
        map.put("f0", 1001);
        map.put("f1", 1002);

        Map<String, Object> paths = JSONPath.paths(map);
        assertEquals(3, paths.size());
    }

    public void test_paths_2() throws Exception {
        Map map = new HashMap();
        map.put("f0", 1001);
        map.put("f1", 1002);

        JSONPath path = new JSONPath("$.f0");
        assertEquals("$.f0", path.getPath());
        assertEquals(1001, path.eval(map));
    }

    public static class Model {
        public Integer f0;
        public Integer f1;

    }

//    public void test_path_2() throws Exception {
////        File file = new File("/Users/wenshao/Downloads/test");
////        String json = FileUtils.readFileToString(file);
//        String json = "{\"returnObj\":[{\"$ref\":\"$.subInvokes.com\\\\.alipay\\\\.cif\\\\.user\\\\.UserInfoQueryService\\\\@findUserInfosByCardNo\\\\(String[])[0].response[0]\"}]}";
//        JSON.parseObject(json);
//    }

}

@@ -238,16 +238,54 @@
 til.Map;
+%0Aimport java.util.concurrent.TimeUnit;
 %0A%0Apublic
@@ -1065,16 +1065,226 @@
 l(map));
+%0A%0A        path.remove(null);%0A    %7D%0A%0A    public void test_paths_3() throws Exception %7B%0A        JSONPath.paths(null);%0A        JSONPath.paths(1);%0A        JSONPath.paths(%221%22);%0A        JSONPath.paths(TimeUnit.DAYS);
 %0A    %7D%0A%0A

add testcase.