File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
src/test/java/io/jenkins/plugins/jsonpath Expand file tree Collapse file tree 1 file changed +37
-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 org .junit .jupiter .api .Test ;
6
+
7
+ import com .jayway .jsonpath .Configuration ;
8
+ import com .jayway .jsonpath .JsonPath ;
9
+
10
+ public class JsonPathSmokeTest {
11
+
12
+ public static class Person {
13
+ public String name ;
14
+ public int age ;
15
+ public String city ;
16
+ }
17
+
18
+ @ Test
19
+ public void smokeTest () throws Exception {
20
+ String json = "{\" name\" :\" John\" , \" age\" :30, \" city\" :\" New York\" }" ;
21
+
22
+ String name = JsonPath .read (json , "$.name" );
23
+ int age = JsonPath .read (json , "$.age" );
24
+ String city = JsonPath .read (json , "$.city" );
25
+
26
+ assertEquals ("John" , name );
27
+ assertEquals (30 , age );
28
+ assertEquals ("New York" , city );
29
+
30
+ Person person = 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
+ }
36
+
37
+ }
You can’t perform that action at this time.
0 commit comments