File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
src/test/java/io/jenkins/plugins/jsonpath Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ package io .jenkins .plugins .jsonpath ;
2+
3+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4+
5+ import com .jayway .jsonpath .Configuration ;
6+ import com .jayway .jsonpath .JsonPath ;
7+ import org .junit .jupiter .api .Test ;
8+
9+ public class JsonPathSmokeTest {
10+
11+ public static class Person {
12+ public String name ;
13+ public int age ;
14+ public String city ;
15+ }
16+
17+ @ Test
18+ public void smokeTest () throws Exception {
19+ String json = "{\" name\" :\" John\" , \" age\" :30, \" city\" :\" New York\" }" ;
20+
21+ String name = JsonPath .read (json , "$.name" );
22+ int age = JsonPath .read (json , "$.age" );
23+ String city = JsonPath .read (json , "$.city" );
24+
25+ assertEquals ("John" , name );
26+ assertEquals (30 , age );
27+ assertEquals ("New York" , city );
28+
29+ Person person =
30+ JsonPath .using (Configuration .defaultConfiguration ()).parse (json ).read ("$" , Person .class );
31+ assertEquals ("John" , person .name );
32+ assertEquals (30 , person .age );
33+ assertEquals ("New York" , person .city );
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments