Java Code Examples for io.restassured.path.json.JsonPath#from()

The following examples show how to use io.restassured.path.json.JsonPath#from() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CrawlTestBase.java    From fess with Apache License 2.0 6 votes vote down vote up
protected static void deleteDocuments(final String queryString) {
    List<String> docIds = new ArrayList<>();
    Response response =
            given().contentType("application/json").param("scroll", "1m").param("q", queryString)
                    .get(getEsUrl() + "/" + DOC_INDEX_NAME + "/" + DOC_TYPE_NAME + "/_search");
    JsonPath jsonPath = JsonPath.from(response.asString());
    String scrollId = jsonPath.getString("_scroll_id");
    while (true) {
        List<String> resultIds = jsonPath.getList("hits.hits._id");
        if (resultIds.size() == 0) {
            break;
        }
        docIds.addAll(resultIds);
        Map<String, Object> scrollBody = new HashMap<>();
        scrollBody.put("scroll", "1m");
        scrollBody.put("scroll_id", scrollId);
        response = given().contentType("application/json").body(scrollBody).get(getEsUrl() + "/_search/scroll");
        jsonPath = JsonPath.from(response.asString());
    }

    for (String docId : docIds) {
        given().contentType("application/json").delete(getEsUrl() + "/" + DOC_INDEX_NAME + "/" + DOC_TYPE_NAME + "/" + docId);
    }
}
 
Example 2
Source File: SearchApiTests.java    From fess with Apache License 2.0 5 votes vote down vote up
private static String createLabel() {
    Map<String, Object> labelBody = new HashMap<>();
    labelBody.put("name", TEST_LABEL);
    labelBody.put("value", TEST_LABEL);
    labelBody.put("included_paths", ".*tools.*");
    Response response = checkMethodBase(labelBody).put("/api/admin/labeltype/setting");
    JsonPath jsonPath = JsonPath.from(response.asString());
    assertTrue(jsonPath.getBoolean("response.created"));
    assertEquals(0, jsonPath.getInt("response.status"));
    return jsonPath.get("response.id");
}
 
Example 3
Source File: SearchApiTests.java    From fess with Apache License 2.0 5 votes vote down vote up
private static String createCrawlLabel() {
    Map<String, Object> labelBody = new HashMap<>();
    labelBody.put("name", CRAWL_LABEL);
    labelBody.put("value", CRAWL_LABEL);
    labelBody.put("included_paths", ".*");
    Response response = checkMethodBase(labelBody).put("/api/admin/labeltype/setting");
    JsonPath jsonPath = JsonPath.from(response.asString());
    assertTrue(jsonPath.getBoolean("response.created"));
    assertEquals(0, jsonPath.getInt("response.status"));
    return jsonPath.get("response.id");
}
 
Example 4
Source File: CrawlTestBase.java    From fess with Apache License 2.0 5 votes vote down vote up
protected static String createWebConfig(final Map<String, Object> requestBody) {
    String response = checkMethodBase(requestBody).put("/api/admin/webconfig/setting").asString();
    JsonPath jsonPath = JsonPath.from(response);
    assertTrue(jsonPath.getBoolean("response.created"));
    assertEquals(0, jsonPath.getInt("response.status"));
    return jsonPath.getString("response.id");
}
 
Example 5
Source File: CrawlTestBase.java    From fess with Apache License 2.0 5 votes vote down vote up
protected static String createFileConfig(final Map<String, Object> requestBody) {
    String response = checkMethodBase(requestBody).put("/api/admin/fileconfig/setting").asString();
    JsonPath jsonPath = JsonPath.from(response);
    assertTrue(jsonPath.getBoolean("response.created"));
    assertEquals(0, jsonPath.getInt("response.status"));
    return jsonPath.getString("response.id");
}