-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
DemoTest.java
81 lines (67 loc) · 2.57 KB
/
DemoTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.jayway.jsonpath.matchers;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.io.File;
import static com.jayway.jsonpath.matchers.JsonPathMatchers.*;
import static com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resource;
import static com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resourceAsFile;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
@Disabled
public class DemoTest {
@Test
public void shouldFailOnJsonString() {
String json = resource("books.json");
assertThat(json, isJson(withJsonPath("$.store.name", equalTo("The Shop"))));
}
@Test
public void shouldFailOnJsonFile() {
File json = resourceAsFile("books.json");
assertThat(json, isJson(withJsonPath("$.store.name", equalTo("The Shop"))));
}
@Test
public void shouldFailOnInvalidJsonString() {
String json = resource("invalid.json");
assertThat(json, isJson(withJsonPath("$.store.name", equalTo("The Shop"))));
}
@Test
public void shouldFailOnInvalidJsonFile() {
File json = resourceAsFile("invalid.json");
assertThat(json, isJson(withJsonPath("$.store.name", equalTo("The Shop"))));
}
@Test
public void shouldFailOnTypedJsonString() {
String json = resource("books.json");
assertThat(json, isJsonString(withJsonPath("$.store.name", equalTo("The Shop"))));
}
@Test
public void shouldFailOnTypedJsonFile() {
File json = resourceAsFile("books.json");
assertThat(json, isJsonFile(withJsonPath("$.store.name", equalTo("The Shop"))));
}
@Test
public void shouldFailOnTypedInvalidJsonString() {
String json = resource("invalid.json");
assertThat(json, isJsonString(withJsonPath("$.store.name", equalTo("The Shop"))));
}
@Test
public void shouldFailOnTypedInvalidJsonFile() {
File json = resourceAsFile("invalid.json");
assertThat(json, isJsonFile(withJsonPath("$.store.name", equalTo("The Shop"))));
}
@Test
public void shouldFailOnNonExistingJsonPath() {
String json = resource("books.json");
assertThat(json, hasJsonPath("$.not-here"));
}
@Test
public void shouldFailOnExistingJsonPath() {
String json = resource("books.json");
assertThat(json, hasNoJsonPath("$.store.name"));
}
@Test
public void shouldFailOnExistingJsonPathAlternative() {
String json = resource("books.json");
assertThat(json, isJson(withoutJsonPath("$.store.name")));
}
}