use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.
the class UpdateServiceInstanceResponseTest method responseWithAllValuesIsBuilt.
@Test
public void responseWithAllValuesIsBuilt() {
UpdateServiceInstanceResponse response = UpdateServiceInstanceResponse.builder().async(true).operation("in progress").build();
assertThat(response.isAsync()).isEqualTo(true);
assertThat(response.getOperation()).isEqualTo("in progress");
DocumentContext json = JsonUtils.toJsonPath(response);
assertThat(json).hasPath("$.operation").isEqualTo("in progress");
}
use of com.jayway.jsonpath.DocumentContext in project fabric8-maven-plugin by fabric8io.
the class Verify method verifyResourceDescriptors.
public static void verifyResourceDescriptors(File actualPath, File expectedPath, boolean strict) throws IOException, ParseException {
String actualText = readFile(actualPath);
String expectedText = readFile(expectedPath);
JsonTextMessageValidator validator = new JsonTextMessageValidator();
validator.setStrict(strict);
DocumentContext actualContext = JsonPath.parse(actualText);
validator.validateJson(newMessage(actualText), newMessage(expectedText), new JsonMessageValidationContext(), createTestContext(), actualContext);
}
use of com.jayway.jsonpath.DocumentContext in project connectors-workspace-one by vmware.
the class SalesforceControllerTest method getAccountRequestSoql.
private String getAccountRequestSoql(String filePath) throws IOException {
DocumentContext ctx = JsonPath.parse(fromFile(filePath));
final String senderDomain = '@' + StringUtils.substringAfterLast(senderEmail(ctx), "@");
return String.format(QUERY_FMT_ACCOUNT, senderDomain, userEmail(ctx));
}
use of com.jayway.jsonpath.DocumentContext in project solr-cmd-utils by tblsoft.
the class JsonPathReader method loadJsonContext.
protected DocumentContext loadJsonContext() throws IOException {
DocumentContext context = null;
String url = getProperty("url", null);
String filename = getProperty("filename", null);
if (StringUtils.isNotEmpty(url)) {
// @todo jsonBody has encoding bug
String jsonBody = HTTPHelper.get(url);
context = JsonPath.parse(jsonBody);
} else if (StringUtils.isNotEmpty(filename)) {
File jsonFile = IOUtils.getAbsoluteFileAsFile(getBaseDir(), filename);
context = JsonPath.parse(jsonFile);
}
return context;
}
use of com.jayway.jsonpath.DocumentContext in project JsonPath by json-path.
the class IssuesTest method issue_97.
@Test
public void issue_97() throws Exception {
String json = "{ \"books\": [ " + "{ \"category\": \"fiction\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"fiction\" }, " + "{ \"category\": \"fiction\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"fiction\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"reference\" } ] }";
Configuration conf = Configuration.builder().jsonProvider(new GsonJsonProvider()).mappingProvider(new GsonMappingProvider()).build();
DocumentContext context = JsonPath.using(conf).parse(json);
context.delete("$.books[?(@.category == 'reference')]");
List<String> categories = context.read("$..category", List.class);
assertThat(categories).containsOnly("fiction");
}
Aggregations