Skip to content

Commit

Permalink
add testcase for JSONPath
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Apr 30, 2016
1 parent 3ec0e76 commit 2728045
Showing 1 changed file with 13 additions and 6 deletions.
@@ -1,22 +1,29 @@
package com.alibaba.json.bvt.path;

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;

import junit.framework.TestCase;
import java.util.Map;

import org.junit.Assert;

import com.alibaba.fastjson.JSONPath;

import junit.framework.TestCase;

public class JSONPath_field_wildcard extends TestCase {

public void test_list_map() throws Exception {
JSONPath path = new JSONPath("$.*");
Entity entity = new Entity(123, "wenshao");
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("id", 123);
map.put("name", "wenshao");

List<Object> fieldValues = (List<Object>) path.eval(entity);
Assert.assertSame(entity.getId(), fieldValues.get(0));
Assert.assertSame(entity.getName(), fieldValues.get(1));
Collection<Object> fieldValues = (Collection<Object>) path.eval(map);
Iterator<Object> it = fieldValues.iterator();
Assert.assertSame(map.get("id"), it.next());
Assert.assertSame(map.get("name"), it.next());
}

public void test_list_map_none_root() throws Exception {
Expand Down

0 comments on commit 2728045

Please sign in to comment.