use of com.jayway.jsonpath.JsonPath in project batfish by batfish.
the class JsonPathTest method testPath3.
@Test
public void testPath3() {
JsonPath jsonPath = JsonPath.compile("$.nodes[*][?(!@.ntpServers)]");
assertThat(jsonPath, not(equalTo(nullValue())));
}
use of com.jayway.jsonpath.JsonPath in project batfish by batfish.
the class JsonPathTest method testOneNtpServerPresentViolation.
@Test
public void testOneNtpServerPresentViolation() {
String path = "$.nodes[*][?(!([\"9.9.9.9\"] subsetof @.ntpServers))].ntpServers";
JsonPath jsonPath = JsonPath.compile(path);
ArrayNode prefixes = null;
try {
prefixes = jsonPath.read(_oneNtpServerNodesAnswerJsonObject, _prefixConfiguration);
} catch (PathNotFoundException e) {
prefixes = JsonNodeFactory.instance.arrayNode();
}
assertThat(prefixes, not(equalTo(nullValue())));
assertThat(prefixes.size(), equalTo(1));
}
use of com.jayway.jsonpath.JsonPath in project batfish by batfish.
the class JsonPathTest method testOneNtpServerSanctioned.
@Test
public void testOneNtpServerSanctioned() {
String path = "$.nodes[*].ntpServers[?(@ nin [\"1.2.3.4\"])]";
JsonPath jsonPath = JsonPath.compile(path);
ArrayNode prefixes = null;
try {
prefixes = jsonPath.read(_oneNtpServerNodesAnswerJsonObject, _prefixConfiguration);
} catch (PathNotFoundException e) {
prefixes = JsonNodeFactory.instance.arrayNode();
}
assertThat(prefixes, not(equalTo(nullValue())));
assertThat(prefixes.size(), equalTo(0));
}
use of com.jayway.jsonpath.JsonPath in project batfish by batfish.
the class JsonPathTest method testTwoNtpServersPresentViolation.
@Test
public void testTwoNtpServersPresentViolation() {
String path = "$.nodes[*][?(!([\"1.2.3.4\", \"9.9.9.9\"] subsetof @.ntpServers))].ntpServers";
JsonPath jsonPath = JsonPath.compile(path);
ArrayNode prefixes = null;
try {
prefixes = jsonPath.read(_twoNtpServersNodesAnswerJsonObject, _prefixConfiguration);
} catch (PathNotFoundException e) {
prefixes = JsonNodeFactory.instance.arrayNode();
}
assertThat(prefixes, not(equalTo(nullValue())));
assertThat(prefixes.size(), equalTo(1));
}
use of com.jayway.jsonpath.JsonPath in project JsonPath by json-path.
the class IssuesTest method github_89.
@Test(expected = PathNotFoundException.class)
public void github_89() {
com.google.gson.JsonObject json = new JsonObject();
json.addProperty("foo", "bar");
JsonPath path = JsonPath.compile("$.foo");
String object = path.read(json);
}
Aggregations