当前位置: 首页>>代码示例>>Java>>正文


Java JsonPath.from方法代码示例

本文整理汇总了Java中com.jayway.restassured.path.json.JsonPath.from方法的典型用法代码示例。如果您正苦于以下问题:Java JsonPath.from方法的具体用法?Java JsonPath.from怎么用?Java JsonPath.from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jayway.restassured.path.json.JsonPath的用法示例。


在下文中一共展示了JsonPath.from方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dataverseCategory

import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
@Test
public void dataverseCategory() {
    Response enableNonPublicSearch = enableSetting(SettingsServiceBean.Key.SearchApiNonPublicAllowed);
    assertEquals(200, enableNonPublicSearch.getStatusCode());

    /**
     * Unfortunately, it appears that the ability to specify the category of
     * a dataverse when creating it is a GUI-only feature. It can't
     * currently be done via the API, to our knowledge. You also can't tell
     * from the API which category was persisted but it always seems to be
     * "UNCATEGORIZED"
     */
    TestDataverse dataverseToCreate = new TestDataverse(dv1, "dv1", Dataverse.DataverseType.ORGANIZATIONS_INSTITUTIONS);
    Response createDvResponse = createDataverse(dataverseToCreate, homer);
    assertEquals(201, createDvResponse.getStatusCode());

    TestSearchQuery query = new TestSearchQuery("dv1");
    Response searchResponse = search(query, homer);
    JsonPath jsonPath = JsonPath.from(searchResponse.body().asString());
    String dv1Category = jsonPath.get("data.facets." + SearchFields.DATAVERSE_CATEGORY).toString();
    String msg = "dv1Category: " + dv1Category;
    assertEquals("dv1Category: [null]", msg);

    Response disableNonPublicSearch = deleteSetting(SettingsServiceBean.Key.SearchApiNonPublicAllowed);
    assertEquals(200, disableNonPublicSearch.getStatusCode());
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:27,代码来源:SearchIT.java

示例2: suggestLimit

import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
@Test
public void suggestLimit() throws Exception {
    // given
    final String columnMetadata = IOUtils.toString(Application.class.getResourceAsStream("suggestions/date_column.json"),
            UTF_8);

    // when
    final String response = given() //
            .contentType(JSON) //
            .body(columnMetadata) //
            .when() //
            .post("/suggest/column?limit=2") //
            .asString();

    // then
    final JsonPath json = JsonPath.from(response);
    assertThat(json.getList("").size(), is(2));
}
 
开发者ID:Talend,项目名称:data-prep,代码行数:19,代码来源:SuggestionTest.java

示例3: suggestLimitDefault

import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
@Test
public void suggestLimitDefault() throws Exception {
    // given
    final String columnMetadata = IOUtils.toString(Application.class.getResourceAsStream("suggestions/date_column.json"),
            UTF_8);

    // when
    final String response = given() //
            .contentType(JSON) //
            .body(columnMetadata) //
            .when() //
            .post("/suggest/column") //
            .asString();

    // then
    final JsonPath json = JsonPath.from(response);
    assertThat(json.getList("").size(), is(5)); // Default for "limit" is 5.
}
 
开发者ID:Talend,项目名称:data-prep,代码行数:19,代码来源:SuggestionTest.java

示例4: createUser

import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
private static JsonObject createUser(String jsonStr) {
    JsonObjectBuilder createdUser = Json.createObjectBuilder();
    Response response = createUserViaApi(jsonStr, getPassword(jsonStr));
    Assert.assertEquals(200, response.getStatusCode());
    JsonPath jsonPath = JsonPath.from(response.body().asString());
    createdUser.add(idKey, jsonPath.getInt("data.user." + idKey));
    createdUser.add(usernameKey, jsonPath.get("data.user." + usernameKey).toString());
    createdUser.add(apiTokenKey, jsonPath.get("data." + apiTokenKey).toString());
    return createdUser.build();
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:11,代码来源:SearchIT.java

示例5: findDatasetIdFromGlobalId

import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
/**
 * Assumes you have turned on experimental non-public search
 * https://github.com/IQSS/dataverse/issues/1299
 *
 * curl -X PUT -d true
 * http://localhost:8080/api/admin/settings/:SearchApiNonPublicAllowed
 *
 * @return The Integer found or null.
 */
private static Integer findDatasetIdFromGlobalId(String globalId, String apiToken) {
    Response searchForGlobalId = given()
            .get("api/search?key=" + apiToken
                    + "&q=dsPersistentId:\""
                    + globalId.replace(":", "\\:")
                    + "\"&show_entity_ids=true");
    JsonPath jsonPath = JsonPath.from(searchForGlobalId.body().asString());
    int id;
    try {
        id = jsonPath.get("data.items[0].entity_id");
    } catch (IllegalArgumentException ex) {
        return null;
    }
    return id;
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:25,代码来源:SearchIT.java

示例6: jsonBody

import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
public static Matcher<TypedOutput> jsonBody(final Matcher<JsonPath> mimeType) {
    return new FeatureMatcher<TypedOutput, JsonPath>(mimeType, "a request body with mime type", "mime type") {
        @Override
        protected JsonPath featureValueOf(TypedOutput actual) {
            final int capacity = (int) Math.max(actual.length(), 32);
            final ByteArrayOutputStream os = new ByteArrayOutputStream(capacity);
            try {
                actual.writeTo(os);
                return JsonPath.from(new String(os.toByteArray(), StandardCharsets.UTF_8));
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }
    };
}
 
开发者ID:ccmtaylor,项目名称:retromock,代码行数:16,代码来源:IsRequestWithBody.java

示例7: getRoleAssignmentId

import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
private long getRoleAssignmentId(Response response) {
    JsonPath jsonPath = JsonPath.from(response.body().asString());
    return jsonPath.getInt("data.id");
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:5,代码来源:SearchIT.java


注:本文中的com.jayway.restassured.path.json.JsonPath.from方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。