Skip to content

Commit 834894a

Browse files
committed
Add smoke tests
1 parent 8b7dc8b commit 834894a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
}

0 commit comments

Comments
 (0)